Search in sources :

Example 16 with ServiceSchemaManager

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

the class AMAuthenticationManager method getAuthenticationSchema.

private static AMAuthenticationSchema getAuthenticationSchema(String authType, SSOToken token) throws AMConfigurationException {
    if (DEBUG.messageEnabled()) {
        DEBUG.message("getting auth schema for " + authType);
    }
    try {
        ServiceSchema serviceSchema;
        String serviceName = getServiceName(authType);
        ServiceSchemaManager scm = new ServiceSchemaManager(serviceName, token);
        ServiceSchema orgSchema = scm.getOrganizationSchema();
        ServiceSchema subSchema = orgSchema.getSubSchema(ISAuthConstants.SERVER_SUBSCHEMA);
        if (subSchema != null) {
            // using the sub schema in new auth config.
            serviceSchema = subSchema;
        } else {
            // fall back to the org schema if the DIT is old.
            serviceSchema = orgSchema;
        }
        AMAuthenticationSchema amschema = new AMAuthenticationSchema(serviceSchema);
        return amschema;
    } catch (Exception e) {
        throw new AMConfigurationException(e);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException)

Example 17 with ServiceSchemaManager

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

the class FSSAMLServiceModelImpl method init.

private void init() {
    String curSchemaType = "*";
    try {
        serviceSchemaManager = new ServiceSchemaManager(SAML_SERVICE_NAME, getUserSSOToken());
        String i18nFileName = serviceSchemaManager.getI18NFileName();
        if ((i18nFileName != null) && (i18nFileName.trim().length() > 0)) {
            resBundle = AMResBundleCacher.getBundle(i18nFileName, getUserLocale());
        }
        String[] params = new String[3];
        params[0] = SAML_SERVICE_NAME;
        params[2] = "*";
        Set schemaTypes = serviceSchemaManager.getSchemaTypes();
        for (Iterator iter = schemaTypes.iterator(); iter.hasNext(); ) {
            SchemaType type = (SchemaType) iter.next();
            ServiceSchema schema = serviceSchemaManager.getSchema(type);
            if (schema != null) {
                curSchemaType = type.getType();
                params[1] = curSchemaType;
                logEvent("ATTEMPT_GET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", params);
                Set aschemas = schema.getAttributeSchemas();
                for (Iterator i = aschemas.iterator(); i.hasNext(); ) {
                    AttributeSchema as = (AttributeSchema) i.next();
                    String i18n = as.getI18NKey();
                    if ((i18n != null) && (i18n.trim().length() > 0)) {
                        attributeSchemas.put(as.getName(), as);
                    }
                }
                logEvent("SUCCEED_GET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", params);
            }
        }
    } catch (SSOException e) {
        String[] paramsEx = { SAML_SERVICE_NAME, "*", curSchemaType, getErrorString(e) };
        logEvent("SSO_EXCEPTION_GET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", paramsEx);
        debug.error("FSSAMLServiceModelImpl.init", e);
    } catch (SMSException e) {
        String[] paramsEx = { SAML_SERVICE_NAME, "*", curSchemaType, getErrorString(e) };
        logEvent("SMS_EXCEPTION_GET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", paramsEx);
        debug.error("FSSAMLServiceModelImpl.init", e);
    }
}
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) SchemaType(com.sun.identity.sm.SchemaType)

Example 18 with ServiceSchemaManager

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

the class IDRepoModelImpl method getIDRepoTypesMap.

/**
     * Returns map of ID Repo type name to its localized string.
     *
     * @return map of ID Repo type name to its localized string.
     */
public Map getIDRepoTypesMap() throws AMConsoleException {
    try {
        ServiceSchemaManager schemaMgr = new ServiceSchemaManager(IdConstants.REPO_SERVICE, getUserSSOToken());
        ResourceBundle rb = AMResBundleCacher.getBundle(schemaMgr.getI18NFileName(), getUserLocale());
        ServiceSchema orgSchema = schemaMgr.getOrganizationSchema();
        Set names = orgSchema.getSubSchemaNames();
        Map map = new HashMap(names.size() * 2);
        for (Iterator iter = names.iterator(); iter.hasNext(); ) {
            String name = (String) iter.next();
            ServiceSchema ss = orgSchema.getSubSchema(name);
            String i18nKey = ss.getI18NKey();
            if ((i18nKey != null) && (i18nKey.trim().length() > 0)) {
                map.put(name, Locale.getString(rb, i18nKey, debug));
            }
        }
        return map;
    } catch (SMSException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) Iterator(java.util.Iterator) ResourceBundle(java.util.ResourceBundle) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 19 with ServiceSchemaManager

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

the class IDRepoModelImpl method getPropertyXMLString.

/**
     * Returns property sheet XML for ID Repo Profile.
     *
     * @param realmName Name of Realm.
     * @param viewbeanClassName Class Name of View Bean.
     * @param type Type of ID Repo.
     * @param bCreate <code>true</code> for creation operation.
     * @return property sheet XML for ID Repo Profile.
     */
public String getPropertyXMLString(String realmName, String viewbeanClassName, String type, boolean bCreate) throws AMConsoleException {
    try {
        ServiceSchemaManager schemaMgr = new ServiceSchemaManager(IdConstants.REPO_SERVICE, getUserSSOToken());
        ServiceSchema orgSchema = schemaMgr.getOrganizationSchema();
        ServiceSchema ss = orgSchema.getSubSchema(type);
        DelegationConfig dConfig = DelegationConfig.getInstance();
        boolean canModify = dConfig.hasPermission(realmName, null, AMAdminConstants.PERMISSION_MODIFY, this, viewbeanClassName);
        Set attributeSchemas = ss.getAttributeSchemas();
        PropertyXMLBuilder.removeAttributeSchemaWithoutI18nKey(attributeSchemas);
        PropertyXMLBuilder builder = new PropertyXMLBuilder(IdConstants.REPO_SERVICE, this, attributeSchemas, SchemaType.ORGANIZATION);
        if (!bCreate && !canModify) {
            builder.setAllAttributeReadOnly(true);
        }
        String xml = builder.getXML();
        String xmlFile = (bCreate) ? "com/sun/identity/console/propertyRMIDRepoAdd.xml" : "com/sun/identity/console/propertyRMIDRepoEdit.xml";
        String header = AMAdminUtils.getStringFromInputStream(getClass().getClassLoader().getResourceAsStream(xmlFile));
        xml = PropertyXMLBuilder.prependXMLProperty(xml, header);
        return xml;
    } catch (SMSException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) DelegationConfig(com.sun.identity.console.delegation.model.DelegationConfig) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) PropertyXMLBuilder(com.sun.identity.console.property.PropertyXMLBuilder) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 20 with ServiceSchemaManager

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

the class AuthenticationModuleCollectionHandler method getSchemaManager.

private ServiceSchemaManager getSchemaManager(String authType) throws SSOException, SMSException, AMConfigurationException {
    AMAuthenticationManager authenticationManager = new AMAuthenticationManager(adminToken, "/");
    AMAuthenticationSchema schema = authenticationManager.getAuthenticationSchema(authType);
    return new ServiceSchemaManager(schema.getServiceName(), adminToken);
}
Also used : AMAuthenticationSchema(com.sun.identity.authentication.config.AMAuthenticationSchema) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

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