Search in sources :

Example 81 with IOutput

use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.

the class ImportBulkFederationData method handleIDFFRequest.

private void handleIDFFRequest(Map nameIds) throws CLIException {
    for (Iterator i = nameIds.entrySet().iterator(); i.hasNext(); ) {
        Map.Entry e = (Map.Entry) i.next();
        String userId = (String) e.getKey();
        String nameId = (String) e.getValue();
        idffFederateUser(userId, nameId);
    }
    IOutput outputWriter = getOutputWriter();
    outputWriter.printlnMessage(getResourceString("import-bulk-federation-data-succeeded"));
}
Also used : IOutput(com.sun.identity.cli.IOutput) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map)

Example 82 with IOutput

use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.

the class ImportBulkFederationData method handleSAML2Request.

private void handleSAML2Request(Map nameIds) throws CLIException {
    for (Iterator i = nameIds.entrySet().iterator(); i.hasNext(); ) {
        Map.Entry e = (Map.Entry) i.next();
        String userId = (String) e.getKey();
        String nameId = (String) e.getValue();
        saml2FederateUser(userId, nameId);
    }
    IOutput outputWriter = getOutputWriter();
    outputWriter.printlnMessage(getResourceString("import-bulk-federation-data-succeeded"));
}
Also used : IOutput(com.sun.identity.cli.IOutput) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map)

Example 83 with IOutput

use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.

the class ImportServiceConfiguration method importData.

private void importData(String xmlFile, String encryptSecret, SSOToken ssoToken) throws CLIException, SSOException, SMSException, IOException {
    // set the correct password encryption key.
    // without doing so, the default encryption key will be used.
    String encKey = getEncKey(xmlFile);
    if (encKey != null) {
        SystemProperties.initializeProperties(Constants.ENC_PWD_PROPERTY, encKey);
        Crypt.reinitialize();
    }
    IOutput outputWriter = getOutputWriter();
    FileInputStream fis = null;
    try {
        AMEncryption encryptObj = new JCEEncryption();
        ((ConfigurableKey) encryptObj).setPassword(encryptSecret);
        ServiceManager ssm = new ServiceManager(ssoToken);
        fis = new FileInputStream(xmlFile);
        ssm.registerServices(fis, encryptObj);
        InitializeSystem initSys = CommandManager.initSys;
        String instanceName = initSys.getInstanceName();
        String serverConfigXML = initSys.getServerConfigXML();
        ServerConfiguration.setServerConfigXML(ssoToken, instanceName, serverConfigXML);
        outputWriter.printlnMessage(getResourceString("import-service-configuration-succeeded"));
    } catch (IOException e) {
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (Exception e) {
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } finally {
        if (fis != null) {
            try {
                fis.close();
            } catch (IOException ie) {
            //ignore if file input stream cannot be closed.
            }
        }
    }
}
Also used : AMEncryption(com.iplanet.services.util.AMEncryption) JCEEncryption(com.iplanet.services.util.JCEEncryption) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) ConfigurableKey(com.iplanet.services.util.ConfigurableKey) FileInputStream(java.io.FileInputStream) LoginException(javax.security.auth.login.LoginException) LDAPServiceException(com.iplanet.services.ldap.LDAPServiceException) InvalidAuthContextException(com.sun.identity.authentication.internal.InvalidAuthContextException) LdapException(org.forgerock.opendj.ldap.LdapException) SMSException(com.sun.identity.sm.SMSException) IOException(java.io.IOException) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) InitializeSystem(com.sun.identity.cli.InitializeSystem) IOutput(com.sun.identity.cli.IOutput) ServiceManager(com.sun.identity.sm.ServiceManager) CLIException(com.sun.identity.cli.CLIException)

Example 84 with IOutput

use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.

the class AddSubConfiguration method addSubConfigToRealm.

private void addSubConfigToRealm(String realmName, String serviceName, String subConfigName, String subConfigId, Map attrValues, int priority) throws CLIException {
    SSOToken adminSSOToken = getAdminSSOToken();
    IOutput outputWriter = getOutputWriter();
    String[] params = { realmName, subConfigName, serviceName };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_SUB_CONFIGURATION_TO_REALM", params);
    try {
        ServiceConfigManager scm = new ServiceConfigManager(serviceName, adminSSOToken);
        ServiceConfig sc = scm.getOrganizationConfig(realmName, null);
        if (sc == null) {
            sc = scm.createOrganizationConfig(realmName, null);
        }
        addSubConfig(sc, subConfigName, subConfigId, attrValues, priority);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_SUB_CONFIGURATION_TO_REALM", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-sub-configuration-to-realm-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { realmName, subConfigName, serviceName, e.getMessage() };
        debugError("AddSubConfiguration.addSubConfigToRealm", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_CONFIGURATIONT_TO_REALM", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { realmName, subConfigName, serviceName, e.getMessage() };
        debugError("AddSubConfiguration.addSubConfigToRealm", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_CONFIGURATIONT_TO_REALM", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 85 with IOutput

use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.

the class AddSubSchema 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();
    String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
    String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
    String fileName = getStringOptionValue(ARGUMENT_FILENAME);
    if (subSchemaName == null) {
        subSchemaName = "/";
    }
    IOutput outputWriter = getOutputWriter();
    String[] params = { serviceName, schemaType, subSchemaName };
    ServiceSchema ss = getServiceSchema();
    CommandManager mgr = getCommandManager();
    String url = mgr.getWebEnabledURL();
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_SUB_SCHEMA", params);
    try {
        if ((url != null) && (url.length() > 0)) {
            ss.addSubSchema(new ByteArrayInputStream(fileName.getBytes()));
        } else {
            ss.addSubSchema(new FileInputStream(fileName));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_SUB_SCHEMA", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-subschema-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, e.getMessage() };
        debugError("AddSubSchema.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_SCHEMA", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, e.getMessage() };
        debugError("AddSubSchema.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_SCHEMA", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (IOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, e.getMessage() };
        debugError("AddSubSchema.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_SCHEMA", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) CommandManager(com.sun.identity.cli.CommandManager) ByteArrayInputStream(java.io.ByteArrayInputStream) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Aggregations

IOutput (com.sun.identity.cli.IOutput)152 CLIException (com.sun.identity.cli.CLIException)137 SSOException (com.iplanet.sso.SSOException)123 SSOToken (com.iplanet.sso.SSOToken)99 SMSException (com.sun.identity.sm.SMSException)98 Set (java.util.Set)61 Iterator (java.util.Iterator)53 IdRepoException (com.sun.identity.idm.IdRepoException)45 List (java.util.List)45 AMIdentity (com.sun.identity.idm.AMIdentity)42 Map (java.util.Map)35 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)26 ServiceSchema (com.sun.identity.sm.ServiceSchema)26 IdType (com.sun.identity.idm.IdType)19 IOException (java.io.IOException)18 ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)17 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)15 HashMap (java.util.HashMap)15 HashSet (java.util.HashSet)15 AttributeSchema (com.sun.identity.sm.AttributeSchema)14