Search in sources :

Example 46 with AMException

use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.

the class DCTreeServicesImpl method getOrganizationDN.

/**
     * Returns the organization DN matching the domain name
     * 
     * @param token
     *            SSOToken
     * @param domainName
     *            String representing domin name
     * @return
     *            the organization dn
     * @throws AMException
     */
public String getOrganizationDN(SSOToken token, String domainName) throws AMException {
    try {
        DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
        Hashtable domainToOrgTable = dcTree.getChildDomainIDs();
        if (debug.messageEnabled()) {
            debug.message("DCTree:getOrgDN-> domain=" + domainName);
        }
        return ((String) domainToOrgTable.get(domainName));
    } catch (UMSException umse) {
        // Deepa: Is there a localized property for 1000?
        debug.error("DCTree:getOrganizationDN: " + "UMS Exception: ", umse);
        throw new AMException(AMSDKBundle.getString("1000"), "1000");
    }
}
Also used : UMSException(com.iplanet.ums.UMSException) Hashtable(java.util.Hashtable) AMException(com.iplanet.am.sdk.AMException) DomainComponentTree(com.iplanet.ums.dctree.DomainComponentTree) Guid(com.iplanet.ums.Guid)

Example 47 with AMException

use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.

the class DCTreeServicesImpl method createDomain.

/**
     * Method which creates a DC Tree for the given org, if the
     * <code>sunPreferredDomain</code> attribute is present and has a fully
     * qualified domain name as value.
     * 
     * @param token
     *            SSOToken
     * @param orgGuid
     *            identifiication of Organization entry to be mapped from dctree
     *            to organization DIT organization
     * @param domainName
     *            set the domain this organization belongs to.
     * @param attrSet
     *            the AttrSet of the organization
     * 
     * @exception AMException
     *                if unsuccessful in creating a dc tree for the organization
     *                or unsuccessful in setting the mapping between dc tree and
     *                the organization
     */
protected void createDomain(SSOToken token, Guid orgGuid, String domainName, AttrSet attrSet) throws AMException {
    if (DCTREE_START_DN == null) {
        throw new AMException(AMSDKBundle.getString("355"), "355");
    }
    // Create a DC tree for specified domain.
    if ((domainName != null) && (!domainName.equals(""))) {
        try {
            DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
            dcTree.addDomain(domainName);
            // Set the domain mapping
            dcTree.setDomainMapping(domainName, orgGuid);
            String status = attrSet.getValue(INET_DOMAIN_STATUS_ATTR);
            if (status != null) {
                dcTree.setDomainStatus(domainName, status);
            }
        } catch (InvalidDCRootException ie) {
            debug.error("DCTree.createDomain(): ", ie);
            throw new AMException(AMSDKBundle.getString("343"), "343");
        } catch (UMSException ue) {
            debug.error("DCTree.createDomain(): ", ue);
            throw new AMException(AMSDKBundle.getString("344"), "344");
        }
    }
}
Also used : UMSException(com.iplanet.ums.UMSException) AMException(com.iplanet.am.sdk.AMException) DomainComponentTree(com.iplanet.ums.dctree.DomainComponentTree) Guid(com.iplanet.ums.Guid) InvalidDCRootException(com.iplanet.ums.dctree.InvalidDCRootException)

Example 48 with AMException

use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.

the class DCTreeServicesImpl method updateDomainStatus.

/**
     * Method which update attribute inetdomainstatus of the DC Tree
     * corresponding to the Org
     * 
     * @param token
     *            SSOToken
     * @param orgDN
     *            String representing the DN correponding to the organization
     * @param status
     *            inetdomainstatus value
     * 
     * @exception AMException
     *                if error occured in accessing the org corresponding to
     *                orgDN or during the attribute change of the dc tree
     *                corresponding to the orgDN
     */
