Search in sources :

Example 6 with PolicyEvaluator

use of com.sun.identity.policy.client.PolicyEvaluator in project OpenAM by OpenRock.

the class PolicyEvaluationSample method getPolicyDecision.

private void getPolicyDecision(SSOToken ssoToken, String serviceName, String resourceName, String actionName) throws Exception {
    System.out.println("Entering getPolicyDecision():" + "resourceName=" + resourceName + "," + "serviceName=" + serviceName + "," + "actionName=" + actionName);
    PolicyEvaluator pe = PolicyEvaluatorFactory.getInstance().getPolicyEvaluator(serviceName);
    Map env = new HashMap();
    Set attrSet = new HashSet();
    Set actions = new HashSet();
    actions.add(actionName);
    PolicyDecision pd = pe.getPolicyDecision(ssoToken, resourceName, actions, env);
    System.out.println("policyDecision:" + pd.toXML());
    System.out.println("returning from getPolicyDecision()");
}
Also used : PolicyDecision(com.sun.identity.policy.PolicyDecision) Set(java.util.Set) HashSet(java.util.HashSet) PolicyEvaluator(com.sun.identity.policy.client.PolicyEvaluator) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 7 with PolicyEvaluator

use of com.sun.identity.policy.client.PolicyEvaluator in project OpenAM by OpenRock.

the class AMIdentityMembershipConditionTest method testGetPolicyDecision.

@Test(groups = { "policy-client" })
@Parameters({ "orgName", "userName", "password", "serviceName", "resourceName", "actionName", "invocatorUuid" })
public void testGetPolicyDecision(String orgName, String userName, String password, String serviceName, String resourceName, String actionName, String invocatorUuid) throws Exception {
    entering("testGetPolicyDecision()", null);
    log(Level.INFO, "orgName:", orgName);
    log(Level.INFO, "userName:", userName);
    log(Level.INFO, "password:", password);
    log(Level.INFO, "serviceName:", serviceName);
    log(Level.INFO, "resourceName:", resourceName);
    log(Level.INFO, "actionName:", actionName);
    log(Level.INFO, "invocatorUuid:", invocatorUuid);
    SSOToken token = TokenUtils.getSessionToken(orgName, userName, password);
    log(Level.INFO, "Created ssoToken", "\n");
    PolicyEvaluator pe = PolicyEvaluatorFactory.getInstance().getPolicyEvaluator(serviceName);
    Map env = new HashMap();
    Set attrSet = new HashSet();
    attrSet.add(invocatorUuid);
    env.put("invocatorPrincipalUuid", attrSet);
    log(Level.INFO, "env Map:" + env, "\n");
    Set actions = new HashSet();
    actions.add(actionName);
    PolicyDecision pd = pe.getPolicyDecision(token, resourceName, actions, env);
    log(Level.INFO, "PolicyDecision XML:", pd.toXML());
    entering("testGetPolicyDecision()", null);
}
Also used : PolicyDecision(com.sun.identity.policy.PolicyDecision) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) HashSet(java.util.HashSet) PolicyEvaluator(com.sun.identity.policy.client.PolicyEvaluator) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

PolicyEvaluator (com.sun.identity.policy.client.PolicyEvaluator)7 SSOToken (com.iplanet.sso.SSOToken)6 PolicyDecision (com.sun.identity.policy.PolicyDecision)6 HashSet (java.util.HashSet)6 Map (java.util.Map)6 Set (java.util.Set)6 HashMap (java.util.HashMap)5 Parameters (org.testng.annotations.Parameters)4 Test (org.testng.annotations.Test)4 SSOException (com.iplanet.sso.SSOException)1 SSOTokenManager (com.iplanet.sso.SSOTokenManager)1 AuthContext (com.sun.identity.authentication.AuthContext)1 SSOTokenPrincipal (com.sun.identity.authentication.service.SSOTokenPrincipal)1 PolicyEvaluatorFactory (com.sun.identity.policy.client.PolicyEvaluatorFactory)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 Principal (java.security.Principal)1 StringTokenizer (java.util.StringTokenizer)1 ServletException (javax.servlet.ServletException)1