Search in sources :

Example 91 with ServiceSchema

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

the class AuthUtils method getGlobalAttributes.

/**
      * Returns <code>Map</code> attributes
      *
      * @param serviceName Service Name
      * @return <code>Map</code> of global attributes.
      */
public static Map getGlobalAttributes(String serviceName) {
    Map attrs = null;
    try {
        SSOToken dUserToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
        ServiceSchemaManager scm = new ServiceSchemaManager(serviceName, dUserToken);
        ServiceSchema schema = scm.getGlobalSchema();
        if (schema != null) {
            attrs = schema.getAttributeDefaults();
        }
    } catch (SMSException smsExp) {
        utilDebug.error("AuthUtils.getGlobalAttributes: SMS Error", smsExp);
    } catch (SSOException ssoExp) {
        utilDebug.error("AuthUtils.getGlobalAttributes: SSO Error", ssoExp);
    }
    if (utilDebug.messageEnabled()) {
        utilDebug.message("AuthUtils.getGlobalAttributes: attrs=" + attrs);
    }
    return attrs;
}
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 92 with ServiceSchema

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

the class AuthD method updateAuthServiceGlobals.

/**
     * Update the AuthService global and organization settings.
     * most of the code is moved in from AuthenticatorManager.java.
     * @param scm <code>ServiceSchemaManager</code> to be used for update
     * @throws SMSException if it fails to update auth service
     * @throws Exception
     */
