Search in sources :

Example 21 with OpenSSOUserSubject

use of com.sun.identity.entitlement.opensso.OpenSSOUserSubject in project OpenAM by OpenRock.

the class TestEvaluator method createReferral.

private void createReferral(SSOToken adminToken, Subject adminSubject) throws SMSException, EntitlementException, SSOException, IdRepoException, InterruptedException {
    OrganizationConfigManager orgMgr = new OrganizationConfigManager(adminToken, "/");
    String subRealm = SUB_REALM.substring(1);
    orgMgr.createSubOrganization(subRealm, Collections.EMPTY_MAP);
    Map<String, Set<String>> map = new HashMap<String, Set<String>>();
    Set<String> set = new HashSet<String>();
    map.put(APPL_NAME, set);
    set.add("http://www.testevaluator.com:80/*");
    Set<String> realms = new HashSet<String>();
    realms.add(SUB_REALM);
    ReferralPrivilege referral = new ReferralPrivilege(REFERRAL_NAME, map, realms);
    PrivilegeManager pm = PrivilegeManager.getInstance(SUB_REALM, adminSubject);
    Map<String, Boolean> actions = new HashMap<String, Boolean>();
    actions.put("GET", Boolean.TRUE);
    Entitlement ent = new Entitlement(APPL_NAME, URL1, actions);
    user1 = IdRepoUtils.createUser("/", USER1_NAME);
    user2 = IdRepoUtils.createUser("/", USER2_NAME);
    Set<EntitlementSubject> esSet = new HashSet<EntitlementSubject>();
    EntitlementSubject es1 = new OpenSSOUserSubject(user1.getUniversalId());
    EntitlementSubject es2 = new OpenSSOUserSubject(user2.getUniversalId());
    esSet.add(es1);
    esSet.add(es2);
    EntitlementSubject eSubject = new OrSubject(esSet);
    Privilege privilege = Privilege.getNewInstance();
    privilege.setName(PRIVILEGE1_NAME);
    privilege.setEntitlement(ent);
    privilege.setSubject(eSubject);
    pm.add(privilege);
    Thread.sleep(1000);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) OpenSSOUserSubject(com.sun.identity.entitlement.opensso.OpenSSOUserSubject) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) HashSet(java.util.HashSet)

Example 22 with OpenSSOUserSubject

use of com.sun.identity.entitlement.opensso.OpenSSOUserSubject in project OpenAM by OpenRock.

the class ApplicationPrivilegeBase method getSubjects.

protected Set<SubjectImplementation> getSubjects(RequestContext rc) throws CLIException {
    Set<SubjectImplementation> eSubjects = new HashSet<SubjectImplementation>();
    boolean bUser = isUserSubject();
    IdType idType = (bUser) ? IdType.USER : IdType.GROUP;
    String realm = getStringOptionValue(IArgument.REALM_NAME);
    List<String> subjects = rc.getOption(PARAM_SUBJECTS);
    for (String s : subjects) {
        // create AMIdentity just to get the uuid.
        AMIdentity amid = new AMIdentity(null, s, idType, realm, null);
        String universalId = amid.getUniversalId();
        SubjectImplementation sbj = (bUser) ? new OpenSSOUserSubject(universalId) : new OpenSSOGroupSubject(universalId);
        eSubjects.add(sbj);
    }
    return eSubjects;
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) OpenSSOGroupSubject(com.sun.identity.entitlement.opensso.OpenSSOGroupSubject) OpenSSOUserSubject(com.sun.identity.entitlement.opensso.OpenSSOUserSubject) SubjectImplementation(com.sun.identity.entitlement.SubjectImplementation) HashSet(java.util.HashSet) IdType(com.sun.identity.idm.IdType)

Aggregations

OpenSSOUserSubject (com.sun.identity.entitlement.opensso.OpenSSOUserSubject)22 HashMap (java.util.HashMap)19 HashSet (java.util.HashSet)17 Set (java.util.Set)11 Entitlement (com.sun.identity.entitlement.Entitlement)4 Privilege (com.sun.identity.entitlement.Privilege)4 IPv4Condition (org.forgerock.openam.entitlement.conditions.environment.IPv4Condition)4 SubjectImplementation (com.sun.identity.entitlement.SubjectImplementation)3 UserSubject (com.sun.identity.entitlement.UserSubject)3 Test (org.testng.annotations.Test)3 SSOException (com.iplanet.sso.SSOException)2 AndCondition (com.sun.identity.entitlement.AndCondition)2 EntitlementCondition (com.sun.identity.entitlement.EntitlementCondition)2 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)2 OrSubject (com.sun.identity.entitlement.OrSubject)2 ResourceAttribute (com.sun.identity.entitlement.ResourceAttribute)2 StaticAttributes (com.sun.identity.entitlement.StaticAttributes)2 UserAttributes (com.sun.identity.entitlement.UserAttributes)2 OpenSSOGroupSubject (com.sun.identity.entitlement.opensso.OpenSSOGroupSubject)2 AMIdentity (com.sun.identity.idm.AMIdentity)2