Search in sources :

Example 1 with OpenSSOUserSubject

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

the class ApplicationDelegationTest method createPrivileges.

private void createPrivileges() throws EntitlementException {
    PrivilegeManager pm = PrivilegeManager.getInstance("/", adminSubject);
    Map<String, Boolean> actionValues = new HashMap<String, Boolean>();
    actionValues.put("GET", Boolean.TRUE);
    Entitlement entitlement = new Entitlement(APPL_NAME, DELEGATED_RESOURCE_BASE, actionValues);
    OpenSSOUserSubject subject = new OpenSSOUserSubject("id=dummy,ou=user," + SMSEntry.getRootSuffix());
    Privilege privilege1 = Privilege.getNewInstance();
    privilege1.setName(PRIVILEGE_NAME1);
    privilege1.setEntitlement(entitlement);
    privilege1.setSubject(subject);
    pm.add(privilege1);
    Privilege privilege2 = Privilege.getNewInstance();
    privilege2.setName(PRIVILEGE_NAME2);
    entitlement.setResourceName(DELEGATED_RESOURCE);
    privilege2.setEntitlement(entitlement);
    privilege2.setSubject(subject);
    pm.add(privilege2);
}
Also used : HashMap(java.util.HashMap) OpenSSOUserSubject(com.sun.identity.entitlement.opensso.OpenSSOUserSubject)

Example 2 with OpenSSOUserSubject

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

the class ApplicationFilterTest method createDelegationPrivilege.

private void createDelegationPrivilege() throws SMSException, EntitlementException, SSOException, IdRepoException, InterruptedException {
    ApplicationPrivilege ap = new ApplicationPrivilege(DELEGATE_PRIVILEGE_NAME);
    OpenSSOUserSubject sbj = new OpenSSOUserSubject();
    sbj.setID(user1.getUniversalId());
    Set<SubjectImplementation> subjects = new HashSet<SubjectImplementation>();
    subjects.add(sbj);
    ap.setSubject(subjects);
    Map<String, Set<String>> appRes = new HashMap<String, Set<String>>();
    Set<String> res = new HashSet<String>();
    appRes.put(APPL_NAME, res);
    res.add(DELEGATED_RESOURCE_BASE);
    ap.setApplicationResources(appRes);
    ap.setActionValues(ApplicationPrivilege.PossibleAction.READ);
    ApplicationPrivilegeManager apm = ApplicationPrivilegeManager.getInstance("/", adminSubject);
    apm.addPrivilege(ap);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) OpenSSOUserSubject(com.sun.identity.entitlement.opensso.OpenSSOUserSubject) HashSet(java.util.HashSet)

Example 3 with OpenSSOUserSubject

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

the class ApplicationPrivilegeMetaTest method createDelegationPrivilege.

private void createDelegationPrivilege() throws SMSException, EntitlementException, SSOException, IdRepoException, InterruptedException {
    ApplicationPrivilege ap = new ApplicationPrivilege(DELEGATE_PRIVILEGE_NAME);
    OpenSSOUserSubject sbj = new OpenSSOUserSubject();
    sbj.setID("id=dummy,dc=openam,dc=forgerock,dc=org");
    Set<SubjectImplementation> subjects = new HashSet<SubjectImplementation>();
    subjects.add(sbj);
    ap.setSubject(subjects);
    Map<String, Set<String>> appRes = new HashMap<String, Set<String>>();
    Set<String> res = new HashSet<String>();
    appRes.put(APPL_NAME, res);
    res.add(DELEGATED_RESOURCE);
    ap.setApplicationResources(appRes);
    ap.setActionValues(ApplicationPrivilege.PossibleAction.READ);
    ApplicationPrivilegeManager apm = ApplicationPrivilegeManager.getInstance("/", adminSubject);
    apm.addPrivilege(ap);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) OpenSSOUserSubject(com.sun.identity.entitlement.opensso.OpenSSOUserSubject) HashSet(java.util.HashSet)

Example 4 with OpenSSOUserSubject

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

the class ApplicationDelegationTest method createDelegationPrivilege.

private void createDelegationPrivilege() throws SMSException, EntitlementException, SSOException, IdRepoException, InterruptedException {
    ApplicationPrivilege ap = new ApplicationPrivilege(DELEGATE_PRIVILEGE_NAME);
    OpenSSOUserSubject sbj = new OpenSSOUserSubject();
    sbj.setID(user1.getUniversalId());
    Set<SubjectImplementation> subjects = new HashSet<SubjectImplementation>();
    subjects.add(sbj);
    ap.setSubject(subjects);
    Map<String, Set<String>> appRes = new HashMap<String, Set<String>>();
    Set<String> res = new HashSet<String>();
    appRes.put(APPL_NAME, res);
    res.add(DELEGATED_RESOURCE);
    ap.setApplicationResources(appRes);
    ap.setActionValues(ApplicationPrivilege.PossibleAction.READ);
    ApplicationPrivilegeManager apm = ApplicationPrivilegeManager.getInstance("/", adminSubject);
    apm.addPrivilege(ap);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) OpenSSOUserSubject(com.sun.identity.entitlement.opensso.OpenSSOUserSubject) HashSet(java.util.HashSet)

Example 5 with OpenSSOUserSubject

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

the class PrivilegeDelegationTest method createApplicationPrivilege.

private ApplicationPrivilegeManager createApplicationPrivilege(ApplicationPrivilege.PossibleAction actions) throws EntitlementException {
    ApplicationPrivilegeManager apm = ApplicationPrivilegeManager.getInstance(realm, SubjectUtils.createSubject(adminToken));
    ApplicationPrivilege ap = new ApplicationPrivilege(DELEG_PRIVILEGE_NAME);
    OpenSSOUserSubject sbj = new OpenSSOUserSubject();
    sbj.setID(user.getUniversalId());
    Set<SubjectImplementation> subjects = new HashSet<SubjectImplementation>();
    subjects.add(sbj);
    ap.setSubject(subjects);
    Set<String> res = new HashSet<String>();
    Map<String, Set<String>> appRes = new HashMap<String, Set<String>>();
    appRes.put(ApplicationTypeManager.URL_APPLICATION_TYPE_NAME, res);
    res.add(RESOURCE + "/*");
    ap.setApplicationResources(appRes);
    ap.setActionValues(actions);
    apm.addPrivilege(ap);
    return apm;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) OpenSSOUserSubject(com.sun.identity.entitlement.opensso.OpenSSOUserSubject) HashSet(java.util.HashSet)

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