Search in sources :

Example 41 with SSOToken

use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.

the class TokenResource method getUid.

private AMIdentity getUid(Context context) throws SSOException, IdRepoException, UnauthorizedClientException {
    String cookie = getCookieFromServerContext(context);
    SSOTokenManager mgr = SSOTokenManager.getInstance();
    SSOToken token = mgr.createSSOToken(cookie);
    return identityManager.getResourceOwnerIdentity(token.getProperty("UserToken"), token.getProperty("Organization"));
}
Also used : SSOTokenManager(com.iplanet.sso.SSOTokenManager) SSOToken(com.iplanet.sso.SSOToken)

Example 42 with SSOToken

use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.

the class Issue619Test method testGetPolicyDecision.

@Test(groups = { "policy-client" })
@Parameters({ "orgName", "userName", "password", "serviceName", "resourceName", "actionName" })
public void testGetPolicyDecision(String orgName, String userName, String password, String serviceName, String resourceName, String actionName) 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);
    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);
    log(Level.INFO, "set auth level in envMap as a set containing " + "/:1, /:2", "\n");
    attrSet.add("/:1");
    attrSet.add("/:2");
    env.put(Condition.REQUEST_AUTH_LEVEL, 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)

Example 43 with SSOToken

use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.

the class Issue736Test method testGetPolicyDecision.

@Test(groups = { "policy-client" })
@Parameters({ "orgName", "userName", "password", "serviceName", "actionName" })
public void testGetPolicyDecision(String orgName, String userName, String password, String serviceName, String actionName) throws Exception {
    entering("Issue736Test.testGetPolicyDecision()", null);
    String resourceName = "http://host1.sample.com:80/banner.html";
    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);
    SSOToken token = TokenUtils.getSessionToken(orgName, userName, password);
    log(Level.INFO, "Created ssoToken", "\n");
    PolicyEvaluator pe = PolicyEvaluatorFactory.getInstance().getPolicyEvaluator(serviceName);
    Set actions = new HashSet();
    actions.add(actionName);
    PolicyDecision pd = pe.getPolicyDecision(token, resourceName, actions, //null envMap
    null);
    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) HashSet(java.util.HashSet) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 44 with SSOToken

use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.

the class PolicyEvaluatorTest method testGetPolicyDecision.

@Test(groups = { "policy-client" })
@Parameters({ "orgName", "userName", "password", "serviceName", "resourceName", "actionName" })
public void testGetPolicyDecision(String orgName, String userName, String password, String serviceName, String resourceName, String actionName) 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);
    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)

Example 45 with SSOToken

use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.

the class RealmTest method createRealmWithSameName.

/**
     * Test case of creating a new with the same name. Should throw
     * an SMSException that realm already exists.
     */
@Test(groups = ("api"), expectedExceptions = { SMSException.class })
public void createRealmWithSameName() throws SMSException, SSOException {
    OrganizationConfigManager ocm = null;
    String realm = "sm-noissue-create-realm-with-same-name";
    try {
        SSOToken token = getAdminSSOToken();
        ocm = new OrganizationConfigManager(token, "/");
        ocm.createSubOrganization(realm, Collections.EMPTY_MAP);
        ocm.createSubOrganization(realm, Collections.EMPTY_MAP);
    } finally {
        if (ocm != null) {
            ocm.deleteSubOrganization(realm, true);
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Test(org.testng.annotations.Test)

Aggregations

SSOToken (com.iplanet.sso.SSOToken)776 SSOException (com.iplanet.sso.SSOException)390 Set (java.util.Set)226 SMSException (com.sun.identity.sm.SMSException)218 HashSet (java.util.HashSet)179 IdRepoException (com.sun.identity.idm.IdRepoException)144 HashMap (java.util.HashMap)130 Test (org.testng.annotations.Test)130 CLIException (com.sun.identity.cli.CLIException)117 Iterator (java.util.Iterator)115 AMIdentity (com.sun.identity.idm.AMIdentity)113 Map (java.util.Map)113 IOutput (com.sun.identity.cli.IOutput)99 IOException (java.io.IOException)68 List (java.util.List)57 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)56 IdType (com.sun.identity.idm.IdType)54 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)53 EntitlementException (com.sun.identity.entitlement.EntitlementException)52 ServiceConfig (com.sun.identity.sm.ServiceConfig)52