Search in sources :

Example 6 with UnknownPropertyNameException

use of com.sun.identity.common.configuration.UnknownPropertyNameException in project OpenAM by OpenRock.

the class SpecialRepo method updateServiceConfiguration.

private void updateServiceConfiguration(String urlAccessAgentCryptPwd) throws IdRepoException, SSOException {
    if (urlAccessAgentCryptPwd != null) {
        Map<String, Set<String>> map = new HashMap<String, Set<String>>();
        Set<String> set = new HashSet<String>();
        set.add(urlAccessAgentCryptPwd);
        map.put(Constants.AM_SERVICES_SECRET, set);
        SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
        String instance = SystemProperties.getServerInstanceName();
        try {
            ServerConfiguration.setServerInstance(adminToken, instance, map);
        } catch (SMSException e) {
            debug.error("SpecialRepo.updateServiceConfiguration", e);
            Object[] args = { NAME, IdOperation.EDIT.getName() };
            throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.UNABLE_SYNC_URL_ACCESS_AGENT, args);
        } catch (IOException e) {
            debug.error("SpecialRepo.updateServiceConfiguration", e);
            Object[] args = { NAME, IdOperation.EDIT.getName() };
            throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.UNABLE_SYNC_URL_ACCESS_AGENT, args);
        } catch (ConfigurationException e) {
            debug.error("SpecialRepo.updateServiceConfiguration", e);
            Object[] args = { NAME, IdOperation.EDIT.getName() };
            throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.UNABLE_SYNC_URL_ACCESS_AGENT, args);
        } catch (UnknownPropertyNameException e) {
        // never happen
        }
    }
}
Also used : UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) Set(java.util.Set) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) SSOToken(com.iplanet.sso.SSOToken) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) SMSException(com.sun.identity.sm.SMSException) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) IdRepoException(com.sun.identity.idm.IdRepoException) IOException(java.io.IOException) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet)

Example 7 with UnknownPropertyNameException

use of com.sun.identity.common.configuration.UnknownPropertyNameException in project OpenAM by OpenRock.

the class ServerSiteModelImpl method createServer.

/**
     * Creates a server.
     *
     * @param name Name of Server.
     * @throws AMConsoleException if error occurs when creating server.
     */
