Search in sources :

Example 16 with ServiceConfig

use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.

the class ServerConfiguration method createDefaults.

public static void createDefaults(SSOToken ssoToken) throws SSOException, SMSException, UnknownPropertyNameException {
    boolean bCreated = false;
    ServiceConfig sc = getRootServerConfig(ssoToken);
    try {
        bCreated = (sc.getSubConfig(DEFAULT_SERVER_CONFIG) != null);
    } catch (SMSException e) {
    // ignore, default is not created.
    }
    if (!bCreated) {
        ResourceBundle res = ResourceBundle.getBundle(SERVER_DEFAULTS);
        Set values = new HashSet();
        for (Enumeration i = res.getKeys(); i.hasMoreElements(); ) {
            String key = (String) i.nextElement();
            String val = (String) res.getString(key);
            if (val.equals("@" + SetupConstants.CONFIG_VAR_PLATFORM_LOCALE + "@")) {
                val = Locale.getDefault().toString();
            }
            values.add(key + "=" + val);
        }
        try {
            createServerInstance(ssoToken, DEFAULT_SERVER_CONFIG, DEFAULT_SERVER_ID, values, "");
        } catch (ConfigurationException ex) {
        //ignore, this should not happen because default values
        //are all valid.
        }
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Enumeration(java.util.Enumeration) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) ResourceBundle(java.util.ResourceBundle) HashSet(java.util.HashSet)

Example 17 with ServiceConfig

use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.

the class ServerConfiguration method getServerInstance.

/**
     * Returns the configuration of a server instance.
     *
     * @param ssoToken Single Sign-On Token which is used to access to the
     *        service management datastore.
     * @param instanceName Name of the server instance.
     * @return the configuration of the server Instance.
     * @throws SMSException if errors access in the service management
     *         datastore.
     * @throws SSOException if the <code>ssoToken</code> is not valid.
     * @throws IOException if IO operation fails.
     */
public static Properties getServerInstance(SSOToken ssoToken, String instanceName) throws SMSException, SSOException, IOException {
    Properties prop = null;
    ServiceConfig cfg = getServerConfig(ssoToken, instanceName);
    if (cfg != null) {
        Map map = cfg.getAttributes();
        prop = getProperties((Set) map.get(ATTR_SERVER_CONFIG));
    }
    return prop;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) SystemProperties(com.iplanet.am.util.SystemProperties) Properties(java.util.Properties) HashMap(java.util.HashMap) Map(java.util.Map)

Example 18 with ServiceConfig

use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.

the class ServerConfiguration method getServers.

/**
     * Returns a set of server instance name (String).
     *
     * @param ssoToken Single Sign-On Token which is used to query the service
     *        management datastore.
     * @return a set of server instance name.
     * @throws SMSException if errors access in the service management
     *         datastore.
     * @throws SSOException if the <code>ssoToken</code> is not valid.
     */
public static Set<String> getServers(SSOToken ssoToken) throws SMSException, SSOException {
    Set<String> servers = new HashSet<>();
    ServiceConfig sc = getRootServerConfig(ssoToken);
    if (sc != null) {
        servers.addAll(sc.getSubConfigNames("*"));
        servers.remove(DEFAULT_SERVER_CONFIG);
    }
    return servers;
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) HashSet(java.util.HashSet)

Example 19 with ServiceConfig

use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.

the class ServerConfiguration method getServerConfigXML.

/**
     * Returns server configuration XML.
     *
     * @param ssoToken Single Sign-On Token which is used to access to the
     *        service management datastore.
     * @param instanceName Name of the server instance.
     * @return server configuration XML.
     * @throws SMSException if errors access in the service management
     *         datastore.
     * @throws SSOException if the <code>ssoToken</code> is not valid.
     */
public static String getServerConfigXML(SSOToken ssoToken, String instanceName) throws SMSException, SSOException {
    String xml = null;
    ServiceConfig cfg = getServerConfig(ssoToken, instanceName);
    if (cfg != null) {
        Map map = cfg.getAttributes();
        Set set = (Set) map.get(ATTR_SERVER_CONFIG_XML);
        xml = (String) set.iterator().next();
    }
    return xml;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with ServiceConfig

use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.

the class SiteConfiguration method getSitePrimaryURL.

/**
     * Returns the primary URL of a site.
     *
     * @param ssoToken Single Sign-On Token which is used to access to the
     *        service management datastore.
     * @param siteName Name of the site.
     * @return the primary URL of a site.
     * @throws SMSException if errors access in the service management
     *         datastore.
     * @throws SSOException if the <code>ssoToken</code> is not valid.
     */
public static String getSitePrimaryURL(SSOToken ssoToken, String siteName) throws SMSException, SSOException {
    ServiceConfig rootNode = getRootSiteConfig(ssoToken);
    ServiceConfig sc = rootNode.getSubConfig(siteName);
    ServiceConfig accessPoint = sc.getSubConfig(SUBCONFIG_ACCESS_URL);
    Map map = accessPoint.getAttributes();
    Set set = (Set) map.get(ATTR_PRIMARY_SITE_URL);
    return (String) set.iterator().next();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ServiceConfig (com.sun.identity.sm.ServiceConfig)285 SMSException (com.sun.identity.sm.SMSException)180 Set (java.util.Set)144 SSOException (com.iplanet.sso.SSOException)143 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)124 HashSet (java.util.HashSet)119 Map (java.util.Map)101 HashMap (java.util.HashMap)96 SSOToken (com.iplanet.sso.SSOToken)52 Iterator (java.util.Iterator)41 IdRepoException (com.sun.identity.idm.IdRepoException)27 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)22 EntitlementException (com.sun.identity.entitlement.EntitlementException)19 LinkedHashSet (java.util.LinkedHashSet)18 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)17 CLIException (com.sun.identity.cli.CLIException)16 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)16 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)13 ServiceNotFoundException (com.sun.identity.sm.ServiceNotFoundException)13 ServiceSchema (com.sun.identity.sm.ServiceSchema)12