Search in sources :

Example 41 with AMIdentityRepository

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

the class ConfigMonitoring method getAgents.

private void getAgents(String realm) {
    String classMethod = "ConfigMonitoring.getAgents: ";
    StringBuffer sb = new StringBuffer(classMethod);
    try {
        IdSearchControl isc = new IdSearchControl();
        isc.setMaxResults(0);
        // should use set value, but for now...
        isc.setTimeOut(3000);
        isc.setAllReturnAttributes(false);
        AMIdentityRepository airepo = new AMIdentityRepository(ssoToken, realm);
        IdSearchResults isr = airepo.searchIdentities(IdType.AGENT, "*", isc);
        // set of AMIdentitys
        Set results = isr.getSearchResults();
        sb = new StringBuffer("Agents for realm ");
        sb.append(realm).append("; size = ").append(results.size()).append(":\n");
        for (Iterator it = results.iterator(); it.hasNext(); ) {
            AMIdentity aid = (AMIdentity) it.next();
            processAgentIdentity(aid, sb);
        }
        debug.error(classMethod + sb.toString());
    } catch (IdRepoException e) {
        debug.error(classMethod + "idrepo error getting agents: " + e.getMessage());
    } catch (SSOException e) {
        debug.error(classMethod + "sso error getting agents: " + e.getMessage());
    }
}
Also used : 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)

Example 42 with AMIdentityRepository

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

the class ConfigMonitoring method getSupportedEntityTypes.

private Set getSupportedEntityTypes(String realm) {
    String classMethod = "ConfigMonitoring.getSupportedEntityTypes: ";
    Set supportedTypes = Collections.EMPTY_SET;
    try {
        AMIdentityRepository repo = new AMIdentityRepository(ssoToken, realm);
        supportedTypes = repo.getSupportedIdTypes();
    } catch (IdRepoException e) {
        debug.error(classMethod + "idrepo exception getting supported entity types; " + e.getMessage());
    } catch (SSOException e) {
        debug.error(classMethod + "sso exception getting supported entity types; " + e.getMessage());
    }
    return supportedTypes;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException)

Example 43 with AMIdentityRepository

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

the class DeleteAgents method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    String realm = getStringOptionValue(IArgument.REALM_NAME);
    List agentNames = (List) rc.getOption(IArgument.AGENT_NAMES);
    String file = getStringOptionValue(IArgument.FILE);
    if (agentNames == null) {
        agentNames = new ArrayList();
    }
    if (file != null) {
        agentNames.addAll(AttributeValues.parseValues(file));
    }
    if (agentNames.isEmpty()) {
        throw new CLIException(getResourceString("missing-agent-names"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
    String displayableNames = tokenize(agentNames);
    String[] params = { realm, displayableNames };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_AGENTS", params);
    try {
        AMIdentityRepository amir = new AMIdentityRepository(adminSSOToken, realm);
        Set setDelete = new HashSet();
        for (Iterator i = agentNames.iterator(); i.hasNext(); ) {
            String name = (String) i.next();
            AMIdentity amid = new AMIdentity(adminSSOToken, name, IdType.AGENTONLY, realm, null);
            setDelete.add(amid);
        }
        amir.deleteIdentities(setDelete);
        IOutput outputWriter = getOutputWriter();
        outputWriter.printlnMessage(getResourceString("delete-agent-succeeded"));
        for (Iterator i = agentNames.iterator(); i.hasNext(); ) {
            outputWriter.printlnMessage("    " + (String) i.next());
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_DELETE_AGENTS", params);
    } catch (IdRepoException e) {
        String[] args = { realm, displayableNames, e.getMessage() };
        debugError("DeleteAgents.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_AGENTS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        String[] args = { realm, displayableNames, e.getMessage() };
        debugError("DeleteAgents.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_AGENTS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) IOutput(com.sun.identity.cli.IOutput) AMIdentity(com.sun.identity.idm.AMIdentity) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) Iterator(java.util.Iterator) CLIException(com.sun.identity.cli.CLIException) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Example 44 with AMIdentityRepository

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

the class ListAgents method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    IOutput outputWriter = getOutputWriter();
    String realm = getStringOptionValue(IArgument.REALM_NAME);
    String patternType = getStringOptionValue(IArgument.AGENT_TYPE);
    String filter = getStringOptionValue(IArgument.FILTER);
    if (patternType == null) {
        patternType = "";
    }
    if ((filter == null) || (filter.length() == 0)) {
        filter = "*";
    }
    String[] params = { realm, patternType, filter };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_LIST_AGENTS", params);
    try {
        AMIdentityRepository amir = new AMIdentityRepository(adminSSOToken, realm);
        IdSearchResults isr = amir.searchIdentities(IdType.AGENTONLY, filter, new IdSearchControl());
        Set results = isr.getSearchResults();
        if ((results != null) && !results.isEmpty()) {
            for (Iterator i = results.iterator(); i.hasNext(); ) {
                AMIdentity amid = (AMIdentity) i.next();
                if (!matchType(amid, patternType)) {
                    i.remove();
                }
            }
        }
        if ((results != null) && !results.isEmpty()) {
            for (Iterator i = results.iterator(); i.hasNext(); ) {
                AMIdentity amid = (AMIdentity) i.next();
                Object[] args = { amid.getName(), amid.getUniversalId() };
                outputWriter.printlnMessage(MessageFormat.format(getResourceString("format-search-agent-results"), args));
            }
        } else {
            outputWriter.printlnMessage(getResourceString("search-agent-no-entries"));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_LIST_AGENTS", params);
    } catch (IdRepoException e) {
        String[] args = { realm, patternType, filter, e.getMessage() };
        debugError("ListAgents.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_AGENTS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        String[] args = { realm, patternType, filter, e.getMessage() };
        debugError("ListAgents.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_AGENTS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) IdSearchResults(com.sun.identity.idm.IdSearchResults) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) IOutput(com.sun.identity.cli.IOutput) AMIdentity(com.sun.identity.idm.AMIdentity) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdSearchControl(com.sun.identity.idm.IdSearchControl) Iterator(java.util.Iterator) CLIException(com.sun.identity.cli.CLIException)

Example 45 with AMIdentityRepository

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

the class DevicePrintModule method init.

/**
     * {@inheritDoc}
     */
@Override
public void init(Subject subject, Map sharedState, Map options) {
    userName = (String) sharedState.get(getUserKey());
    if (StringUtils.isEmpty(userName)) {
        ResourceBundle bundle = amCache.getResBundle(AUTH_MODULE_NAME, getLoginLocale());
        DEBUG.warning(bundle.getString("authModuleNotSetUpWithUsername"));
    }
    AMIdentityRepository amIdentityRepository = getAMIdentityRepository(getRequestOrg());
    AMIdentity amIdentity = getIdentity();
    HOTPService hotpService = moduleInitialiser.getHOTPService(getLoginLocale(), amCache, userName, amIdentityRepository, options);
    devicePrintAuthenticationService = moduleInitialiser.getDevicePrintAuthenticationService(amIdentity, getHttpServletRequest(), hotpService, options);
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) HOTPService(com.sun.identity.authentication.modules.hotp.HOTPService) ResourceBundle(java.util.ResourceBundle)

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