use of com.sun.identity.entitlement.SubjectAttributesManager in project OpenAM by OpenRock.
the class OpenSSOGroupSubject method getSearchIndexAttributes.
/**
* Returns search index attributes.
*
* @return search index attributes.
*/
@Override
public Map<String, Set<String>> getSearchIndexAttributes() {
SubjectAttributesManager sam = getSubjectAttributesManager();
if (sam != null) {
Map<String, Set<String>> map = new HashMap<String, Set<String>>(4);
if (sam.isGroupMembershipSearchIndexEnabled()) {
Set<String> set = new HashSet<String>();
String uuid = getID();
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
try {
AMIdentity amid = IdUtils.getIdentity(adminToken, uuid);
set.add(OpenSSOSubjectAttributesCollector.getIDWithoutOrgName(amid));
} catch (IdRepoException ex) {
if (PrivilegeManager.debug.messageEnabled()) {
PrivilegeManager.debug.message("OpenSSOGroupSubject.getSearchIndexAttributes", ex);
}
set.add(uuid);
}
map.put(SubjectAttributesCollector.NAMESPACE_MEMBERSHIP + IdType.GROUP.getName(), set);
} else {
Set<String> set = new HashSet<String>();
set.add(SubjectAttributesCollector.ATTR_NAME_ALL_ENTITIES);
map.put(SubjectAttributesCollector.NAMESPACE_IDENTITY, set);
}
return map;
} else {
return super.getSearchIndexAttributes();
}
}
use of com.sun.identity.entitlement.SubjectAttributesManager in project OpenAM by OpenRock.
the class SubjectAttributesResourceV1 method queryCollection.
@Override
public Promise<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request, QueryResourceHandler handler) {
final Subject mySubject = getContextSubject(context);
if (mySubject == null) {
debug.error("SubjectAttributesResource :: QUERY : Unknown Subject");
return new BadRequestException().asPromise();
}
final String principalName = PrincipalRestUtils.getPrincipalNameFromSubject(mySubject);
final SubjectAttributesManager manager = getSubjectAttributesManager(mySubject, getRealm(context));
final Set<String> attributes;
try {
attributes = manager.getAvailableSubjectAttributeNames();
} catch (EntitlementException e) {
debug.error("SubjectAttributesResource :: QUERY by " + principalName + " : Unable to query available " + "subject attribute names.");
return new InternalServerErrorException().asPromise();
}
for (String attr : attributes) {
handler.handleResource(newResourceResponse(attr, Long.toString(System.currentTimeMillis()), JsonValue.json(attr)));
}
return newResultPromise(newQueryResponse(null, CountPolicy.EXACT, 0));
}
use of com.sun.identity.entitlement.SubjectAttributesManager in project OpenAM by OpenRock.
the class OpenSSOGroupSubject method getRequiredAttributeNames.
/**
* Returns required attribute names.
*
* @return required attribute names.
*/
@Override
public Set<String> getRequiredAttributeNames() {
SubjectAttributesManager sam = getSubjectAttributesManager();
if (sam != null) {
if (sam.isGroupMembershipSearchIndexEnabled()) {
Set<String> set = new HashSet<String>(2);
set.add(SubjectAttributesCollector.NAMESPACE_MEMBERSHIP + IdType.GROUP.getName());
return set;
} else {
return (Collections.EMPTY_SET);
}
} else {
return super.getRequiredAttributeNames();
}
}
use of com.sun.identity.entitlement.SubjectAttributesManager in project OpenAM by OpenRock.
the class OpenSSOApplicationPrivilegeManager method getPrivileges.
private void getPrivileges() throws EntitlementException {
Set<String> hostIndex = new HashSet<String>();
hostIndex.add("://" + DNMapper.orgNameToDN(realm));
Set<String> pathParentIndex = new HashSet<String>();
pathParentIndex.add(RESOURCE_PREFIX);
ResourceSearchIndexes rIndex = new ResourceSearchIndexes(hostIndex, null, pathParentIndex);
SubjectAttributesManager sam = SubjectAttributesManager.getInstance(dsameUserSubject);
Set<String> subjectIndex = (bPolicyAdmin) ? Collections.EMPTY_SET : sam.getSubjectSearchFilter(caller, APPL_NAME);
OpenSSOIndexStore db = new OpenSSOIndexStore(dsameUserSubject, getHiddenRealmDN());
Iterator<IPrivilege> results = db.search("/", rIndex, subjectIndex, true, false);
while (results.hasNext()) {
Privilege p = (Privilege) results.next();
if (bPolicyAdmin || doesSubjectMatch(p, resourcePrefix)) {
delegatables.evaluate(p);
modifiables.evaluate(p);
readables.evaluate(p);
}
}
}
use of com.sun.identity.entitlement.SubjectAttributesManager in project OpenAM by OpenRock.
the class OpenSSOApplicationPrivilegeManager method doesSubjectMatch.
private boolean doesSubjectMatch(Privilege privilege, String resourceName) throws EntitlementException {
SubjectAttributesManager mgr = SubjectAttributesManager.getInstance(dsameUserSubject, realm);
SubjectDecision sDecision = privilege.getSubject().evaluate(realm, mgr, caller, resourceName, Collections.EMPTY_MAP);
return sDecision.isSatisfied();
}
Aggregations