public void createServer(String name) throws AMConsoleException {
    SSOToken ssoToken = getUserSSOToken();
    String[] param = { name };
    logEvent("ATTEMPT_CREATE_SERVER", param);
    try {
        String svrConfigXML = ServerConfiguration.getServerConfigXML(ssoToken, SystemProperties.getServerInstanceName());
        ServerConfiguration.createServerInstance(ssoToken, name, Collections.EMPTY_MAP, svrConfigXML);
        logEvent("SUCCEED_CREATE_SERVER", param);
    } catch (UnknownPropertyNameException e) {
    // this will not happen because we do not set any property during
    // creation.
    } catch (SSOException e) {
        String[] params = { name, e.getMessage() };
        logEvent("SSO_EXCEPTION_CREATE_SERVER", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (ConfigurationException e) {
        String[] params = { name, e.getMessage() };
        logEvent("CONFIGURATION_EXCEPTION_CREATE_SERVER", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (SMSException e) {
        String[] params = { name, e.getMessage() };
        logEvent("SMS_EXCEPTION_CREATE_SITE", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (IOException e) {
        String[] params = { name, e.getMessage() };
        logEvent("IO_EXCEPTION_CREATE_SERVER", params);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) SSOToken(com.iplanet.sso.SSOToken) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 8 with UnknownPropertyNameException

use of com.sun.identity.common.configuration.UnknownPropertyNameException in project OpenAM by OpenRock.

the class ServerSiteModelImpl method updateServerConfigInheritance.

/**
     * Updates server property inheritance settings.
     *
     * @param serverName Name of server.
     * @param toInherit Properties to inherit.
     * @param notToInherit Properties not to inherit.
     * @throws AMConsoleException if server profile cannot be updated.
     */
public void updateServerConfigInheritance(String serverName, Set toInherit, Set notToInherit) throws AMConsoleException {
    String[] param = { serverName };
    logEvent("ATTEMPT_MODIFY_SERVER_INHERITANCE", param);
    try {
        SSOToken ssoToken = getUserSSOToken();
        Map defaultValues = ServerConfiguration.getDefaults(ssoToken);
        Map svrProperties = ServerConfiguration.getServerInstance(ssoToken, serverName);
        if ((toInherit != null) && !toInherit.isEmpty()) {
            Set toRemove = new HashSet();
            for (Iterator i = toInherit.iterator(); i.hasNext(); ) {
                String name = (String) i.next();
                if (svrProperties.containsKey(name)) {
                    toRemove.add(name);
                }
            }
            if (!toRemove.isEmpty()) {
                ServerConfiguration.removeServerConfiguration(ssoToken, serverName, toRemove);
            }
        }
        if ((notToInherit != null) && !notToInherit.isEmpty()) {
            Map toAdd = new HashMap();
            for (Iterator i = notToInherit.iterator(); i.hasNext(); ) {
                String name = (String) i.next();
                if (!svrProperties.containsKey(name)) {
                    toAdd.put(name, defaultValues.get(name));
                }
            }
            if (!toAdd.isEmpty()) {
                try {
                    ServerConfiguration.setServerInstance(ssoToken, serverName, toAdd);
                } catch (UnknownPropertyNameException ex) {
                // ignore, this cannot happen because default values
                // would have all valid property names
                }
            }
        }
        logEvent("SUCCEED_MODIFY_SERVER_INHERITANCE", param);
    } catch (ConfigurationException e) {
        String[] params = { serverName, e.getMessage() };
        logEvent("CONFIGURATION_EXCEPTION_MODIFY_SERVER_INHERITANCE", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (IOException e) {
        String[] params = { serverName, e.getMessage() };
        logEvent("IO_EXCEPTION_MODIFY_SERVER_INHERITANCE", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (SMSException e) {
        String[] params = { serverName, e.getMessage() };
        logEvent("SMS_EXCEPTION_MODIFY_SERVER_INHERITANCE", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        String[] params = { serverName, e.getMessage() };
        logEvent("SSO_EXCEPTION_MODIFY_SERVER_INHERITANCE", params);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) Iterator(java.util.Iterator) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 9 with UnknownPropertyNameException

use of com.sun.identity.common.configuration.UnknownPropertyNameException in project OpenAM by OpenRock.

the class UpdateServerConfig 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 serverName = getStringOptionValue(IArgument.SERVER_NAME);
    String datafile = getStringOptionValue(IArgument.DATA_FILE);
    List attrValues = rc.getOption(IArgument.ATTRIBUTE_VALUES);
    if ((datafile == null) && (attrValues == null)) {
        throw new CLIException(getResourceString("missing-attributevalues"), ExitCodes.INCORRECT_OPTION, rc.getSubCommand().getName());
    }
    Map attributeValues = AttributeValues.parse(getCommandManager(), datafile, attrValues);
    encryptPasswordAttributes(attributeValues);
    String[] params = { serverName };
    try {
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_UPDATE_SERVER_CONFIG", params);
        if (serverName.equals(DEFAULT_SVR_CONFIG)) {
            try {
                ServerConfiguration.setServerInstance(adminSSOToken, ServerConfiguration.DEFAULT_SERVER_CONFIG, attributeValues);
            } catch (UnknownPropertyNameException ex) {
                outputWriter.printlnMessage(ex.getL10NMessage(getCommandManager().getLocale()));
                outputWriter.printlnMessage("");
            }
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("update-server-config-succeeded"), (Object[]) params));
        } else {
            if (ServerConfiguration.isServerInstanceExist(adminSSOToken, serverName)) {
                try {
                    ServerConfiguration.setServerInstance(adminSSOToken, serverName, attributeValues);
                } catch (UnknownPropertyNameException ex) {
                    outputWriter.printlnMessage(getResourceString("update-server-config-unknown"));
                    outputWriter.printlnMessage("");
                }
                outputWriter.printlnMessage(MessageFormat.format(getResourceString("update-server-config-succeeded"), (Object[]) params));
            } else {
                outputWriter.printlnMessage(MessageFormat.format(getResourceString("update-server-config-does-not-exists"), (Object[]) params));
            }
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_UPDATE_SERVER_CONFIG", params);
    } catch (ConfigurationException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("UpdateServerConfig.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_SERVER_CONFIG", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (IOException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("UpdateServerConfig.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_SERVER_CONFIG", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("UpdateServerConfig.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_SERVER_CONFIG", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("UpdateServerConfig.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_SERVER_CONFIG", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) SSOToken(com.iplanet.sso.SSOToken) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) List(java.util.List) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) Map(java.util.Map)

Aggregations

UnknownPropertyNameException (com.sun.identity.common.configuration.UnknownPropertyNameException)9 ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)6 SMSException (com.sun.identity.sm.SMSException)6 SSOException (com.iplanet.sso.SSOException)5 SSOToken (com.iplanet.sso.SSOToken)5 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)5 IOException (java.io.IOException)5 Map (java.util.Map)4 ServerSiteModel (com.sun.identity.console.service.model.ServerSiteModel)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 CLIException (com.sun.identity.cli.CLIException)2 IOutput (com.sun.identity.cli.IOutput)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Set (java.util.Set)2 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)1 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)1 IdRepoException (com.sun.identity.idm.IdRepoException)1 StringTokenizer (java.util.StringTokenizer)1