Search in sources :

Example 71 with AMIdentityRepository

use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.

the class AgentsModelImpl method deleteAgents.

/**
     * Deletes agents.
     *
     * @param realmName Realm where agent resides.
     * @param agents Set of agent names to be deleted.
     * @throws AMConsoleException if agents cannot be deleted.
     */
public void deleteAgents(String realmName, Set agents) throws AMConsoleException {
    if ((agents != null) && !agents.isEmpty()) {
        String idNames = AMFormatUtils.toCommaSeparatedFormat(agents);
        String[] params = { realmName, idNames };
        logEvent("ATTEMPT_DELETE_AGENT", params);
        try {
            AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
            repo.deleteIdentities(getAMIdentity(agents));
            logEvent("SUCCEED_DELETE_AGENT", params);
        } catch (IdRepoException e) {
            String[] paramsEx = { realmName, idNames, getErrorString(e) };
            logEvent("EXCEPTION_DELETE_AGENT", paramsEx);
            throw new AMConsoleException(getErrorString(e));
        } catch (SSOException e) {
            String[] paramsEx = { realmName, idNames, getErrorString(e) };
            logEvent("EXCEPTION_DELETE_AGENT", paramsEx);
            throw new AMConsoleException(getErrorString(e));
        }
    }
}
Also used : AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 72 with AMIdentityRepository

use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.

the class AgentsModelImpl method getAgentGroupNames.

/**
     * Returns agent group names.
     *
     * @param realmName Realm where agent groups reside.
     * @param setTypes Agent Types.
     * @param pattern Search Pattern.
     * @param results Set to contains the results.
     * @return error code.
     * @throws AMConsoleException if result cannot be returned.
     */
public int getAgentGroupNames(String realmName, Set setTypes, String pattern, Set results) throws AMConsoleException {
    int sizeLimit = getSearchResultLimit();
    int timeLimit = getSearchTimeOutLimit();
    String[] params = { realmName, setTypes.toString(), pattern, Integer.toString(sizeLimit), Integer.toString(timeLimit) };
    try {
        IdSearchControl idsc = new IdSearchControl();
        idsc.setMaxResults(sizeLimit);
        idsc.setTimeOut(timeLimit);
        idsc.setAllReturnAttributes(false);
        logEvent("ATTEMPT_SEARCH_AGENT_GROUP", params);
        AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
        IdSearchResults isr = repo.searchIdentities(IdType.AGENTGROUP, pattern, idsc);
        Set res = isr.getSearchResults();
        if ((res != null) && !res.isEmpty()) {
            for (Iterator i = res.iterator(); i.hasNext(); ) {
                AMIdentity amid = (AMIdentity) i.next();
                if (matchType(amid, setTypes)) {
                    results.add(amid);
                }
            }
        }
        logEvent("SUCCEED_SEARCH_AGENT_GROUP", params);
        return isr.getErrorCode();
    } catch (IdRepoException e) {
        String[] paramsEx = { realmName, setTypes.toString(), pattern, Integer.toString(sizeLimit), Integer.toString(timeLimit), getErrorString(e) };
        logEvent("EXCEPTION_SEARCH_AGENT_GROUP", paramsEx);
        if (debug.warningEnabled()) {
            debug.warning("AgentsModelImpl.getAgentGroupNames " + getErrorString(e));
        }
        throw new AMConsoleException("no.properties");
    } catch (SSOException e) {
        String[] paramsEx = { realmName, setTypes.toString(), pattern, Integer.toString(sizeLimit), Integer.toString(timeLimit), getErrorString(e) };
        logEvent("EXCEPTION_SEARCH_AGENT_GROUP", paramsEx);
        debug.warning("AgentsModelImpl.getAgentGroupNames ", e);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) IdSearchResults(com.sun.identity.idm.IdSearchResults) AMIdentity(com.sun.identity.idm.AMIdentity) IdSearchControl(com.sun.identity.idm.IdSearchControl) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) Iterator(java.util.Iterator) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 73 with AMIdentityRepository

use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.

the class AgentsModelImpl method getAgentNames.

/**
     * Returns agent names.
     *
     * @param realmName Realm where agents reside.
     * @param setTypes Agent Types.
     * @param pattern Search Pattern.
     * @param results Set to contains the results.
     * @return error code.
     * @throws AMConsoleException if result cannot be returned.
     */
