use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class RemoteServicesImpl method getAttributesByteValues.
public Map getAttributesByteValues(SSOToken token, String entryDN, int profileType) throws AMException, SSOException {
try {
String tokenID = token.getTokenID().toString();
Object[] objs = { tokenID, entryDN, new Integer(profileType) };
return ((Map) client.send(client.encodeMessage("getAttributesByteValues1", objs), sessionCookies.getLBCookie(tokenID), null));
} catch (AMRemoteException amrex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.getAttributesByteValues: entryDN=" + entryDN + "; AMRemoteException caught exception=", amrex);
}
throw convertException(amrex);
} catch (RemoteException rex) {
getDebug().error("RemoteServicesImpl.getAttributesByteValues: " + "caught exception=", rex);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (SSOException ssoe) {
getDebug().error("RemoteServicesImpl.getAttributesByteValues: caught " + "SSOException=", ssoe);
throw ssoe;
} catch (Exception ex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.getAttributesByteValues: 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 AdminInterfaceUtils method inOrganizationalUnit.
/**
* Returns true if an object is a descendent of an organizational unit.
*
* @param debug
* instance
* @param storeConn
* Store Connection object.
* @param obj
* <code>AMObject</code> to be inspected.
* @return true if <code>obj</code> is a descendent of an organizational
* unit.
*/
public static boolean inOrganizationalUnit(Debug debug, AMStoreConnection storeConn, AMObject obj) {
boolean inOrgUnit = false;
String parentDN = obj.getParentDN();
try {
while ((parentDN != null) && !inOrgUnit) {
if (storeConn.getAMObjectType(parentDN) == AMObject.ORGANIZATIONAL_UNIT) {
inOrgUnit = true;
} else {
AMObject parent = getAMObject(debug, parentDN, storeConn);
parentDN = (parent != null) ? parent.getParentDN() : null;
}
}
} catch (SSOException ssoe) {
debug.warning("AdminInterfaceUtils.inOrganizationalUnit", ssoe);
} catch (AMException ame) {
debug.warning("AdminInterfaceUtils.inOrganizationalUnit", ame);
}
return inOrgUnit;
}
use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class AMUserPasswordValidationPlugin method validateUserID.
/**
* Checks for invalid characters in the source string
*
* @param userID
* source string which should be validated
* @param envParams
* parameters for which the userID validation is enforced.
* @throws throws
* AMException when it detects specified pattern within source
* string which need to be validated OR if source string is null
*/
public void validateUserID(String userID, Map envParams) throws AMException {
StringBuilder errorString = new StringBuilder(10);
SSOToken token = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
String orgDN = (String) envParams.get(com.sun.identity.shared.Constants.ORGANIZATION_NAME);
String regEx = getOrgUserInvalidChars(orgDN, token);
if (userID == null || userID.length() == 0) {
debug.error("AMUserPasswordValidationPlugin." + "validateUserID() : Source string is null or empty" + userID);
throw new AMInvalidDNException(AMSDKBundle.getString("157"), "157");
}
if (regEx == null || regEx.length() == 0) {
debug.error("AMUserPasswordValidationPlugin." + "validateUserID() : List of invalid characters is null " + "or empty" + regEx);
throw new AMInvalidDNException(AMSDKBundle.getString("157"), "157");
}
StringTokenizer st = new StringTokenizer(regEx, SEPERATOR);
while (st.hasMoreTokens()) {
String obj = st.nextToken();
if (userID.indexOf(obj) > -1) {
debug.error("AMUserPasswordValidationPlugin." + "validateUserID() : Detected invalid chars ...");
debug.error("AMUserPasswordValidationPlugin." + "validateUserID() : User Name validation Failed:" + obj);
errorString.append(obj).append(" ");
}
}
Object[] args = { userID, errorString.toString() };
if (errorString.length() != 0) {
throw new AMException(AMSDKBundle.getString("1002", args), "1002", args);
}
}
use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class EntityObjectImpl method modifyEntity.
/**
* Sets or replaces attribute values with the new values supplied and Stores
* the changes to directory server.
*
* @param ssoToken User's Single Sign Token.
* @param entityName Name of this entity. example
* <code>cn=websphereAgent</code>
* @param entityType Type of entity being created. eg. Agent The types
* supported by SDK are configured in the list of Managed Objects
* in the <code>DAI</code> service.
* @param entityLocation Location of the entity creation. example
* <code>www.abc.com</code>.
* @throws EntityException if there is an internal error in the AM Store.
* @throws SSOException if the sign on is no longer valid.
* @throws RemoteException
*/
public void modifyEntity(String ssoToken, String entityName, String entityType, String entityLocation, Map attributes) throws EntityException, SSOException, RemoteException {
initializeObject(ssoToken, entityLocation);
AMEntity amEntity = getAMEntity(ssoToken, entityName, entityType, entityLocation);
try {
if (amEntity != null) {
amEntity.setAttributes(attributes);
amEntity.store();
}
} catch (AMException amex) {
EntityUtils.debug.error("EntityObjectImpl.modifyEntity() : " + "Modify Entity Failed. " + amex);
throw EntityUtils.convertException(amex);
}
}
use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class EntityObjectImpl method getEntityDN.
/**
* Method to get the DN of the entity based on the search results for the
* entityName from the entityLocation.
*/
private String getEntityDN(String entityName, int entityType, String entityLocation) throws EntityException, SSOException {
String entDN = null;
try {
Set entityResults = entity.searchEntities(entityType, "*", AMConstants.SCOPE_SUB, new HashMap());
Iterator iter = entityResults.iterator();
while (iter.hasNext()) {
entDN = (String) iter.next();
if (entDN.indexOf(entityName) >= 0) {
break;
}
}
} catch (AMException amex) {
EntityUtils.debug.error("EntityObjectImpl.getEntityDN() : " + "Unable to get DN for the Entity " + amex);
throw EntityUtils.convertException(amex);
}
return entDN;
}
Aggregations