use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class RemoteServicesImpl method getAMTemplateDN.
/**
* Get the AMTemplate DN (COSTemplateDN)
*
* @param token
* SSOToken
* @param entryDN
* DN of the profile whose template is to be set
* @param serviceName
* Service Name
* @param type
* the template type, AMTemplate.DYNAMIC_TEMPLATE
* @return String DN of the AMTemplate
*/
public String getAMTemplateDN(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) };
return ((String) client.send(client.encodeMessage("getAMTemplateDN", objs), sessionCookies.getLBCookie(tokenID), null));
} catch (AMRemoteException amrex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.getAMTemplateDN : entryDN=" + entryDN + "; AMRemoteException caught exception=", amrex);
}
throw convertException(amrex);
} catch (RemoteException rex) {
getDebug().error("RemoteServicesImpl.getAMTemplateDN: caught exception=", rex);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (Exception ex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.getAMTemplateDN : 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 search.
/**
* Search the Directory
*
* @param token
* SSOToken
* @param entryDN
* DN of the entry to start the search with
* @param searchFilter
* search filter
* @param searchControl
* search control defining the VLV indexes and search scope
* @param attrNames
* attributes name
* @return Set of matching DNs
*/
public AMSearchResults search(SSOToken token, String entryDN, String searchFilter, SearchControl searchControl, String[] attrNames) throws AMException {
try {
SortKey[] keys = searchControl.getSortKeys();
LinkedList sortKeys = new LinkedList();
for (int i = 0; (keys != null) && (i < keys.length); i++) {
if (keys[i].reverse) {
sortKeys.add("true:" + keys[i].attributeName);
} else {
// Using "fals" instead of "false" so that it
// has 4 characters as "true", hence easy to
// reconstruct SortKey
sortKeys.add("fals:" + keys[i].attributeName);
}
}
int[] vlvRange = searchControl.getVLVRange();
if (vlvRange == null) {
vlvRange = new int[3];
}
Set attrNamesSet = MiscUtils.stringArrayToSet(attrNames);
String tokenID = token.getTokenID().toString();
Object[] objs = { tokenID, entryDN, searchFilter, sortKeys, new Integer(vlvRange[0]), new Integer(vlvRange[1]), new Integer(vlvRange[2]), searchControl.getVLVJumpTo(), new Integer(searchControl.getTimeOut()), new Integer(searchControl.getMaxResults()), new Integer(searchControl.getSearchScope()), Boolean.valueOf(searchControl.isGetAllReturnAttributesEnabled()), attrNamesSet };
Map results = (Map) client.send(client.encodeMessage("search3", objs), sessionCookies.getLBCookie(tokenID), null);
String cString = (String) results.remove(AMSR_COUNT);
Set dns = (Set) results.remove(AMSR_RESULTS);
String eString = (String) results.remove(AMSR_CODE);
int count = 0, errorCode = 0;
try {
count = Integer.parseInt(cString);
errorCode = Integer.parseInt(eString);
} catch (NumberFormatException nfe) {
getDebug().error("RemoteServicesImpl.search: caught number " + "format error", nfe);
}
return (new AMSearchResults(count, dns, errorCode, results));
} catch (AMRemoteException amrex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.search2 : entryDN" + entryDN + "; AMRemoteException caught exception=", amrex);
}
throw convertException(amrex);
} catch (RemoteException rex) {
getDebug().error("RemoteServicesImpl.search: caught exception=", rex);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (Exception ex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.search2 : 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 changePassword.
/**
* Changes user password.
*
* @param token Single sign on token
* @param entryDN DN of the profile whose template is to be set
* @param attrName password attribute name
* @param oldPassword old password
* @param newPassword new password
* @throws AMException if an error occurs when changing user password
* @throws SSOException If user's single sign on token is invalid.
*/
public void changePassword(SSOToken token, String entryDN, String attrName, String oldPassword, String newPassword) throws AMException, SSOException {
try {
String tokenID = token.getTokenID().toString();
Object[] objs = { tokenID, entryDN, attrName, oldPassword, newPassword };
client.send(client.encodeMessage("changePassword", objs), sessionCookies.getLBCookie(tokenID), null);
} catch (AMRemoteException amrex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.changePassword : entryDN" + entryDN + "; AMRemoteException caught exception=", amrex);
}
throw convertException(amrex);
} catch (RemoteException rex) {
getDebug().error("RemoteServicesImpl.changePassword: caught exception=", rex);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (SSOException ssoe) {
getDebug().error("RemoteServicesImpl.changePassword: caught SSOException=", ssoe);
throw ssoe;
} catch (Exception ex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.changePassword : 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 getExternalAttributes.
/**
* Returns attributes from an external data store.
*
* @param token
* Single sign on token of user
* @param entryDN
* DN of the entry user is trying to read
* @param attrNames
* Set of attributes to be read
* @param profileType
* Integer determining the type of profile being read
* @return A Map of attribute-value pairs
* @throws AMException
* if an error occurs when trying to read external datastore
*/
public Map getExternalAttributes(SSOToken token, String entryDN, Set attrNames, int profileType) throws AMException {
try {
String tokenID = token.getTokenID().toString();
Object[] objs = { tokenID, entryDN, attrNames, new Integer(profileType) };
return ((Map) client.send(client.encodeMessage("getExternalAttributes", objs), sessionCookies.getLBCookie(tokenID), null));
} catch (AMRemoteException amrex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.getExternalAttributes: entryDN=" + entryDN + "; AMRemoteException caught exception=", amrex);
}
throw convertException(amrex);
} catch (RemoteException rex) {
getDebug().error("RemoteServicesImpl.getExternalAttributes: caught " + "exception=", rex);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (Exception ex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.getExternalAttributes: 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 removeAdminRole.
/**
* Remove group admin role
*
* @param token
* SSOToken of the caller
* @param dn
* group DN
* @param recursive
* true to delete all admin roles for all sub groups or sub
* people container
*/
public void removeAdminRole(SSOToken token, String dn, boolean recursive) throws SSOException, AMException {
try {
String tokenID = token.getTokenID().toString();
Object[] objs = { tokenID, dn, Boolean.valueOf(recursive) };
client.send(client.encodeMessage("removeAdminRole", objs), sessionCookies.getLBCookie(tokenID), null);
} catch (AMRemoteException amrex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.removeAdminRole: dn=" + dn + "; AMRemoteException caught exception=", amrex);
}
throw convertException(amrex);
} catch (RemoteException rex) {
getDebug().error("RemoteServicesImpl.removeAdminRole: caught exception=", rex);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (SSOException ssoe) {
getDebug().error("RemoteServicesImpl.removeAdminRole: caught SSOException=", ssoe);
throw ssoe;
} catch (Exception ex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.removeAdminRole: dn=" + dn + "; caught exception=", ex);
}
throw new AMException(AMSDKBundle.getString("1000"), "1000");
}
}
Aggregations