use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class ComplianceServicesImpl method isAdminGroupsEnabled.
/**
* Method which checks if Admin Groups need to be created for an
* organization.
*
* @param orgDN
* organization dn
* @return true if Admin Groups need to be created
* @exception AMException
* if an error is encountered
*/
public static boolean isAdminGroupsEnabled(String orgDN) throws AMException {
if (!isUnderRootSuffix(orgDN)) {
return false;
}
try {
if (gsc == null) {
ServiceSchemaManager scm = new ServiceSchemaManager(ADMINISTRATION_SERVICE, internalToken);
gsc = scm.getGlobalSchema();
}
Map attrMap = gsc.getReadOnlyAttributeDefaults();
Set values = (Set) attrMap.get(ADMIN_GROUPS_ENABLED_ATTR);
boolean enabled = false;
if (values == null || values.isEmpty()) {
enabled = false;
} else {
String val = (String) values.iterator().next();
enabled = (val.equalsIgnoreCase("true"));
}
if (debug.messageEnabled()) {
debug.message("Compliance.isAdminGroupsEnabled = " + enabled);
}
return enabled;
} catch (SMSException ex) {
debug.error(AMSDKBundle.getString("357"), ex);
throw new AMException(AMSDKBundle.getString("357"), "357");
} catch (SSOException ex) {
debug.error(AMSDKBundle.getString("357"), ex);
throw new AMException(AMSDKBundle.getString("357"), "357");
}
}
use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class CallBackHelper method preProcessModifyMemberShip.
/**
* Special method for pre processing memberShip modification for roles &
* groups.
*/
public Set preProcessModifyMemberShip(SSOToken token, String entryDN, String orgDN, Set members, int operation, int objectType) throws AMException {
Set implSet = getPrePostImpls(orgDN);
if (implSet != null && !implSet.isEmpty()) {
// Post processing impls present
// Iterate through the PrePost-Processing plugins and execute
Iterator itr = implSet.iterator();
while (itr.hasNext()) {
String className = (String) itr.next();
AMCallBack impl = getCallBackObject(className);
if (impl == null) {
continue;
}
try {
switch(operation) {
case DirectoryServicesImpl.ADD_MEMBER:
members = impl.preProcessAddUser(token, entryDN, members, objectType);
break;
case DirectoryServicesImpl.REMOVE_MEMBER:
members = impl.preProcessRemoveUser(token, entryDN, members, objectType);
break;
}
} catch (AMException ae) {
// Exception thrown by the external impl
debug.error("CallBackHelper.preProcessModifyMemberShip():" + " Preprocessing impl " + className + " exception " + "thrown by impl:", ae);
throw ae;
}
}
}
return members;
}
use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class CallBackHelper method postProcess.
// TODO: Remove this. Use the Maps interface only
public void postProcess(SSOToken token, String entryDN, String orgDN, AttrSet oldAttrSet, AttrSet newAttrSet, int operation, int objectType, boolean softDelete) throws AMException {
// Use the external impls instantiated at the time of pre-processing
Set implSet = getPrePostImpls(orgDN);
if ((implSet != null) && (!implSet.isEmpty())) {
Map newAttrMap = CommonUtils.attrSetToMap(newAttrSet);
Map oldAttrMap = CommonUtils.attrSetToMap(oldAttrSet);
// Iterate through the Pre-Processing Impls and execute
Iterator itr = implSet.iterator();
while (itr.hasNext()) {
String className = (String) itr.next();
AMCallBack impl = getCallBackObject(className);
if (impl == null) {
continue;
}
try {
switch(operation) {
case CREATE:
impl.postProcessCreate(token, entryDN, newAttrMap, objectType);
break;
case MODIFY:
impl.postProcessModify(token, entryDN, oldAttrMap, newAttrMap, objectType);
break;
case DELETE:
impl.postProcessDelete(token, entryDN, oldAttrMap, softDelete, objectType);
break;
}
} catch (AMException ae) {
// Exception thrown by the external impl
debug.error("CallBackHelper.postProcess(): Preprocessing" + "impl " + impl.getClass().getName() + " exception thrown: ", ae);
}
}
}
}
use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class RemoteServicesImpl method createEntry.
/**
* Create an entry in the Directory
*
* @param token
* SSOToken
* @param entryName
* name of the entry (naming value), e.g. "sun.com", "manager"
* @param objectType
* Profile Type, ORGANIZATION, AMObject.ROLE, AMObject.USER, etc.
* @param parentDN
* the parent DN
* @param attributes
* the initial attribute set for creation
*/
public void createEntry(SSOToken token, String entryName, int objectType, String parentDN, Map attributes) throws AMEntryExistsException, AMException, SSOException {
try {
String tokenID = token.getTokenID().toString();
Object[] objs = { tokenID, entryName, new Integer(objectType), parentDN, attributes };
client.send(client.encodeMessage("createEntry", objs), sessionCookies.getLBCookie(tokenID), null);
} catch (AMRemoteException amrex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.createEntry: entryName=" + entryName + "; AMRemoteException caught exception=", amrex);
}
throw convertException(amrex);
} catch (SSOException ssoe) {
throw ssoe;
} catch (RemoteException rex) {
getDebug().error("RemoteServicesImpl.createEntry: caught " + "exception=", rex);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (Exception ex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.createEntry: entryName=" + entryName + "; caught exception=", ex);
}
throw new AMException(AMSDKBundle.getString("1000"), "1000");
}
}
use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class RemoteServicesImpl method verifyAndGetOrgDN.
/**
* Gets the Organization DN for the specified entryDN. If the entry itself
* is an org, then same DN is returned.
*
* @param token
* a valid SSOToken
* @param entryDN
* the entry whose parent Organization is to be obtained
* @param childDN
* the immediate entry whose parent Organization is to be
* obtained
* @return the DN String of the parent Organization
* @throws AMException
* if an error occured while obtaining the parent Organization
*/
public String verifyAndGetOrgDN(SSOToken token, String entryDN, String childDN) throws AMException {
try {
String tokenID = token.getTokenID().toString();
Object[] objs = { tokenID, entryDN, childDN };
return ((String) client.send(client.encodeMessage("verifyAndGetOrgDN", objs), sessionCookies.getLBCookie(tokenID), null));
} catch (AMRemoteException amrex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.verifyAndGetOrgDN: entryDN=" + entryDN + "; AMRemoteException caught exception=", amrex);
}
throw convertException(amrex);
} catch (RemoteException rex) {
getDebug().error("RemoteServicesImpl.verifyAndGetOrgDN: caught exception=", rex);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (SSOException ssoe) {
getDebug().error("RemoteServicesImpl.verifyAndGetOrgDN: caught " + "SSOException=", ssoe);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (Exception ex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.verifyAndGetOrgDN: entryDN=" + entryDN + "; caught exception=", ex);
}
throw new AMException(AMSDKBundle.getString("1000"), "1000");
}
}
Aggregations