use of com.sun.identity.entitlement.opensso.OpenSSOUserSubject in project OpenAM by OpenRock.
the class PrivilegeManagerTest method createPrivilege.
private Privilege createPrivilege() throws EntitlementException {
Map<String, Boolean> actionValues = new HashMap<String, Boolean>();
actionValues.put("GET", Boolean.TRUE);
actionValues.put("POST", Boolean.FALSE);
String resourceName = "http://www.privilegemanagertest.com:80";
Entitlement entitlement = new Entitlement(APPL_NAME, resourceName, actionValues);
entitlement.setName("ent1");
String user11 = "id=user11,ou=user," + ServiceManager.getBaseDN();
String user12 = "id=user12,ou=user," + ServiceManager.getBaseDN();
ua1 = new OpenSSOUserSubject();
ua1.setID(user11);
ua2 = new OpenSSOUserSubject();
ua2.setID(user12);
Set<EntitlementSubject> subjects = new HashSet<EntitlementSubject>();
subjects.add(ua1);
subjects.add(ua2);
OrSubject os = new OrSubject(subjects);
IPv4Condition ipc = new IPv4Condition();
ipc.setStartIpAndEndIp(startIp, endIp);
SimpleTimeCondition tc = new SimpleTimeCondition();
tc.setStartTime("08:00");
tc.setEndTime("16:00");
tc.setStartDay("mon");
tc.setEndDay("fri");
Set<EntitlementCondition> conditions = new HashSet<EntitlementCondition>();
conditions.add(tc);
StaticAttributes sa1 = new StaticAttributes();
Set<String> aValues = new HashSet<String>();
aValues.add("a10");
aValues.add("a20");
sa1.setPropertyName("a");
sa1.setPropertyValues(aValues);
sa1.setPResponseProviderName("sa");
StaticAttributes sa2 = new StaticAttributes();
Set<String> bValues = new HashSet<String>();
bValues.add("b10");
bValues.add("b20");
sa2.setPropertyName("b");
sa2.setPropertyValues(bValues);
sa2.setPResponseProviderName("sa");
UserAttributes uat1 = new UserAttributes();
uat1.setPropertyName("email");
uat1.setPResponseProviderName("ua");
UserAttributes uat2 = new UserAttributes();
uat2.setPropertyName("uid");
uat2.setPResponseProviderName("ua");
Set<ResourceAttribute> ra = new HashSet<ResourceAttribute>();
ra.add(sa1);
ra.add(sa2);
ra.add(uat1);
ra.add(uat2);
Privilege priv = Privilege.getNewInstance();
priv.setName(PRIVILEGE_NAME);
priv.setEntitlement(entitlement);
priv.setSubject(os);
priv.setCondition(ipc);
priv.setResourceAttributes(ra);
priv.setDescription(PRIVILEGE_DESC);
return priv;
}
use of com.sun.identity.entitlement.opensso.OpenSSOUserSubject in project OpenAM by OpenRock.
the class DelegationIsAllowedSubResourceTest 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);
}
use of com.sun.identity.entitlement.opensso.OpenSSOUserSubject in project OpenAM by OpenRock.
the class DelegationPrivilegeIdRepoAccessTest method addUserToPrivilege.
private void addUserToPrivilege() throws EntitlementException {
ApplicationPrivilegeManager mgr = ApplicationPrivilegeManager.getInstance(SUB_REALM, PrivilegeManager.superAdminSubject);
ApplicationPrivilege ap = mgr.getPrivilege(DELEGATE_PRIVILEGE_NAME);
Set<SubjectImplementation> eSubjects = new HashSet<SubjectImplementation>();
OpenSSOUserSubject sbj = new OpenSSOUserSubject();
sbj.setID(delegatedUser.getUniversalId());
eSubjects.add(sbj);
OpenSSOUserSubject sbj1 = new OpenSSOUserSubject();
sbj1.setID(delegatedUser1.getUniversalId());
eSubjects.add(sbj1);
ap.setSubject(eSubjects);
mgr.replacePrivilege(ap);
}
use of com.sun.identity.entitlement.opensso.OpenSSOUserSubject in project OpenAM by OpenRock.
the class DelegationPrivilegeSubResourceTest method createDelegationPrivilege.
private void createDelegationPrivilege(String dpName, String uuid, String resource, ApplicationPrivilege.PossibleAction actions) throws SMSException, EntitlementException, SSOException, IdRepoException, InterruptedException {
ApplicationPrivilege ap = new ApplicationPrivilege(dpName);
OpenSSOUserSubject sbj = new OpenSSOUserSubject();
sbj.setID(uuid);
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(ApplicationTypeManager.URL_APPLICATION_TYPE_NAME, res);
res.add(resource);
ap.setApplicationResources(appRes);
ap.setActionValues(actions);
ApplicationPrivilegeManager apm = ApplicationPrivilegeManager.getInstance("/", adminSubject);
apm.addPrivilege(ap);
}
use of com.sun.identity.entitlement.opensso.OpenSSOUserSubject in project OpenAM by OpenRock.
the class DelegationPrivilegeTest method testAdd.
@Test
public void testAdd() throws Exception {
ApplicationPrivilegeManager mgr = ApplicationPrivilegeManager.getInstance(realm, SubjectUtils.createSubject(adminToken));
ApplicationPrivilege ap = new ApplicationPrivilege(testParams.get("DELEGATE_PRIVILEGE_NAME"));
OpenSSOUserSubject sbj = new OpenSSOUserSubject();
sbj.setID(delegatedUser.getUniversalId());
Set<SubjectImplementation> subjects = new HashSet<SubjectImplementation>();
subjects.add(sbj);
ap.setSubject(subjects);
String delResource = testParams.get("DELEGATED_RESOURCE");
Map<String, Set<String>> appRes = new HashMap<String, Set<String>>();
Set<String> res = new HashSet<String>();
appRes.put(ApplicationTypeManager.URL_APPLICATION_TYPE_NAME, res);
res.add(delResource);
ap.setApplicationResources(appRes);
ap.setActionValues(ApplicationPrivilege.PossibleAction.READ_MODIFY_DELEGATE);
mgr.addPrivilege(ap);
Application app = ApplicationManager.getApplication(PrivilegeManager.superAdminSubject, realm, ApplicationTypeManager.URL_APPLICATION_TYPE_NAME);
// Test disabled, unable to fix model change.
// if (app.getResources().contains(delResource)) {
// throw new Exception("DelegationPrivilegeTest.testAdd:" +
// "application resources should not have delegated resource");
// }
}
Aggregations