package eu.musesproject.server.eventprocessor.policy.manage;
import java.util.List;
import org.wso2.balana.Balana;
import org.wso2.balana.PDP;
import org.wso2.balana.PDPConfig;
import org.wso2.balana.finder.AttributeFinder;
import org.wso2.balana.finder.AttributeFinderModule;
import org.wso2.balana.finder.ResourceFinder;
import org.wso2.balana.finder.ResourceFinderModule;
/*
* #%L
* MUSES Server
* %%
* Copyright (C) 2013 - 2014 S2 Grupo
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
public class PolicyDecisionPoint {
/**
* Returns a new PDP instance with new XACML policies
*
* @return a PDP instance
*/
public static PDP getPDPNewInstance(){
Balana balana = PolicyEnforcementPoint.getBalana();
PDPConfig pdpConfig = balana.getPdpConfig();
// registering new attribute finder. so default PDPConfig is needed to change
AttributeFinder attributeFinder = pdpConfig.getAttributeFinder();
List<AttributeFinderModule> finderModules = attributeFinder.getModules();
finderModules.add(new MusesAttributeFinderModule());
attributeFinder.setModules(finderModules);
// registering new resource finder. so default PDPConfig is needed to change
ResourceFinder resourceFinder = pdpConfig.getResourceFinder();
List<ResourceFinderModule> resourceModules = resourceFinder.getModules();
resourceModules.add(new HierarchicalResourceFinder());
resourceFinder.setModules(resourceModules);
return new PDP(new PDPConfig(attributeFinder, pdpConfig.getPolicyFinder(), resourceFinder, true));
}
}