use of com.sun.identity.entitlement.EntitlementException in project OpenAM by OpenRock.
the class PolicyV1Filter method filterCreate.
/**
* The policy json will not have any resource type defined. Create retrieves the policy's associated application
* and uses the applications associated resource type for the policy.
*
* @param context
* the filter chain context
* @param request
* the create request
* @param next
* a request handler representing the remainder of the filter chain
*/
@Override
public Promise<ResourceResponse, ResourceException> filterCreate(Context context, CreateRequest request, RequestHandler next) {
try {
final JsonValue jsonValue = request.getContent();
final Subject callingSubject = contextHelper.getSubject(context);
final String realm = contextHelper.getRealm(context);
retrieveResourceType(jsonValue, callingSubject, realm);
} catch (EntitlementException eE) {
debug.error("Error filtering policy create CREST request", eE);
return resourceErrorHandler.handleError(context, request, eE).asPromise();
} catch (ResourceException rE) {
debug.error("Error filtering policy create CREST request", rE);
return rE.asPromise();
}
return transform(next.handleCreate(context, request));
}
use of com.sun.identity.entitlement.EntitlementException in project OpenAM by OpenRock.
the class UpgradeEntitlementSubConfigsStep method addMissingApplicationTypes.
/**
* Add missing application types.
*
* @throws UpgradeException
* should the process of creating new application types fail
*/
private void addMissingApplicationTypes() throws UpgradeException {
for (final Node typeNode : missingApplicationTypes) {
final Map<String, Set<String>> keyValueMap = parseAttributeValuePairTags(typeNode);
final String name = getNodeAttributeValue(typeNode, NAME);
UpgradeProgress.reportStart(AUDIT_NEW_TYPE_START, name);
keyValueMap.put(NAME, Collections.singleton(name));
try {
DEBUG.message("Saving new entitlement application type: " + name);
entitlementService.storeApplicationType(createApplicationType(name, keyValueMap));
UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
} catch (EntitlementException eE) {
UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
throw new UpgradeException(eE);
} catch (InstantiationException ie) {
UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
throw new UpgradeException(ie);
} catch (IllegalAccessException iae) {
UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
throw new UpgradeException(iae);
}
}
}
use of com.sun.identity.entitlement.EntitlementException in project OpenAM by OpenRock.
the class UpgradeEntitlementSubConfigsStep method addMissingActions.
/**
* Adds the missing actions to their corresponding application type's.
*
* @throws UpgradeException If there was an error while updating the application type.
*/
private void addMissingActions() throws UpgradeException {
for (final Map.Entry<String, Map<String, Boolean>> entry : missingActions.entrySet()) {
final String name = entry.getKey();
final Map<String, Boolean> actions = entry.getValue();
try {
UpgradeProgress.reportStart(AUDIT_MODIFIED_TYPE_START, name);
if (DEBUG.messageEnabled()) {
DEBUG.message("Modifying application type " + name + " ; adding actions: " + actions);
}
final ApplicationType type = getType(name);
type.getActions().putAll(actions);
entitlementService.storeApplicationType(type);
UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
} catch (EntitlementException ee) {
UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
throw new UpgradeException(ee);
}
}
}
use of com.sun.identity.entitlement.EntitlementException in project OpenAM by OpenRock.
the class UpgradeEntitlementSubConfigsStep method addChangedSubjects.
/**
* Clears the subjects currently associated with an application, then replaces them with
* the new set of conditions defined.
*
* @throws UpgradeException If there was an error while updating the application.
*/
private void addChangedSubjects() throws UpgradeException {
for (final Map.Entry<String, Set<String>> entry : changedSubjects.entrySet()) {
final String name = entry.getKey();
final Set<String> subjects = entry.getValue();
try {
UpgradeProgress.reportStart(AUDIT_MODIFIED_SUB_START, name);
if (DEBUG.messageEnabled()) {
DEBUG.message("Modifying application " + name + " ; adding subjects: " + subjects);
}
final Application application = getApplication(name);
application.setSubjects(subjects);
entitlementService.storeApplication(application);
UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
} catch (EntitlementException ee) {
UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
throw new UpgradeException(ee);
}
}
}
use of com.sun.identity.entitlement.EntitlementException in project OpenAM by OpenRock.
the class DataStore method searchPrivileges.
private Set<IPrivilege> searchPrivileges(String realm, BufferedIterator iterator, ResourceSearchIndexes indexes, Set<String> subjectIndexes, boolean bSubTree, Set<String> excludeDNs) throws EntitlementException {
Set<IPrivilege> results = new HashSet<IPrivilege>();
String filter = getFilter(indexes, subjectIndexes, bSubTree);
String baseDN = getSearchBaseDN(realm, null);
if (PolicyConstants.DEBUG.messageEnabled()) {
PolicyConstants.DEBUG.message("[PolicyEval] DataStore.searchPrivileges");
PolicyConstants.DEBUG.message("[PolicyEval] search filter: " + filter);
PolicyConstants.DEBUG.message("[PolicyEval] search DN: " + baseDN);
}
if (filter != null) {
SSOToken token = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
long start = DB_MONITOR_PRIVILEGE.start();
if (SMSEntry.checkIfEntryExists(baseDN, token)) {
try {
Iterator i = SMSEntry.search(token, baseDN, filter, NO_LIMIT, NO_LIMIT, NOT_SORTED, NOT_SORTED, excludeDNs);
while (i.hasNext()) {
SMSDataEntry e = (SMSDataEntry) i.next();
Privilege privilege = Privilege.getInstance(new JSONObject(e.getAttributeValue(SERIALIZABLE_INDEX_KEY)));
iterator.add(privilege);
results.add(privilege);
}
} catch (JSONException e) {
Object[] arg = { baseDN };
throw new EntitlementException(52, arg, e);
} catch (SMSException e) {
Object[] arg = { baseDN };
throw new EntitlementException(52, arg, e);
}
}
DB_MONITOR_PRIVILEGE.end(start);
}
return results;
}
Aggregations