Search in sources :

Example 81 with AMException

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");
    }
}
Also used : AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException) RemoteException(java.rmi.RemoteException) AMEntryExistsException(com.iplanet.am.sdk.AMEntryExistsException) AMEventManagerException(com.iplanet.am.sdk.AMEventManagerException) RemoteException(java.rmi.RemoteException) AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException)

Example 82 with AMException

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;
}
Also used : AMException(com.iplanet.am.sdk.AMException) AMObject(com.iplanet.am.sdk.AMObject) SSOException(com.iplanet.sso.SSOException)

Example 83 with AMException

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);
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) SSOToken(com.iplanet.sso.SSOToken) AMInvalidDNException(com.iplanet.am.sdk.AMInvalidDNException) AMException(com.iplanet.am.sdk.AMException)

Example 84 with AMException

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);
    }
}
Also used : AMEntity(com.iplanet.am.sdk.AMEntity) AMException(com.iplanet.am.sdk.AMException)

Example 85 with AMException

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;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Iterator(java.util.Iterator) AMException(com.iplanet.am.sdk.AMException)

Aggregations

AMException (com.iplanet.am.sdk.AMException)127 SSOException (com.iplanet.sso.SSOException)56 Set (java.util.Set)35 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)34 Guid (com.iplanet.ums.Guid)33 UMSException (com.iplanet.ums.UMSException)33 Map (java.util.Map)33 AMEventManagerException (com.iplanet.am.sdk.AMEventManagerException)32 RemoteException (java.rmi.RemoteException)31 AttrSet (com.iplanet.services.ldap.AttrSet)28 HashSet (java.util.HashSet)28 HashMap (java.util.HashMap)26 Iterator (java.util.Iterator)22 PersistentObject (com.iplanet.ums.PersistentObject)20 SSOToken (com.iplanet.sso.SSOToken)14 EntryNotFoundException (com.iplanet.ums.EntryNotFoundException)13 AMHashMap (com.iplanet.am.sdk.AMHashMap)12 AccessRightsException (com.iplanet.ums.AccessRightsException)12 SMSException (com.sun.identity.sm.SMSException)12 DN (org.forgerock.opendj.ldap.DN)12