protected void updateDomainStatus(SSOToken token, String orgDN, String status) throws AMException {
    try {
        String domainName = getCanonicalDomain(token, orgDN);
        if ((domainName != null) && (domainName.length() > 0)) {
            DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
            dcTree.setDomainStatus(domainName, status);
        } else {
            debug.warning("DCTree.updateDomainStatus(): value for " + IPLANET_DOMAIN_NAME_ATTR + " attribute " + "null or empty");
        }
    // }
    } catch (UMSException ue) {
        debug.error("DCTree.removeDomain(): ", ue);
        throw new AMException(AMSDKBundle.getString("356"), "356");
    }
}
Also used : UMSException(com.iplanet.ums.UMSException) AMException(com.iplanet.am.sdk.AMException) DomainComponentTree(com.iplanet.ums.dctree.DomainComponentTree) Guid(com.iplanet.ums.Guid)

Example 49 with AMException

use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.

the class DirectoryServicesImpl method getRegisteredServiceNames.

// *************************************************************************
// Service Related Functionality
// *************************************************************************
/**
     * Get registered services for an organization
     * 
     * @param token
     *            SSOToken
     * @param entryDN
     *            DN of the org
     * @return Set set of service names
     */
public Set getRegisteredServiceNames(SSOToken token, String entryDN) throws AMException {
    try {
        Set attrNames = new HashSet(1);
        attrNames.add(SERVICE_STATUS_ATTRIBUTE);
        // User dsame privileged user to get the registered
        // services. Admins of all levels will need this access
        Map attributes = getAttributes(internalToken, entryDN, attrNames, AMObject.UNDETERMINED_OBJECT_TYPE);
        Set resultSet = Collections.EMPTY_SET;
        if (attributes.size() == 1) {
            resultSet = (Set) attributes.get(SERVICE_STATUS_ATTRIBUTE);
        }
        if (debug.messageEnabled()) {
            debug.message("DirectoryServicesImpl." + "getRegisteredServiceNames()" + " Registered Service Names for entryDN: " + entryDN + " are: " + resultSet);
        }
        return resultSet;
    } catch (Exception e) {
        debug.error("DirectoryServicesImpl.getRegisteredService", e);
        throw new AMException(token, "455");
    }
}
Also used : Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) AttrSet(com.iplanet.services.ldap.AttrSet) AMException(com.iplanet.am.sdk.AMException) Map(java.util.Map) AMHashMap(com.iplanet.am.sdk.AMHashMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) EntryAlreadyExistsException(com.iplanet.ums.EntryAlreadyExistsException) UMSException(com.iplanet.ums.UMSException) AMEventManagerException(com.iplanet.am.sdk.AMEventManagerException) AMEntryExistsException(com.iplanet.am.sdk.AMEntryExistsException) SizeLimitExceededException(com.iplanet.ums.SizeLimitExceededException) AMInvalidDNException(com.iplanet.am.sdk.AMInvalidDNException) TimeLimitExceededException(com.iplanet.ums.TimeLimitExceededException) SSOException(com.iplanet.sso.SSOException) AccessRightsException(com.iplanet.ums.AccessRightsException) LdapException(org.forgerock.opendj.ldap.LdapException) InvalidSearchFilterException(com.iplanet.ums.InvalidSearchFilterException) SMSException(com.sun.identity.sm.SMSException) AMException(com.iplanet.am.sdk.AMException) AMPreCallBackException(com.iplanet.am.sdk.AMPreCallBackException) EntryNotFoundException(com.iplanet.ums.EntryNotFoundException) COSNotFoundException(com.iplanet.ums.cos.COSNotFoundException) HashSet(java.util.HashSet)

Example 50 with AMException

use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.

the class DirectoryServicesImpl method setAttributes.

// TODO: method rename from setProfileAttributes to setAttributes
/**
     * Method Set the attributes of an entry.
     * 
     * @param token
     *            SSOToken
     * @param entryDN
     *            DN of the profile whose template is to be set
     * @param objectType
     *            profile type
     * @param stringAttributes
     *            attributes to be set
     * @param byteAttributes
     *            attributes to be set
     * @param isAdd
     *            <code>true</code> if add to existing value;
     *            otherwise replace the existing value.
     */
