use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class ComplianceServicesImpl method verifyAndLinkRoleToGroup.
/**
* Method which verifies if the <code>roleDN</code> corresponds to an
* admin role. If true the <code>memberOf</code> and
* <code>adminRole</code> attributes of each member/user are set to the
* corresponding administration <code>groupDN</code> and administration
* <code>groupRDN</code> respectively. Each of the members/users are also
* added to the corresponding admin group.
*
* @param token
* single sign on token.
* @param membersGuid
* Guid array of members to be operated on.
* @param roleDN
* distinguished name of the role.
*
* @exception AMException
* if unsuccessful in adding the members to the corresponding
* admin group. As a result of which the memberOf and
* adminRole attributes are also not updated.
*/
protected void verifyAndLinkRoleToGroup(SSOToken token, Guid[] membersGuid, String roleDN) throws AMException {
// Obtain the group corresponding to roleDN
DN dn = DN.valueOf(roleDN);
String groupName = getGroupFromRoleDN(dn);
if (groupName != null) {
// roleDN corresponds to an admin role
String orgDN = dn.parent().toString();
String groupDN = NamingAttributeManager.getNamingAttribute(AMObject.GROUP) + "=" + groupName + ",ou=Groups," + orgDN;
String groupRDN = NamingAttributeManager.getNamingAttribute(AMObject.GROUP) + "=" + groupName;
try {
// Add the members to corresponding group.
AssignableDynamicGroup group = (AssignableDynamicGroup) UMSObject.getObject(token, new Guid(groupDN));
group.addMembers(membersGuid);
Attr[] attrs = new Attr[1];
attrs[0] = new Attr("adminrole", groupRDN);
AttrSet attrSet = new AttrSet(attrs);
int numMembers = membersGuid.length;
for (int i = 0; i < numMembers; i++) {
addAttributesToEntry(token, membersGuid[i].getDn(), attrSet);
}
} catch (EntryNotFoundException ex) {
debug.error("Compliance.verifyAndLinkRoleToGroup: " + "Admin groups are missing");
} catch (UMSException ue) {
debug.error("Compliance." + "verifyAndLinkRoleToGroup(): ", ue);
throw new AMException(AMSDKBundle.getString("771"), "771");
}
}
}
use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class ComplianceServicesImpl method isComplianceUserDeletionEnabled.
/**
* Method which checks if Compliance User Deletion is enabled
*
* @return true if Compliance User Deletion is enabled
* @exception AMException
* if an error is encountered
*/
public static boolean isComplianceUserDeletionEnabled() throws AMException {
try {
if (gsc == null) {
ServiceSchemaManager scm = new ServiceSchemaManager(ADMINISTRATION_SERVICE, internalToken);
gsc = scm.getGlobalSchema();
}
Map attrMap = gsc.getReadOnlyAttributeDefaults();
Set values = (Set) attrMap.get(COMPLIANCE_USER_DELETION_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.isComplianceUserDeletionEnabled = " + enabled);
}
return enabled;
} catch (SMSException ex) {
debug.error(AMSDKBundle.getString("359"), ex);
throw new AMException(AMSDKBundle.getString("359"), "359");
} catch (SSOException ex) {
debug.error(AMSDKBundle.getString("359"), ex);
throw new AMException(AMSDKBundle.getString("359"), "359");
}
}
use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class RemoteServicesImpl method unRegisterService.
/**
* Un register service for a AMro profile.
*
* @param token
* SSOToken
* @param entryDN
* DN of the profile whose service is to be removed
* @param objectType
* profile type
* @param serviceName
* Service Name
* @param type
* Template type
*/
public void unRegisterService(SSOToken token, String entryDN, int objectType, String serviceName, int type) throws AMException {
try {
String tokenID = token.getTokenID().toString();
Object[] objs = { tokenID, entryDN, new Integer(objectType), serviceName, new Integer(type) };
client.send(client.encodeMessage("unRegisterService", objs), sessionCookies.getLBCookie(tokenID), null);
} catch (AMRemoteException amrex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.unRegisterService : entryDN=" + entryDN + "; AMRemoteException caught exception=", amrex);
}
throw convertException(amrex);
} catch (RemoteException rex) {
getDebug().error("RemoteServicesImpl.unRegisterService: caught exception=", rex);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (Exception ex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.unRegisterService : entryDN=" + entryDN + "; 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 getGroupFilterAndScope.
/**
* Returns an array containing the dynamic group's scope, base dn, and
* filter.
*/
public String[] getGroupFilterAndScope(SSOToken token, String entryDN, int profileType) throws SSOException, AMException {
try {
String tokenID = token.getTokenID().toString();
Object[] objs = { tokenID, entryDN, new Integer(profileType) };
LinkedList list = (LinkedList) client.send(client.encodeMessage("getGroupFilterAndScope", objs), sessionCookies.getLBCookie(tokenID), null);
String[] array = new String[list.size()];
list.toArray(array);
return array;
} catch (AMRemoteException amrex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.getGroupFilterAndScope : entryDN" + entryDN + "; AMRemoteException caught exception=", amrex);
}
throw convertException(amrex);
} catch (RemoteException rex) {
getDebug().error("RemoteServicesImpl.getGroupFilterAndScope: " + "caught exception=", rex);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (SSOException ssoe) {
getDebug().error("RemoteServicesImpl.getGroupFilterAndScope: caught " + "SSOException=", ssoe);
throw ssoe;
} catch (Exception ex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.getGroupFilterAndScope : entryDN=" + entryDN + "; 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 getAttributes.
/**
* Gets all attributes corresponding to the entryDN. This method obtains the
* DC Tree node attributes and also performs compliance related verification
* checks in compliance mode. Note: In compliance mode you can skip the
* compliance checks by setting ignoreCompliance to "false".
*
* @param token
* a valid SSOToken
* @param entryDN
* the DN of the entry whose attributes need to retrieved
* @param ignoreCompliance
* a boolean value specificying if compliance related entries
* need to ignored or not. Ignored if true.
* @return a Map containing attribute names as keys and Set of values
* corresponding to each key.
* @throws AMException
* if an error is encountered in fetching the attributes
*/
public Map getAttributes(SSOToken token, String entryDN, boolean ignoreCompliance, boolean byteValues, int profileType) throws AMException, SSOException {
try {
String tokenID = token.getTokenID().toString();
Object[] objs = { tokenID, entryDN, Boolean.valueOf(ignoreCompliance), Boolean.valueOf(byteValues), new Integer(profileType) };
Map map = (Map) client.send(client.encodeMessage("getAttributes3", objs), sessionCookies.getLBCookie(tokenID), null);
AMHashMap res = new AMHashMap();
res.copy(map);
return res;
} catch (AMRemoteException amrex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.getAttributes 3: entryDN=" + entryDN + "; AMRemoteException caught exception=", amrex);
}
throw convertException(amrex);
} catch (RemoteException rex) {
getDebug().error("RemoteServicesImpl.getAttributes: caught exception=", rex);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (SSOException ssoe) {
getDebug().error("RemoteServicesImpl.getAttributes: caught SSOException=", ssoe);
throw ssoe;
} catch (Exception ex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.getAttributes3: entryDN=" + entryDN + "; caught exception=", ex);
}
throw new AMException(AMSDKBundle.getString("1000"), "1000");
}
}
Aggregations