Search in sources :

Example 41 with ConfigurationException

use of com.sun.identity.common.configuration.ConfigurationException 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 42 with ConfigurationException

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

the class ServerSiteModelImpl method deleteSites.

/**
     * Deletes a set of sites.
     *
     * @param sites Set of of sites to be deleted.
     * @throws AMConsoleException if error occurs when getting the site name.
     */
public void deleteSites(Set sites) throws AMConsoleException {
    String siteName = null;
    try {
        if ((sites != null) && !sites.isEmpty()) {
            SSOToken token = getUserSSOToken();
            for (Iterator i = sites.iterator(); i.hasNext(); ) {
                siteName = (String) i.next();
                String[] param = { siteName };
                logEvent("ATTEMPT_DELETE_SITE", param);
                SiteConfiguration.deleteSite(token, siteName);
                logEvent("SUCCEED_DELETE_SITE", param);
            }
        }
    } catch (ConfigurationException e) {
        String[] params = { siteName, e.getMessage() };
        logEvent("SMS_EXCEPTION_DELETE_SITE", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (SMSException e) {
        String[] params = { siteName, e.getMessage() };
        logEvent("SMS_EXCEPTION_DELETE_SITE", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        String[] params = { siteName, e.getMessage() };
        logEvent("SSO_EXCEPTION_DELETE_SITE", params);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) Iterator(java.util.Iterator) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 43 with ConfigurationException

use of com.sun.identity.common.configuration.ConfigurationException 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 44 with ConfigurationException

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

the class ServerSiteModelImpl method modifySite.

/**
     * Modifies site profile.
     *
     * @param siteName name of site.
     * @param primaryURL Primary URL.
     * @param failoverURLs Failover URLs.
     * @throws AMConsoleException if site profile cannot be modified.
     */
public void modifySite(String siteName, String primaryURL, Set failoverURLs) throws AMConsoleException {
    try {
        SSOToken ssoToken = getUserSSOToken();
        String[] param = { siteName };
        logEvent("ATTEMPT_MODIFY_SITE", param);
        SiteConfiguration.setSitePrimaryURL(ssoToken, siteName, primaryURL);
        SiteConfiguration.setSiteSecondaryURLs(ssoToken, siteName, failoverURLs);
        logEvent("SUCCEED_MODIFY_SITE", param);
    } catch (ConfigurationException e) {
        String[] params = { siteName, e.getMessage() };
        logEvent("CONFIGURATION_EXCEPTION_MODIFY_SITE", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (SMSException e) {
        String[] params = { siteName, e.getMessage() };
        logEvent("SMS_EXCEPTION_MODIFY_SITE", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        String[] params = { siteName, e.getMessage() };
        logEvent("SSO_EXCEPTION_MODIFY_SITE", params);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 45 with ConfigurationException

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

the class AgentsModelImpl method createAgentLocal.

/**
     * Creates localized agent.
     *
     * @param realmName Realm where agent resides.
     * @param name Name of agent.
     * @param type Type of agent.
     * @param password Password of agent.
     * @param agentURL Agent URL.
     * @throws AMConsoleException if agent cannot be created.
     */
public void createAgentLocal(String realmName, String name, String type, String password, String agentURL) throws AMConsoleException {
    String[] params = { realmName, name, type };
    try {
        logEvent("ATTEMPT_CREATE_AGENT", params);
        Map map = AgentConfiguration.getDefaultValues(type, false);
        Set set = new HashSet(2);
        map.put(AgentConfiguration.ATTR_NAME_PWD, set);
        set.add(password);
        Set newset = new HashSet(2);
        newset.add(AgentConfiguration.VAL_CONFIG_REPO_LOCAL);
        map.put(AgentConfiguration.ATTR_CONFIG_REPO, newset);
        AgentConfiguration.createAgentLocal(getUserSSOToken(), realmName, name, type, map, agentURL);
        logEvent("SUCCEED_CREATE_AGENT", params);
    } catch (ConfigurationException e) {
        String[] paramsEx = { realmName, name, type, getErrorString(e) };
        logEvent("EXCEPTION_CREATE_AGENT", paramsEx);
        debug.warning("AgentsModelImpl.createAgent", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (MalformedURLException e) {
        String[] paramsEx = { realmName, name, type, getErrorString(e) };
        logEvent("EXCEPTION_CREATE_AGENT", paramsEx);
        debug.warning("AgentsModelImpl.createAgent", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        String[] paramsEx = { realmName, name, type, getErrorString(e) };
        logEvent("EXCEPTION_CREATE_AGENT", paramsEx);
        debug.warning("AgentsModelImpl.createAgent", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (IdRepoException e) {
        String[] paramsEx = { realmName, name, type, getErrorString(e) };
        logEvent("EXCEPTION_CREATE_AGENT", paramsEx);
        debug.warning("AgentsModelImpl.createAgent", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (SMSException e) {
        String[] paramsEx = { realmName, name, type, getErrorString(e) };
        logEvent("EXCEPTION_CREATE_AGENT", paramsEx);
        debug.warning("AgentsModelImpl.createAgent", e);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)48 SSOException (com.iplanet.sso.SSOException)40 SMSException (com.sun.identity.sm.SMSException)39 SSOToken (com.iplanet.sso.SSOToken)30 CLIException (com.sun.identity.cli.CLIException)19 IOutput (com.sun.identity.cli.IOutput)17 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)14 List (java.util.List)12 IdRepoException (com.sun.identity.idm.IdRepoException)11 IOException (java.io.IOException)11 Map (java.util.Map)10 Set (java.util.Set)9 UnknownPropertyNameException (com.sun.identity.common.configuration.UnknownPropertyNameException)6 HashSet (java.util.HashSet)6 Iterator (java.util.Iterator)6 NotFoundException (org.forgerock.json.resource.NotFoundException)6 AMIdentity (com.sun.identity.idm.AMIdentity)5 MalformedURLException (java.net.MalformedURLException)5 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)5 HashMap (java.util.HashMap)4