Search in sources :

Example 41 with ServiceSchemaManager

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

the class AuthClientUtils method getCookieDomains.

/**
     * Return the set of cookie domains configured in Platform settings. Whenever possible, use
     * {@link #getCookieDomainsForRequest(HttpServletRequest)} instead.
     *
     * @return The set of configured cookie domains. May contain null.
     */
public static Set<String> getCookieDomains() {
    Set<String> cookieDomains = Collections.EMPTY_SET;
    try {
        SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance());
        try {
            ServiceSchemaManager scm = new ServiceSchemaManager("iPlanetAMPlatformService", token);
            ServiceSchema psc = scm.getGlobalSchema();
            Map attrs = psc.getAttributeDefaults();
            cookieDomains = (Set) attrs.get(ISAuthConstants.PLATFORM_COOKIE_DOMAIN_ATTR);
        } catch (SMSException ex) {
            // Ignore the exception and leave cookieDomains empty;
            utilDebug.message("getCookieDomains - SMSException ");
        }
        if (cookieDomains == null) {
            cookieDomains = Collections.singleton(null);
        }
    } catch (SSOException ex) {
        // unable to get SSOToken
        utilDebug.message("getCookieDomains - SSOException ");
    }
    if (utilDebug.messageEnabled() && (!cookieDomains.isEmpty())) {
        StringBuilder message = new StringBuilder("CookieDomains : ");
        for (String cookieDomain : cookieDomains) {
            message.append("  '").append(cookieDomain).append("'");
        }
        utilDebug.message(message.toString());
    }
    return cookieDomains;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) Map(java.util.Map) HashMap(java.util.HashMap) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 42 with ServiceSchemaManager

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

the class EntitiesModelImpl method getPropertiesViewBean.

/**
     * Returns properties view bean URL for an attribute schema.
     *
     * @param name Name of attribute schema.
     * @return properties view bean URL for an attribute schema.
     */
public String getPropertiesViewBean(String name) {
    String url = null;
    try {
        ServiceSchemaManager mgr = new ServiceSchemaManager(name, adminSSOToken);
        ServiceSchema schema = mgr.getSchema(SchemaType.USER);
        Set attributeSchemas = schema.getAttributeSchemas();
        for (Iterator i = attributeSchemas.iterator(); i.hasNext() && (url == null); ) {
            AttributeSchema as = (AttributeSchema) i.next();
            if (as.getName().equals(name)) {
                url = as.getPropertiesViewBeanURL();
            }
        }
    } catch (SMSException e) {
        debug.warning("EntitiesModelImpl.getDefaultValues", e);
    } catch (SSOException e) {
        debug.warning("EntitiesModelImpl.getDefaultValues", e);
    }
    return url;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 43 with ServiceSchemaManager

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

the class EntitiesModelImpl method hasAttributeSchema.

private boolean hasAttributeSchema(String serviceName, SchemaType type) {
    boolean hasAttributes = false;
    try {
        ServiceSchemaManager mgr = new ServiceSchemaManager(serviceName, getUserSSOToken());
        ServiceSchema schema = mgr.getSchema(type);
        if (schema != null) {
            Set attributeSchemas = schema.getAttributeSchemas();
            if ((attributeSchemas != null) && !attributeSchemas.isEmpty()) {
                hasAttributes = hasI18nKeys(attributeSchemas);
            }
        }
    } catch (SMSException e) {
        debug.warning("EntitiesModelImpl.hasAttributeSchema", e);
    } catch (SSOException e) {
        debug.warning("EntitiesModelImpl.hasAttributeSchema", e);
    }
    return hasAttributes;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 44 with ServiceSchemaManager

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

the class AMSDKRepo method getDefaultAgentContainerName.

private String getDefaultAgentContainerName() {
    String gcName = "Agent";
    try {
        ServiceSchemaManager ssm = new ServiceSchemaManager(ADMIN_SERVICE, adminToken);
        if (ssm != null) {
            ServiceSchema ss = ssm.getGlobalSchema();
            if (ss != null) {
                Map attrs = ss.getAttributeDefaults();
                Set vals = (Set) attrs.get(AC_ATTR);
                if (vals != null && !vals.isEmpty())
                    gcName = (String) vals.iterator().next();
            }
        }
    } catch (SMSException smse) {
        debug.error("AMSDKRepo.getDefaultAC: SMSException: ", smse);
    } catch (SSOException ssoe) {
        debug.error("AMSDKRepo.getDefaultAC: SSOException", ssoe);
    }
    return gcName;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) Map(java.util.Map) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 45 with ServiceSchemaManager

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

the class AMServiceUtils method getServiceAttributeNames.

/**
     * Get attribute names for the specified Service and Schema Type
     * 
     * @param token
     *            SSOToken a valid SSOToken
     * @param serviceName
     *            the service name
     * @param type
     *            the SchemaType
     * @return the Set of attribute names for that specified Service and Schema
     *         Type
     */
protected static Set getServiceAttributeNames(SSOToken token, String serviceName, SchemaType type) throws SMSException, SSOException {
    ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, token);
    ServiceSchema ss = null;
    try {
        ss = ssm.getSchema(type);
    } catch (SMSException sme) {
        if (debug.warningEnabled()) {
            debug.warning("AMServiceUtils.getServiceAttributeNames():" + " No schema defined for " + type);
        }
    }
    if ((ss == null) || (type == SchemaType.POLICY)) {
        return Collections.EMPTY_SET;
    }
    return ss.getAttributeSchemaNames();
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Aggregations

ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)209 SMSException (com.sun.identity.sm.SMSException)146 ServiceSchema (com.sun.identity.sm.ServiceSchema)131 SSOException (com.iplanet.sso.SSOException)119 Set (java.util.Set)87 HashSet (java.util.HashSet)60 Map (java.util.Map)56 HashMap (java.util.HashMap)49 AttributeSchema (com.sun.identity.sm.AttributeSchema)46 SSOToken (com.iplanet.sso.SSOToken)43 Iterator (java.util.Iterator)40 CLIException (com.sun.identity.cli.CLIException)33 BeforeTest (org.testng.annotations.BeforeTest)27 AfterTest (org.testng.annotations.AfterTest)26 Test (org.testng.annotations.Test)26 CLIRequest (com.sun.identity.cli.CLIRequest)25 Parameters (org.testng.annotations.Parameters)18 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)15 TreeSet (java.util.TreeSet)12 ByteString (org.forgerock.opendj.ldap.ByteString)11