Search in sources :

Example 61 with SSOToken

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

the class HttpStarEvaluationTest method setup.

@BeforeClass
public void setup() throws Exception {
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    adminSubject = SubjectUtils.createSubject(adminToken);
    PrivilegeManager pm = PrivilegeManager.getInstance("/", adminSubject);
    Privilege privilege = Privilege.getNewInstance();
    privilege.setName(POLICY_NAME);
    Map<String, Boolean> actions = new HashMap<String, Boolean>();
    actions.put("findAll", true);
    Entitlement entitlement = new Entitlement(ApplicationTypeManager.URL_APPLICATION_TYPE_NAME, "http://*", actions);
    privilege.setEntitlement(entitlement);
    privilege.setSubject(new AuthenticatedUsers());
    pm.add(privilege);
}
Also used : SSOToken(com.iplanet.sso.SSOToken) HashMap(java.util.HashMap) AuthenticatedUsers(org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers) BeforeClass(org.testng.annotations.BeforeClass)

Example 62 with SSOToken

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

the class IdentityGroupToEntitlementGroupTest method test.

@Test
public void test() throws Exception {
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    PolicyManager pm = new PolicyManager(adminToken, "/");
    Policy policy = new Policy("IdentityGroupToEntitlementGroupTest", "desc", false);
    policy.addRule(createRule());
    policy.addSubject("subject", createSubject(pm));
    Set<IPrivilege> privileges = PrivilegeUtils.policyObjectToPrivileges(policy);
    if ((privileges == null) || privileges.isEmpty()) {
        throw new Exception("IdentityGroupToEntitlementGroupTest, set is empty");
    }
    Privilege p = (Privilege) privileges.iterator().next();
//uncomment after the groupsubject mapping is done
/*        EntitlementSubject subject = p.getSubject();
        if (!(subject instanceof OrSubject)) {
            throw new Exception(
                "IdentityGroupToEntitlementGroupTest, orSubject not found");
        }

        OrSubject orSubject = (OrSubject)subject;
        Set<EntitlementSubject> subjects = orSubject.getESubjects();
        if ((subjects == null) || (subjects.size() != 2)) {
            throw new Exception(
                "IdentityGroupToEntitlementGroupTest, subjects collection is incorrect");
        }

        for (EntitlementSubject s : subjects) {
            if (!(s instanceof GroupSubject)) {
                throw new Exception(
                    "IdentityGroupToEntitlementGroupTest, no group subject");
            }
        }*/
}
Also used : Policy(com.sun.identity.policy.Policy) PolicyManager(com.sun.identity.policy.PolicyManager) SSOToken(com.iplanet.sso.SSOToken) PolicyException(com.sun.identity.policy.PolicyException) Test(org.testng.annotations.Test)

Example 63 with SSOToken

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

the class IdentityGroupToEntitlementGroupTest method setup.

@BeforeClass
public void setup() throws Exception {
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    AMIdentityRepository amir = new AMIdentityRepository(adminToken, "/");
    group1 = amir.createIdentity(IdType.GROUP, GROUP_NAME1, Collections.EMPTY_MAP);
    group2 = amir.createIdentity(IdType.GROUP, GROUP_NAME2, Collections.EMPTY_MAP);
}
Also used : SSOToken(com.iplanet.sso.SSOToken) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) BeforeClass(org.testng.annotations.BeforeClass)

Example 64 with SSOToken

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

the class SubRealmEvaluationTest method setup.

@BeforeClass
public void setup() throws Exception {
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    adminSubject = SubjectUtils.createSubject(adminToken);
    Application appl = new Application(APPL_NAME, ApplicationTypeManager.getAppplicationType(adminSubject, ApplicationTypeManager.URL_APPLICATION_TYPE_NAME));
    // Test disabled, unable to fix model change
    // Set<String> avaliableResources = new HashSet<String>();
    // avaliableResources.add("http://www.testevaluator.com:80/*");
    // appl.addResources(avaliableResources);
    appl.setEntitlementCombiner(DenyOverride.class);
    ApplicationManager.saveApplication(adminSubject, "/", appl);
}
Also used : SSOToken(com.iplanet.sso.SSOToken) BeforeClass(org.testng.annotations.BeforeClass)

Example 65 with SSOToken

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

the class SubRealmEvaluationTest method evaluate.

private boolean evaluate(String res) throws EntitlementException {
    Subject subject = createSubject(user1.getUniversalId());
    Set actions = new HashSet();
    actions.add("GET");
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    Evaluator evaluator = new Evaluator(SubjectUtils.createSubject(adminToken), APPL_NAME);
    return evaluator.hasEntitlement(SUB_REALM, subject, new Entitlement(res, actions), Collections.EMPTY_MAP);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) SSOToken(com.iplanet.sso.SSOToken) Subject(javax.security.auth.Subject) HashSet(java.util.HashSet)

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