synchronized void updateAuthServiceGlobals(ServiceSchemaManager scm) throws Exception {
    ServiceSchema schema = scm.getOrganizationSchema();
    Map attrs = schema.getAttributeDefaults();
    // get Global type attributes for iPlanetAMAuthService
    schema = scm.getGlobalSchema();
    attrs.putAll(schema.getAttributeDefaults());
    if (debug.messageEnabled()) {
        debug.message("attrs : " + attrs);
    }
    adminAuthModule = CollectionHelper.getMapAttr(attrs, ISAuthConstants.ADMIN_AUTH_MODULE);
    defaultAuthLevel = CollectionHelper.getMapAttr(attrs, ISAuthConstants.DEFAULT_AUTH_LEVEL, DEFAULT_AUTH_LEVEL);
    Set s = (Set) attrs.get(ISAuthConstants.AUTHENTICATORS);
    for (final Object value : s) {
        String name = (String) value;
        int dot = name.lastIndexOf('.');
        if (dot > -1) {
            String tmp = name.substring(dot + 1, name.length());
            authMethods.put(tmp, name);
        } else {
            authMethods.put(name, name);
        }
    }
    if (debug.messageEnabled()) {
        debug.message("AM.update authMethods = " + authMethods.toString());
    }
    defaultSuccessURLSet = (Set) attrs.get(ISAuthConstants.LOGIN_SUCCESS_URL);
    defaultFailureURLSet = (Set) attrs.get(ISAuthConstants.LOGIN_FAILURE_URL);
    if (debug.messageEnabled()) {
        debug.message("Default Success URL Set = " + defaultSuccessURLSet);
        debug.message("Default Failure URL Set = " + defaultFailureURLSet);
    }
    Integer sleepTime = new Integer(CollectionHelper.getMapAttr(attrs, ISAuthConstants.SLEEP_INTERVAL));
    defaultSleepTime = sleepTime.longValue();
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 93 with ServiceSchema

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

the class EventService method isAMSDKConfigured.

private static boolean isAMSDKConfigured() {
    boolean isAMSDKConfigured = false;
    boolean configTime = isDuringConfigurationTime();
    logger.message("EventService.getListenerList(): {}: {}", Constants.SYS_PROPERTY_INSTALL_TIME, configTime);
    if (!configTime) {
        try {
            ServiceSchemaManager scm = new ServiceSchemaManager(AccessController.doPrivileged(AdminTokenAction.getInstance()), IdConstants.REPO_SERVICE, "1.0");
            ServiceSchema idRepoSubSchema = scm.getOrganizationSchema();
            Set idRepoPlugins = idRepoSubSchema.getSubSchemaNames();
            if (idRepoPlugins.contains("amSDK")) {
                isAMSDKConfigured = true;
            }
        } catch (SMSException ex) {
            logger.warning("EventService.getListenerList() - Unable to obtain idrepo service", ex);
        } catch (SSOException ex) {
        // Should not happen, ignore the exception
        }
    }
    return isAMSDKConfigured;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 94 with ServiceSchema

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

the class AbstractAuditModel method getAddEventHandlerPropertyXML.

/**
     * Get the JATO XML configuration for generation the UI used to add event handlers.
     *
     * @param schemaId The event handler schema ID.
     * @return The JATO XML configuration for generation the UI.
     * @throws AMConsoleException If an error occurs during the XML creation.
     */
public String getAddEventHandlerPropertyXML(String schemaId) throws AMConsoleException {
    try {
        ServiceSchema handlerSchema = getServiceSchema().getSubSchema(schemaId);
        updateHandlerResourceBundle(handlerSchema);
        xmlBuilder = new PropertyXMLBuilder(handlerSchema, this, handlerResourceBundle, getSectionsForHandler(schemaId), schemaId + SECTION_FILE_NAME_SUFFIX);
        xmlBuilder.setSupportSubConfig(false);
        String xml = xmlBuilder.getXML();
        String attributeNameXML = AMAdminUtils.getStringFromInputStream(getClass().getClassLoader().getResourceAsStream("com/sun/identity/console/propertyAuditEventHandlerName.xml"));
        return PropertyXMLBuilder.prependXMLProperty(xml, attributeNameXML);
    } catch (SMSException | SSOException e) {
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) PropertyXMLBuilder(com.sun.identity.console.property.PropertyXMLBuilder)

Example 95 with ServiceSchema

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

the class AbstractAuditModel method getEventHandlerDefaultValues.

/**
     * Get the default attribute values for the specified event handler type (schema ID).
     *
     * @param eventHandlerType The name of the event handler type.
     * @return A map of default event handler attribute values.
     * @throws AMConsoleException If an error occurs whilst reading the attributes.
     */
public Map<String, Set<?>> getEventHandlerDefaultValues(String eventHandlerType) throws AMConsoleException {
    try {
        Map<String, Set<?>> defaultValues = new HashMap<>();
        ServiceSchema handlerSchema = getServiceSchema().getSubSchema(eventHandlerType);
        Set attributeSchemas = handlerSchema.getAttributeSchemas();
        for (Object value : attributeSchemas) {
            AttributeSchema as = (AttributeSchema) value;
            Set values = as.getDefaultValues();
            if (values != null) {
                defaultValues.put(as.getName(), values);
            }
        }
        return defaultValues;
    } catch (SSOException | SMSException e) {
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

ServiceSchema (com.sun.identity.sm.ServiceSchema)216 SMSException (com.sun.identity.sm.SMSException)152 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)131 SSOException (com.iplanet.sso.SSOException)117 Set (java.util.Set)101 AttributeSchema (com.sun.identity.sm.AttributeSchema)76 HashSet (java.util.HashSet)71 Map (java.util.Map)70 HashMap (java.util.HashMap)57 Iterator (java.util.Iterator)56 CLIException (com.sun.identity.cli.CLIException)46 SSOToken (com.iplanet.sso.SSOToken)27 IOutput (com.sun.identity.cli.IOutput)26 BeforeTest (org.testng.annotations.BeforeTest)22 CLIRequest (com.sun.identity.cli.CLIRequest)21 ByteString (org.forgerock.opendj.ldap.ByteString)21 AfterTest (org.testng.annotations.AfterTest)21 Test (org.testng.annotations.Test)21 Parameters (org.testng.annotations.Parameters)18 TreeSet (java.util.TreeSet)15