Search in sources :

Example 86 with AttributeSchema

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

the class FSSAMLServiceModelImpl method deleteTrustPartners.

/**
     * delete trusted partners.
     *
     * @param values a Set of trusted partners .
     * @throws AMConsoleException if name cannot be set.
     */
public void deleteTrustPartners(Set values) throws AMConsoleException {
    String schemaName = SAML_TRUSTED_PARTNERS;
    String[] params = new String[3];
    params[0] = SAML_SERVICE_NAME;
    params[1] = "-";
    params[2] = schemaName;
    try {
        AttributeSchema as = (AttributeSchema) attributeSchemas.get(schemaName);
        Set orgValues = (Set) as.getDefaultValues();
        orgValues.removeAll(values);
        as.setDefaultValues(orgValues);
        logEvent("SUCCEED_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", params);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { SAML_SERVICE_NAME, "-", schemaName, strError };
        logEvent("SSO_EXCEPTION_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { SAML_SERVICE_NAME, "-", schemaName, strError };
        logEvent("SMS_EXCEPTION_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) 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)

Example 87 with AttributeSchema

use of com.sun.identity.sm.AttributeSchema 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 88 with AttributeSchema

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

the class RMRealmModelImpl method getDataMap.

/**
     * Returns Map of attribute name to empty set of values.
     *
     * @throws AMConsoleException if map cannot be obtained.
     */
public Map getDataMap() {
    Map map = new HashMap();
    try {
        OrganizationConfigManager orgMgr = new OrganizationConfigManager(getUserSSOToken(), "/");
        Set serviceSchemas = orgMgr.getServiceSchemas();
        for (Iterator iter = serviceSchemas.iterator(); iter.hasNext(); ) {
            ServiceSchema ss = (ServiceSchema) iter.next();
            String serviceName = ss.getServiceName();
            Set attrSchemas = ss.getAttributeSchemas();
            for (Iterator i = attrSchemas.iterator(); i.hasNext(); ) {
                AttributeSchema as = (AttributeSchema) i.next();
                map.put(serviceName + "_" + as.getName(), Collections.EMPTY_SET);
            }
        }
    } catch (SMSException e) {
        debug.error("RMRealmModelImpl.getDataMap", e);
    }
    return map;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashMap(java.util.HashMap) Map(java.util.Map)

Example 89 with AttributeSchema

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

the class RMRealmModelImpl method getDefaultValues.

/**
    * Returns Map of default attribute values used when creating
    * new realms. This only returns default values for single choice
    * type attributes. Returning other default values runs the risk
    * of violating the attribute uniqueness plugin while creating a 
    * new realm.
    *
    * @throws AMConsoleException if map cannot be obtained.
    */
public Map getDefaultValues() {
    Map map = new HashMap();
    try {
        OrganizationConfigManager orgMgr = new OrganizationConfigManager(getUserSSOToken(), "/");
        Set serviceSchemas = orgMgr.getServiceSchemas();
        for (Iterator iter = serviceSchemas.iterator(); iter.hasNext(); ) {
            ServiceSchema ss = (ServiceSchema) iter.next();
            String serviceName = ss.getServiceName();
            Set attrSchemas = ss.getAttributeSchemas();
            for (Iterator i = attrSchemas.iterator(); i.hasNext(); ) {
                AttributeSchema as = (AttributeSchema) i.next();
                if (as.getType() == AttributeSchema.Type.SINGLE_CHOICE) {
                    map.put(serviceName + "_" + as.getName(), as.getDefaultValues());
                }
            }
        }
    } catch (SMSException e) {
        debug.error("RMRealmModelImpl.getDefaultValues", e);
    }
    return map;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashMap(java.util.HashMap) Map(java.util.Map)

Example 90 with AttributeSchema

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

the class CreateDataStore method getDefaultAttributeValues.

private Map getDefaultAttributeValues(SSOToken adminSSOToken) throws SMSException, SSOException {
    ServiceSchemaManager schemaMgr = new ServiceSchemaManager(IdConstants.REPO_SERVICE, adminSSOToken);
    ServiceSchema orgSchema = schemaMgr.getOrganizationSchema();
    Set attrs = orgSchema.getAttributeSchemas();
    Map values = new HashMap(attrs.size() * 2);
    for (Iterator iter = attrs.iterator(); iter.hasNext(); ) {
        AttributeSchema as = (AttributeSchema) iter.next();
        values.put(as.getName(), as.getDefaultValues());
    }
    return values;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashMap(java.util.HashMap) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashMap(java.util.HashMap) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Aggregations

AttributeSchema (com.sun.identity.sm.AttributeSchema)149 Iterator (java.util.Iterator)80 ServiceSchema (com.sun.identity.sm.ServiceSchema)76 Set (java.util.Set)75 SMSException (com.sun.identity.sm.SMSException)67 HashSet (java.util.HashSet)59 SSOException (com.iplanet.sso.SSOException)58 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)46 HashMap (java.util.HashMap)36 Map (java.util.Map)34 CLIException (com.sun.identity.cli.CLIException)28 CLIRequest (com.sun.identity.cli.CLIRequest)18 AfterTest (org.testng.annotations.AfterTest)18 BeforeTest (org.testng.annotations.BeforeTest)18 Parameters (org.testng.annotations.Parameters)18 Test (org.testng.annotations.Test)18 IOutput (com.sun.identity.cli.IOutput)14 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)10 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)9 SSOToken (com.iplanet.sso.SSOToken)8