public void setAttributes(SSOToken token, String entryDN, int objectType, Map stringAttributes, Map byteAttributes, boolean isAdd) throws AMException, SSOException {
    Map oldAttributes = null;
    EmailNotificationHelper mailer = null;
    validateAttributeUniqueness(entryDN, objectType, false, stringAttributes);
    String eDN = entryDN;
    if (objectType == AMObject.USER) {
        eDN = DN.valueOf(entryDN).parent().toString();
    }
    String orgDN = getOrganizationDN(internalToken, eDN);
    try {
        if (debug.messageEnabled()) {
            debug.message("DirectoryServicesImpl.setAttributes() entryDN: " + entryDN);
        }
        if (objectType == AMObject.USER) {
            // Create user modification list
            // Invoke the user password validation plugin. Note: the
            // validation is done only for String attributes
            UserPasswordValidationHelper pluginImpl = new UserPasswordValidationHelper(token, orgDN);
            try {
                pluginImpl.validate(stringAttributes);
            } catch (AMException ame) {
                debug.error("DirectoryServicesImpl.setAttributes(): Invalid " + "characters for user", ame);
                throw ame;
            }
            // Create a mailter instance
            mailer = new EmailNotificationHelper(entryDN);
            mailer.setUserModifyNotificationList();
        }
        if ((getUserPostPlugin() != null) || (mailer != null && mailer.isPresentUserModifyNotificationList())) {
            Set attrNames = stringAttributes.keySet();
            oldAttributes = getAttributes(token, entryDN, attrNames, objectType);
        }
        // Call pre-processing user impls & get modified attributes
        // Note currently only String attributes supported
        stringAttributes = processPreModifyCallBacks(token, entryDN, oldAttributes, stringAttributes, orgDN, objectType);
        // Set DCTree attributes
        setDCTreeAttributes(token, entryDN, stringAttributes, objectType);
        // modify and save the entry
        modifyAndSaveEntry(token, entryDN, stringAttributes, byteAttributes, isAdd);
    } catch (AccessRightsException e) {
        if (debug.warningEnabled()) {
            debug.warning("DirectoryServicesImpl.setAttributes() User does " + "not have sufficient access rights: ", e);
        }
        throw new AMException(token, "460");
    } catch (EntryNotFoundException ee) {
        if (debug.warningEnabled()) {
            debug.warning("DirectoryServicesImpl.setAttributes() Entry not " + "found: ", ee);
        }
        String msgid = getEntryNotFoundMsgID(objectType);
        String entryName = getEntryName(ee);
        Object[] args = { entryName };
        throw new AMException(AMSDKBundle.getString(msgid, args), msgid, args);
    } catch (UMSException e) {
        if (debug.warningEnabled())
            debug.warning("DirectoryServicesImpl.setAttributes() Internal " + "error occurred", e);
        processInternalException(token, e, "452");
    }
    processPostModifyCallBacks(token, entryDN, oldAttributes, stringAttributes, orgDN, objectType);
    if (objectType == AMObject.USER) {
        AMUserEntryProcessed postPlugin = getUserPostPlugin();
        if (postPlugin != null) {
            // Invoke pre processing impls
            postPlugin.processUserModify(token, entryDN, oldAttributes, stringAttributes);
        }
        if (mailer != null && mailer.isPresentUserModifyNotificationList()) {
            mailer.sendUserModifyNotification(token, stringAttributes, oldAttributes);
        }
    }
}
Also used : AccessRightsException(com.iplanet.ums.AccessRightsException) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) AttrSet(com.iplanet.services.ldap.AttrSet) UMSException(com.iplanet.ums.UMSException) EntryNotFoundException(com.iplanet.ums.EntryNotFoundException) AMException(com.iplanet.am.sdk.AMException) AMUserEntryProcessed(com.iplanet.am.sdk.AMUserEntryProcessed) Map(java.util.Map) AMHashMap(com.iplanet.am.sdk.AMHashMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

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