Search in sources :

Example 66 with AMException

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

the class ComplianceServicesImpl method isAdminGroupsEnabled.

/**
     * Method which checks if Admin Groups need to be created for an
     * organization.
     * 
     * @param orgDN
     *            organization dn
     * @return true if Admin Groups need to be created
     * @exception AMException
     *                if an error is encountered
     */
public static boolean isAdminGroupsEnabled(String orgDN) throws AMException {
    if (!isUnderRootSuffix(orgDN)) {
        return false;
    }
    try {
        if (gsc == null) {
            ServiceSchemaManager scm = new ServiceSchemaManager(ADMINISTRATION_SERVICE, internalToken);
            gsc = scm.getGlobalSchema();
        }
        Map attrMap = gsc.getReadOnlyAttributeDefaults();
        Set values = (Set) attrMap.get(ADMIN_GROUPS_ENABLED_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.isAdminGroupsEnabled = " + enabled);
        }
        return enabled;
    } catch (SMSException ex) {
        debug.error(AMSDKBundle.getString("357"), ex);
        throw new AMException(AMSDKBundle.getString("357"), "357");
    } catch (SSOException ex) {
        debug.error(AMSDKBundle.getString("357"), ex);
        throw new AMException(AMSDKBundle.getString("357"), "357");
    }
}
Also used : HashSet(java.util.HashSet) AttrSet(com.iplanet.services.ldap.AttrSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 67 with AMException

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

the class CallBackHelper method preProcessModifyMemberShip.

/**
     * Special method for pre processing memberShip modification for roles &
     * groups.
     */
public Set preProcessModifyMemberShip(SSOToken token, String entryDN, String orgDN, Set members, int operation, int objectType) throws AMException {
    Set implSet = getPrePostImpls(orgDN);
    if (implSet != null && !implSet.isEmpty()) {
        // Post processing impls present
        // Iterate through the PrePost-Processing plugins and execute
        Iterator itr = implSet.iterator();
        while (itr.hasNext()) {
            String className = (String) itr.next();
            AMCallBack impl = getCallBackObject(className);
            if (impl == null) {
                continue;
            }
            try {
                switch(operation) {
                    case DirectoryServicesImpl.ADD_MEMBER:
                        members = impl.preProcessAddUser(token, entryDN, members, objectType);
                        break;
                    case DirectoryServicesImpl.REMOVE_MEMBER:
                        members = impl.preProcessRemoveUser(token, entryDN, members, objectType);
                        break;
                }
            } catch (AMException ae) {
                // Exception thrown by the external impl
                debug.error("CallBackHelper.preProcessModifyMemberShip():" + " Preprocessing impl " + className + " exception " + "thrown by impl:", ae);
                throw ae;
            }
        }
    }
    return members;
}
Also used : AMCallBack(com.iplanet.am.sdk.AMCallBack) AttrSet(com.iplanet.services.ldap.AttrSet) Set(java.util.Set) Iterator(java.util.Iterator) AMException(com.iplanet.am.sdk.AMException)

Example 68 with AMException

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

the class CallBackHelper method postProcess.

// TODO: Remove this. Use the Maps interface only
public void postProcess(SSOToken token, String entryDN, String orgDN, AttrSet oldAttrSet, AttrSet newAttrSet, int operation, int objectType, boolean softDelete) throws AMException {
    // Use the external impls instantiated at the time of pre-processing
    Set implSet = getPrePostImpls(orgDN);
    if ((implSet != null) && (!implSet.isEmpty())) {
        Map newAttrMap = CommonUtils.attrSetToMap(newAttrSet);
        Map oldAttrMap = CommonUtils.attrSetToMap(oldAttrSet);
        // Iterate through the Pre-Processing Impls and execute
        Iterator itr = implSet.iterator();
        while (itr.hasNext()) {
            String className = (String) itr.next();
            AMCallBack impl = getCallBackObject(className);
            if (impl == null) {
                continue;
            }
            try {
                switch(operation) {
                    case CREATE:
                        impl.postProcessCreate(token, entryDN, newAttrMap, objectType);
                        break;
                    case MODIFY:
                        impl.postProcessModify(token, entryDN, oldAttrMap, newAttrMap, objectType);
                        break;
                    case DELETE:
                        impl.postProcessDelete(token, entryDN, oldAttrMap, softDelete, objectType);
                        break;
                }
            } catch (AMException ae) {
                // Exception thrown by the external impl
                debug.error("CallBackHelper.postProcess(): Preprocessing" + "impl " + impl.getClass().getName() + " exception thrown: ", ae);
            }
        }
    }
}
Also used : AMCallBack(com.iplanet.am.sdk.AMCallBack) AttrSet(com.iplanet.services.ldap.AttrSet) Set(java.util.Set) Iterator(java.util.Iterator) AMException(com.iplanet.am.sdk.AMException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 69 with AMException

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

the class RemoteServicesImpl method createEntry.

/**
     * Create an entry in the Directory
     * 
     * @param token
     *            SSOToken
     * @param entryName
     *            name of the entry (naming value), e.g. "sun.com", "manager"
     * @param objectType
     *            Profile Type, ORGANIZATION, AMObject.ROLE, AMObject.USER, etc.
     * @param parentDN
     *            the parent DN
     * @param attributes
     *            the initial attribute set for creation
     */
public void createEntry(SSOToken token, String entryName, int objectType, String parentDN, Map attributes) throws AMEntryExistsException, AMException, SSOException {
    try {
        String tokenID = token.getTokenID().toString();
        Object[] objs = { tokenID, entryName, new Integer(objectType), parentDN, attributes };
        client.send(client.encodeMessage("createEntry", objs), sessionCookies.getLBCookie(tokenID), null);
    } catch (AMRemoteException amrex) {
        if (getDebug().messageEnabled()) {
            getDebug().message("RemoteServicesImpl.createEntry: entryName=" + entryName + ";  AMRemoteException caught exception=", amrex);
        }
        throw convertException(amrex);
    } catch (SSOException ssoe) {
        throw ssoe;
    } catch (RemoteException rex) {
        getDebug().error("RemoteServicesImpl.createEntry: caught " + "exception=", rex);
        throw new AMException(AMSDKBundle.getString("1000"), "1000");
    } catch (Exception ex) {
        if (getDebug().messageEnabled()) {
            getDebug().message("RemoteServicesImpl.createEntry: entryName=" + entryName + ";  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 70 with AMException

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

the class RemoteServicesImpl method verifyAndGetOrgDN.

/**
     * Gets the Organization DN for the specified entryDN. If the entry itself
     * is an org, then same DN is returned.
     * 
     * @param token
     *            a valid SSOToken
     * @param entryDN
     *            the entry whose parent Organization is to be obtained
     * @param childDN
     *            the immediate entry whose parent Organization is to be
     *            obtained
     * @return the DN String of the parent Organization
     * @throws AMException
     *             if an error occured while obtaining the parent Organization
     */
public String verifyAndGetOrgDN(SSOToken token, String entryDN, String childDN) throws AMException {
    try {
        String tokenID = token.getTokenID().toString();
        Object[] objs = { tokenID, entryDN, childDN };
        return ((String) client.send(client.encodeMessage("verifyAndGetOrgDN", objs), sessionCookies.getLBCookie(tokenID), null));
    } catch (AMRemoteException amrex) {
        if (getDebug().messageEnabled()) {
            getDebug().message("RemoteServicesImpl.verifyAndGetOrgDN: entryDN=" + entryDN + ";  AMRemoteException caught exception=", amrex);
        }
        throw convertException(amrex);
    } catch (RemoteException rex) {
        getDebug().error("RemoteServicesImpl.verifyAndGetOrgDN: caught exception=", rex);
        throw new AMException(AMSDKBundle.getString("1000"), "1000");
    } catch (SSOException ssoe) {
        getDebug().error("RemoteServicesImpl.verifyAndGetOrgDN: caught " + "SSOException=", ssoe);
        throw new AMException(AMSDKBundle.getString("1000"), "1000");
    } catch (Exception ex) {
        if (getDebug().messageEnabled()) {
            getDebug().message("RemoteServicesImpl.verifyAndGetOrgDN: 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)

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