use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.
the class PolicyManager method removePolicy.
/**
* Deletes a policy in the organization with the given name.
*
* @param policyName name of the policy to be deleted
*
* @throws SSOException invalid or expired single-sign-on token
* @throws NoPermissionException user does not have sufficient
* privileges to remove policies
* @throws PolicyException for any other abnormal condition
*
* @supported.api
*/
public void removePolicy(String policyName) throws SSOException, NoPermissionException, PolicyException {
// Check if name is valid
if (policyName == null) {
if (debug.warningEnabled()) {
debug.warning("In PolicyManager::removePolicy(), name is null");
}
throw (new InvalidNameException(ResBundleUtils.rbName, "null_name", null, "null", PolicyException.POLICY));
}
try {
// Get service config for named policy node
ServiceConfig oConfig = scm.getOrganizationConfig(org, null);
ServiceConfig namedPolicy = (oConfig == null) ? null : oConfig.getSubConfig(NAMED_POLICY);
if (namedPolicy != null) {
/* Remove the named policy
* before removing the named policy
* prepare for changes in resources tree
*/
Policy policy = getPolicy(policyName);
// do the removal of policy
namedPolicy.removeSubConfig(policyName);
if (policy != null) {
if (isMigratedToEntitlementService()) {
// should use super admin token to remove the index store
// entry
PrivilegeIndexStore pis = PrivilegeIndexStore.getInstance(SubjectUtils.createSuperAdminSubject(), getOrganizationDN());
if (policy.isReferralPolicy()) {
pis.deleteReferral((policyName));
} else {
pis.delete(PrivilegeUtils.policyToPrivileges(policy));
}
policyCache.sendPolicyChangeNotification(null, policy, ServiceListener.REMOVED);
} else {
// do the removal in resources tree
rim.removePolicyFromResourceTree(svtm, token, policy);
}
}
}
} catch (EntitlementException e) {
debug.error("Error while removing policy : " + e.getMessage());
} catch (ServiceNotFoundException snfe) {
debug.error("Error while removing policy : " + snfe.getMessage());
} catch (SMSException smse) {
String[] objs = { policyName, org };
if (PolicyUtils.logStatus) {
PolicyUtils.logErrorMessage("UNABLE_TO_REMOVE_POLICY", objs, token);
}
debug.error("SMS error in deleting policy: " + policyName + " for org: " + org, smse);
// Check for permission exception
if (smse.getExceptionCode() == SMSException.STATUS_NO_PERMISSION) {
throw (new NoPermissionException(ResBundleUtils.rbName, "insufficient_access_rights", null));
} else {
// Throw generic policy exception
throw (new PolicyException(ResBundleUtils.rbName, "unable_to_remove_policy", objs, smse));
}
}
String[] objs = { policyName, org };
if (PolicyUtils.logStatus) {
PolicyUtils.logAccessMessage("POLICY_REMOVE_SUCCESS", objs, token);
}
}
use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.
the class AMServiceUtils method createOrgConfig.
/**
* Create Service Template for a AMro profile, could be used to set policy
* to a profile
*
* @param token
* SSOToken
* @param orgDN
* DN of the org or org unit
* @param serviceName
* Service Name
* @param avPair
* attributes to be set
* @return String DN of the newly created template
*/
protected static ServiceConfig createOrgConfig(SSOToken token, String orgDN, String serviceName, Map avPair) throws SSOException, AMException {
try {
ServiceConfigManager scm = new ServiceConfigManager(serviceName, token);
ServiceConfig sc = scm.createOrganizationConfig(orgDN, avPair);
return sc;
} catch (ServiceNotFoundException ex) {
Object[] args = { serviceName };
String locale = AMCommonUtils.getUserLocale(token);
throw new AMException(AMSDKBundle.getString("481", args, locale), "481", args);
} catch (ServiceAlreadyExistsException ex) {
Object[] args = { serviceName };
String locale = AMCommonUtils.getUserLocale(token);
throw new AMException(AMSDKBundle.getString("479", args, locale), "479", args);
} catch (SMSException ex) {
Object[] args = { serviceName };
String locale = AMCommonUtils.getUserLocale(token);
throw new AMException(AMSDKBundle.getString("482", args, locale), "482", args);
}
}
use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.
the class AMServiceUtils method serviceHasSubSchema.
/**
* Returns true if the service has the subSchema. False otherwise.
*
* @param token
* SSOToken a valid SSOToken
* @param serviceName
* the service name
* @param schemaType
* service schema type (Dynamic, Policy etc)
* @return true if the service has the subSchema.
*/
public static boolean serviceHasSubSchema(SSOToken token, String serviceName, SchemaType schemaType) throws SMSException, SSOException {
boolean schemaTypeFlg = false;
try {
ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, token);
Set types = ssm.getSchemaTypes();
if (debug.messageEnabled()) {
debug.message("AMServiceUtils.serviceHasSubSchema() " + "SchemaTypes types for " + serviceName + " are: " + types);
}
schemaTypeFlg = types.contains(schemaType);
} catch (ServiceNotFoundException ex) {
if (debug.warningEnabled()) {
debug.warning("AMServiceUtils.serviceHasSubSchema() " + "Service does not exist : " + serviceName);
}
}
return (schemaTypeFlg);
}
use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.
the class AMAuthLevelManager method addServiceListener.
private ListenerMapEntry addServiceListener(String service) throws SMSException, SSOException {
if (debug.messageEnabled()) {
debug.message("addServiceListener for " + service);
}
// add Service Schema Listener
ServiceSchemaManager ssm = null;
try {
ssm = new ServiceSchemaManager(service, AuthD.getAuth().getSSOAuthSession());
} catch (ServiceNotFoundException e) {
// module does not define any xml file
return null;
}
String schemaListenerId = ssm.addListener(this);
// add Service Config Manager
ServiceConfigManager scm = null;
try {
scm = new ServiceConfigManager(service, AuthD.getAuth().getSSOAuthSession());
} catch (ServiceNotFoundException e) {
// module does not define any xml file
return null;
}
String configListenerId = scm.addListener(this);
return new ListenerMapEntry(ssm, schemaListenerId, scm, configListenerId);
}
Aggregations