I am trying to run a simple PDP inside a web services. I am getting java.lang.ClassNotFoundException: com.sun.xacml.finder.impl.CurrentEnvModule.
When I run this stand alsone this works. Please help. I have sunxacml.jar in the lib folder of JBoss.
SEVERE: Runtime config file couldn't be loaded so no configurations will be available
com.sun.xacml.ParsingException: couldn't load class com.sun.xacml.finder.impl.CurrentEnvModule
at com.sun.xacml.ConfigurationStore.loadClass(Unknown Source)
at com.sun.xacml.ConfigurationStore.parsePDPConfig(Unknown Source)
at com.sun.xacml.ConfigurationStore.setupConfig(Unknown Source)
at com.sun.xacml.ConfigurationStore.<init>(Unknown Source)
at test.WebServicesPDP.<init>(WebServicesPDP.java:87)
at test.TestWSEJB.ping(TestWSEJB.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.wsf.container.jboss42.DefaultInvocationHandler.invoke(DefaultInvocationHandler.java:102)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:222)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:418)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:274)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:191)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:124)
at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: com.sun.xacml.finder.impl.CurrentEnvModule
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
... 36 more
13:28:52,627 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
com.sun.xacml.ParsingException: couldn't load class com.sun.xacml.finder.impl.CurrentEnvModule
at com.sun.xacml.ConfigurationStore.loadClass(Unknown Source)
at com.sun.xacml.ConfigurationStore.parsePDPConfig(Unknown Source)
at com.sun.xacml.ConfigurationStore.setupConfig(Unknown Source)
at com.sun.xacml.ConfigurationStore.<init>(Unknown Source)
at test.WebServicesPDP.<init>(WebServicesPDP.java:87)
at test.TestWSEJB.ping(TestWSEJB.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.wsf.container.jboss42.DefaultInvocationHandler.invoke(DefaultInvocationHandler.java:102)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:222)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:418)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:274)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:191)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:124)
at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: com.sun.xacml.finder.impl.CurrentEnvModule
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
... 36 more
// this is the actual PDP object we'll use for evaluation
private PDP pdp = null;
/**
* Default constructor. This creates a <code>SimplePDP</code> with a
* <code>PDP</code> based on the configuration defined by the runtime
* property com.sun.xcaml.PDPConfigFile.
*/
public WebServicesPDP() throws Exception {
// load the configuration
System.out.println("loading wspdp");
System.setProperty("com.sun.xacml.PDPConfigFile", "C:\\Install Files\\XACML\\sunxacml\\sunxacml-1.2\\sample\\config\\sample2.xml");
ConfigurationStore store = new ConfigurationStore();
// use the default factories from the configuration
store.useDefaultFactories();
// get the PDP configuration's and setup the PDP
pdp = new PDP(store.getDefaultPDPConfig());
}
/**
* Constructor that takes an array of filenames, each of which
* contains an XACML policy, and sets up a <code>PDP</code> with access
* to these policies only. The <code>PDP</code> is configured
* programatically to have only a few specific modules.
*
* @param policyFiles an arry of filenames that specify policies
*/
public WebServicesPDP(String [] policyFiles) throws Exception {
// Create a PolicyFinderModule and initialize it...in this case,
// we're using the sample FilePolicyModule that is pre-configured
// with a set of policies from the filesystem
System.setProperty("com.sun.xacml.PDPConfigFile", "C:\\Install Files\\XACML\\sunxacml\\sunxacml-1.2\\sample\\config\\standard.xml");
FilePolicyModule filePolicyModule = new FilePolicyModule();
for (int i = 0; i < policyFiles.length; i++)
filePolicyModule.addPolicy(policyFiles[i]);
// next, setup the PolicyFinder that this PDP will use
PolicyFinder policyFinder = new PolicyFinder();
Set policyModules = new HashSet();
policyModules.add(filePolicyModule);
policyFinder.setModules(policyModules);
// now setup attribute finder modules for the current date/time and
// AttributeSelectors (selectors are optional, but this project does
// support a basic implementation)
CurrentEnvModule envAttributeModule = new CurrentEnvModule();
SelectorModule selectorAttributeModule = new SelectorModule();
// Setup the AttributeFinder just like we setup the PolicyFinder. Note
// that unlike with the policy finder, the order matters here. See the
// the javadocs for more details.
AttributeFinder attributeFinder = new AttributeFinder();
List attributeModules = new ArrayList();
attributeModules.add(envAttributeModule);
attributeModules.add(selectorAttributeModule);
attributeFinder.setModules(attributeModules);
// Try to load the time-in-range function, which is used by several
// of the examples...see the documentation for this function to
// understand why it's provided here instead of in the standard
// code base.
FunctionFactoryProxy proxy =
StandardFunctionFactory.getNewFactoryProxy();
FunctionFactory factory = proxy.getConditionFactory();
factory.addFunction(new TimeInRangeFunction());
FunctionFactory.setDefaultFactory(proxy);
/**
* Evaluates the given request and returns the Response that the PDP
* will hand back to the PEP.
*
* @param requestFile the name of a file that contains a Request
*
* @return the result of the evaluation
*
* @throws IOException if there is a problem accessing the file
* @throws ParsingException if the Request is invalid
*/
response = webServicesPDP.evaluate(requestFile);
}
catch(Exception e)
{
System.out.println("Error :" + e.getMessage());
}
// for this sample program, we'll just print out the response
return response;
}
public ResponseCtx evaluate(String requestFile)
throws IOException, ParsingException
{
// setup the request based on the file
RequestCtx request =
RequestCtx.getInstance(new FileInputStream(requestFile));
// evaluate the request
return pdp.evaluate(request);
}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to run a simple PDP inside a web services. I am getting java.lang.ClassNotFoundException: com.sun.xacml.finder.impl.CurrentEnvModule.
When I run this stand alsone this works. Please help. I have sunxacml.jar in the lib folder of JBoss.
SEVERE: Runtime config file couldn't be loaded so no configurations will be available
com.sun.xacml.ParsingException: couldn't load class com.sun.xacml.finder.impl.CurrentEnvModule
at com.sun.xacml.ConfigurationStore.loadClass(Unknown Source)
at com.sun.xacml.ConfigurationStore.parsePDPConfig(Unknown Source)
at com.sun.xacml.ConfigurationStore.setupConfig(Unknown Source)
at com.sun.xacml.ConfigurationStore.<init>(Unknown Source)
at test.WebServicesPDP.<init>(WebServicesPDP.java:87)
at test.TestWSEJB.ping(TestWSEJB.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.wsf.container.jboss42.DefaultInvocationHandler.invoke(DefaultInvocationHandler.java:102)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:222)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:418)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:274)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:191)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:124)
at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: com.sun.xacml.finder.impl.CurrentEnvModule
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
... 36 more
13:28:52,627 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
com.sun.xacml.ParsingException: couldn't load class com.sun.xacml.finder.impl.CurrentEnvModule
at com.sun.xacml.ConfigurationStore.loadClass(Unknown Source)
at com.sun.xacml.ConfigurationStore.parsePDPConfig(Unknown Source)
at com.sun.xacml.ConfigurationStore.setupConfig(Unknown Source)
at com.sun.xacml.ConfigurationStore.<init>(Unknown Source)
at test.WebServicesPDP.<init>(WebServicesPDP.java:87)
at test.TestWSEJB.ping(TestWSEJB.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.wsf.container.jboss42.DefaultInvocationHandler.invoke(DefaultInvocationHandler.java:102)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:222)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:418)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:274)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:191)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:124)
at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: com.sun.xacml.finder.impl.CurrentEnvModule
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
... 36 more
package test;
import javax.ejb.Stateless;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.soap.SOAPBinding;
import org.jboss.annotation.security.SecurityDomain;
import org.jboss.ws.annotation.EndpointConfig;
import com.sun.xacml.ctx.ResponseCtx;
@Stateless
@WebService
(name="TestWSEJB",
targetNamespace = "http://test",
serviceName = "TestWSEJBService")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
@EndpointConfig(configName = "Standard WSSecurity Endpoint")
@SecurityDomain("JBossWS")
public class TestWSEJB {
@WebMethod
public String ping (String name) throws Exception
{
System.out.println("web ws sec");
WebServicesPDP te = new WebServicesPDP();
ResponseCtx res = te.checkWSPolicy();
res.getResults();
return "Hello : " + name;
}
}
WebServicesPDP.java:
package test;
import com.sun.xacml.ConfigurationStore;
import com.sun.xacml.Indenter;
import com.sun.xacml.ParsingException;
import com.sun.xacml.PDP;
import com.sun.xacml.PDPConfig;
import com.sun.xacml.cond.FunctionFactory;
import com.sun.xacml.cond.FunctionFactoryProxy;
import com.sun.xacml.cond.StandardFunctionFactory;
import com.sun.xacml.ctx.RequestCtx;
import com.sun.xacml.ctx.ResponseCtx;
import com.sun.xacml.finder.AttributeFinder;
import com.sun.xacml.finder.PolicyFinder;
import com.sun.xacml.finder.impl.CurrentEnvModule;
import com.sun.xacml.finder.impl.FilePolicyModule;
import com.sun.xacml.finder.impl.SelectorModule;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class WebServicesPDP
{
// this is the actual PDP object we'll use for evaluation
private PDP pdp = null;
/**
* Default constructor. This creates a <code>SimplePDP</code> with a
* <code>PDP</code> based on the configuration defined by the runtime
* property com.sun.xcaml.PDPConfigFile.
*/
public WebServicesPDP() throws Exception {
// load the configuration
System.out.println("loading wspdp");
System.setProperty("com.sun.xacml.PDPConfigFile", "C:\\Install Files\\XACML\\sunxacml\\sunxacml-1.2\\sample\\config\\sample2.xml");
ConfigurationStore store = new ConfigurationStore();
// use the default factories from the configuration
store.useDefaultFactories();
// get the PDP configuration's and setup the PDP
pdp = new PDP(store.getDefaultPDPConfig());
}
/**
* Constructor that takes an array of filenames, each of which
* contains an XACML policy, and sets up a <code>PDP</code> with access
* to these policies only. The <code>PDP</code> is configured
* programatically to have only a few specific modules.
*
* @param policyFiles an arry of filenames that specify policies
*/
public WebServicesPDP(String [] policyFiles) throws Exception {
// Create a PolicyFinderModule and initialize it...in this case,
// we're using the sample FilePolicyModule that is pre-configured
// with a set of policies from the filesystem
System.setProperty("com.sun.xacml.PDPConfigFile", "C:\\Install Files\\XACML\\sunxacml\\sunxacml-1.2\\sample\\config\\standard.xml");
FilePolicyModule filePolicyModule = new FilePolicyModule();
for (int i = 0; i < policyFiles.length; i++)
filePolicyModule.addPolicy(policyFiles[i]);
// next, setup the PolicyFinder that this PDP will use
PolicyFinder policyFinder = new PolicyFinder();
Set policyModules = new HashSet();
policyModules.add(filePolicyModule);
policyFinder.setModules(policyModules);
// now setup attribute finder modules for the current date/time and
// AttributeSelectors (selectors are optional, but this project does
// support a basic implementation)
CurrentEnvModule envAttributeModule = new CurrentEnvModule();
SelectorModule selectorAttributeModule = new SelectorModule();
// Setup the AttributeFinder just like we setup the PolicyFinder. Note
// that unlike with the policy finder, the order matters here. See the
// the javadocs for more details.
AttributeFinder attributeFinder = new AttributeFinder();
List attributeModules = new ArrayList();
attributeModules.add(envAttributeModule);
attributeModules.add(selectorAttributeModule);
attributeFinder.setModules(attributeModules);
// Try to load the time-in-range function, which is used by several
// of the examples...see the documentation for this function to
// understand why it's provided here instead of in the standard
// code base.
FunctionFactoryProxy proxy =
StandardFunctionFactory.getNewFactoryProxy();
FunctionFactory factory = proxy.getConditionFactory();
factory.addFunction(new TimeInRangeFunction());
FunctionFactory.setDefaultFactory(proxy);
// finally, initialize our pdp
pdp = new PDP(new PDPConfig(attributeFinder, policyFinder, null));
}
/**
* Evaluates the given request and returns the Response that the PDP
* will hand back to the PEP.
*
* @param requestFile the name of a file that contains a Request
*
* @return the result of the evaluation
*
* @throws IOException if there is a problem accessing the file
* @throws ParsingException if the Request is invalid
*/
public ResponseCtx checkWSPolicy()
{
ResponseCtx response = null;
try{
WebServicesPDP webServicesPDP = null;
String requestFile = null;
requestFile = "C:\\Install Files\\XACML\\sunxacml\\sunxacml-1.2\\sample\\wsrequest\\wsrequest.xml";
String [] policyFiles = null;
policyFiles[0] = "C:\\Install Files\\XACML\\sunxacml\\sunxacml-1.2\\sample\\wspolicy\\wsaccesspolicy.xml";
webServicesPDP = new WebServicesPDP(policyFiles);
response = webServicesPDP.evaluate(requestFile);
}
catch(Exception e)
{
System.out.println("Error :" + e.getMessage());
}
// for this sample program, we'll just print out the response
return response;
}
public ResponseCtx evaluate(String requestFile)
throws IOException, ParsingException
{
// setup the request based on the file
RequestCtx request =
RequestCtx.getInstance(new FileInputStream(requestFile));
// evaluate the request
return pdp.evaluate(request);
}
}