use of com.sun.identity.entitlement.opensso.OpenSSOGroupSubject in project OpenAM by OpenRock.
the class ApplicationPrivilegeBase method getSubjects.
protected Map<String, Set<String>> getSubjects(ApplicationPrivilege appPrivilege) {
Map<String, Set<String>> results = new HashMap<String, Set<String>>();
Set<SubjectImplementation> subjects = appPrivilege.getSubjects();
for (SubjectImplementation subject : subjects) {
String type = null;
String uuid = null;
if (subject instanceof OpenSSOUserSubject) {
type = PARAM_SUBJECT_USER;
uuid = ((OpenSSOUserSubject) subject).getID();
} else if (subject instanceof OpenSSOGroupSubject) {
type = PARAM_SUBJECT_GROUP;
uuid = ((OpenSSOGroupSubject) subject).getID();
}
if (type != null) {
Set<String> set = results.get(type);
if (set == null) {
set = new HashSet<String>();
results.put(type, set);
}
set.add(uuid);
}
}
return results;
}
use of com.sun.identity.entitlement.opensso.OpenSSOGroupSubject in project OpenAM by OpenRock.
the class TestGroupEvaluator method setup.
@BeforeClass
public void setup() throws Exception {
if (!migrated) {
return;
}
resourceTypeService = Mockito.mock(ResourceTypeService.class);
constraintValidator = Mockito.mock(ConstraintValidator.class);
applicationServiceFactory = Mockito.mock(ApplicationServiceFactory.class);
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);
PrivilegeManager pm = new PolicyPrivilegeManager(applicationServiceFactory, resourceTypeService, constraintValidator);
pm.initialize("/", 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);
group1 = IdRepoUtils.createGroup("/", GROUP1_NAME);
group1.addMember(user1);
EntitlementSubject es1 = new OpenSSOGroupSubject(group1.getUniversalId());
Privilege privilege = Privilege.getNewInstance();
privilege.setName(PRIVILEGE1_NAME);
privilege.setEntitlement(ent);
privilege.setSubject(es1);
pm.add(privilege);
}
use of com.sun.identity.entitlement.opensso.OpenSSOGroupSubject 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;
}
Aggregations