public int getAgentNames(String realmName, Set setTypes, String pattern, Set results) throws AMConsoleException {
    int sizeLimit = getSearchResultLimit();
    int timeLimit = getSearchTimeOutLimit();
    String[] params = { realmName, setTypes.toString(), pattern, Integer.toString(sizeLimit), Integer.toString(timeLimit) };
    try {
        IdSearchControl idsc = new IdSearchControl();
        idsc.setMaxResults(sizeLimit);
        idsc.setTimeOut(timeLimit);
        idsc.setAllReturnAttributes(false);
        logEvent("ATTEMPT_SEARCH_AGENT", params);
        AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
        IdSearchResults isr = repo.searchIdentities(IdType.AGENTONLY, pattern, idsc);
        Set res = isr.getSearchResults();
        if ((res != null) && !res.isEmpty()) {
            for (Iterator i = res.iterator(); i.hasNext(); ) {
                AMIdentity amid = (AMIdentity) i.next();
                if (matchType(amid, setTypes)) {
                    results.add(amid);
                }
            }
        }
        logEvent("SUCCEED_SEARCH_AGENT", params);
        return isr.getErrorCode();
    } catch (IdRepoException e) {
        String[] paramsEx = { realmName, setTypes.toString(), pattern, Integer.toString(sizeLimit), Integer.toString(timeLimit), getErrorString(e) };
        logEvent("EXCEPTION_SEARCH_AGENT", paramsEx);
        if (debug.warningEnabled()) {
            debug.warning("AgentsModelImpl.getAgentNames " + getErrorString(e));
        }
        throw new AMConsoleException("no.properties");
    } catch (SSOException e) {
        String[] paramsEx = { realmName, setTypes.toString(), pattern, Integer.toString(sizeLimit), Integer.toString(timeLimit), getErrorString(e) };
        logEvent("EXCEPTION_SEARCH_AGENT", paramsEx);
        debug.warning("AgentsModelImpl.getAgentNames ", e);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) IdSearchResults(com.sun.identity.idm.IdSearchResults) AMIdentity(com.sun.identity.idm.AMIdentity) IdSearchControl(com.sun.identity.idm.IdSearchControl) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) Iterator(java.util.Iterator) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 74 with AMIdentityRepository

use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.

the class AMModelBase method getConsoleAttributes.

/**
     * Returns a map of the cosole service attributes configured at the realm
     * where the user started (typically where they logged in at.) If the
     * admin service is not configured in that realm, the defaults are taken
     * from global configuration.
     */
protected Map getConsoleAttributes() {
    if (consoleAttributes == null) {
        try {
            AMIdentityRepository repo = new AMIdentityRepository(adminSSOToken, getStartDN());
            AMIdentity realmIdentity = repo.getRealmIdentity();
            Set servicesFromIdRepo = realmIdentity.getAssignedServices();
            if (servicesFromIdRepo.contains(ADMIN_CONSOLE_SERVICE)) {
                consoleAttributes = realmIdentity.getServiceAttributes(ADMIN_CONSOLE_SERVICE);
            } else {
                OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(adminSSOToken, getStartDN());
                consoleAttributes = orgCfgMgr.getServiceAttributes(ADMIN_CONSOLE_SERVICE);
            }
        } catch (SSOException e) {
            debug.error("AMModelBase.getConsoleAttributes", e);
        } catch (SMSException e) {
            debug.error("AMModelBase.getConsoleAttributes", e);
        } catch (IdRepoException e) {
            debug.error("AMModelBase.getConsoleAttributes", e);
        }
    }
    return consoleAttributes;
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) AMIdentity(com.sun.identity.idm.AMIdentity) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException)

Example 75 with AMIdentityRepository

use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.

the class AMModelBase method getSpecialUsers.

/**
     * Returns a set of special user identities. This set of identities 
     * typically should not be displayed in the console. 
     *
     * @param realmName Name of Realm.
     * @return a set of <code>AMIdentity</code> entries that should not be 
     *     displayed in the console.
     */
public Set getSpecialUsers(String realmName) {
    Set identities = null;
    try {
        AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
        IdSearchResults results = repo.getSpecialIdentities(IdType.USER);
        identities = results.getSearchResults();
    } catch (IdRepoException e) {
        debug.warning("AMModelBase.getSpecialUsers", e);
    } catch (SSOException e) {
        debug.warning("AMModelBase.getSpecialUsers", e);
    }
    return (identities == null) ? Collections.EMPTY_SET : identities;
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) IdSearchResults(com.sun.identity.idm.IdSearchResults) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException)

Aggregations

AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)138 IdRepoException (com.sun.identity.idm.IdRepoException)103 SSOException (com.iplanet.sso.SSOException)94 AMIdentity (com.sun.identity.idm.AMIdentity)85 Set (java.util.Set)82 HashSet (java.util.HashSet)58 SSOToken (com.iplanet.sso.SSOToken)56 IdSearchControl (com.sun.identity.idm.IdSearchControl)36 IdSearchResults (com.sun.identity.idm.IdSearchResults)36 Iterator (java.util.Iterator)32 CLIException (com.sun.identity.cli.CLIException)29 HashMap (java.util.HashMap)29 IdType (com.sun.identity.idm.IdType)28 Map (java.util.Map)27 IOutput (com.sun.identity.cli.IOutput)26 SMSException (com.sun.identity.sm.SMSException)24 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)20 List (java.util.List)13 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)12 Callback (javax.security.auth.callback.Callback)6