Search in sources :

Example 1 with SchemaType

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

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

the class PropertyXMLBuilder method getSectionsForType.

private void getSectionsForType() {
    sectionForType = new HashMap<SchemaType, List<String>>();
    for (SchemaType schemaType : schemaTypes) {
        String name = "sections." + serviceName + "." + schemaType.getType();
        String section = model.getLocalizedString(name);
        if (section.equals(name)) {
            continue;
        }
        StringTokenizer st = new StringTokenizer(section, " ");
        List<String> sections = new ArrayList<String>();
        while (st.hasMoreTokens()) {
            sections.add(st.nextToken());
        }
        sectionForType.put(schemaType, sections);
    }
    if (debug.messageEnabled()) {
        debug.message("getSectionsForType: " + sectionForType);
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) SchemaType(com.sun.identity.sm.SchemaType)

Example 3 with SchemaType

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

the class PropertyXMLBuilder method getXML.

/**
     * Returns a XML for displaying attribute in property sheet.
     *
     * @param readonly Set of readonly attributes.
     * @param bPropertySheetElementNode true to include
     *        <code>&lt;propertysheet&gt;</code> tag.
     * @throws SMSException if attribute schema cannot obtained.
     * @throws SSOException if single sign on token is invalid.
     * @throws AMConsoleException if there are no attribute to display.
     * @return XML for displaying attribute in property sheet.
     */
public String getXML(Set readonly, boolean bPropertySheetElementNode) throws SMSException, SSOException, AMConsoleException {
    StringBuffer xml = new StringBuffer(1000);
    onBeforeBuildingXML(mapTypeToAttributeSchema);
    if (bPropertySheetElementNode) {
        xml.append(getXMLDefinitionHeader()).append(START_TAG);
    }
    if (supportSubConfig) {
        String configTable = SUB_CONFIG_TABLE_XML;
        configTable = tagSwap(configTable, SUB_CONFIG_TABLE_VIEW_BEAN, viewBeanName);
        xml.append(configTable);
    }
    if (!supportSubConfig && hasNoAttributes()) {
        throw new AMConsoleException(model.getLocalizedString("propertysheet.no.attributes.message"));
    }
    Set attributeSchema = (Set) mapTypeToAttributeSchema.get(NULL_TYPE);
    if ((attributeSchema != null) && !attributeSchema.isEmpty()) {
        String display = "blank.header";
        SchemaType type = null;
        if ((schemaTypes != null) && (schemaTypes.size() == 1)) {
            Iterator<SchemaType> it = schemaTypes.iterator();
            type = it.next();
        }
        if (getSectionsForType(type) == null) {
            buildSchemaTypeXML(display, attributeSchema, xml, model, serviceBundle, readonly);
        } else {
            String label = "lbl" + display.replace('.', '_');
            Object[] params = { label, display };
            xml.append(MessageFormat.format(SECTION_START_TAG, params));
            for (String section : sectionForType.get(type)) {
                String sectionName = model.getLocalizedString("section.label." + serviceName + "." + type.getType() + "." + section);
                buildSchemaTypeXML(sectionName, attributeSchema, xml, model, serviceBundle, readonly, sectionOrder.get(section));
            }
            xml.append(SECTION_END_TAG);
        }
    }
    for (Iterator iter = orderDisplaySchemaType.iterator(); iter.hasNext(); ) {
        SchemaType type = (SchemaType) iter.next();
        attributeSchema = (Set) mapTypeToAttributeSchema.get(type);
        if ((attributeSchema != null) && !attributeSchema.isEmpty()) {
            String display = model.getLocalizedString((String) mapSchemaTypeToName.get(type));
            if (getSectionsForType(type) == null) {
                buildSchemaTypeXML(display, attributeSchema, xml, model, serviceBundle, readonly);
            } else {
                String label = "lbl" + display.replace('.', '_');
                Object[] params = { label, display };
                xml.append(MessageFormat.format(SECTION_START_TAG, params));
                for (String section : sectionForType.get(type)) {
                    String sectionName = model.getLocalizedString("section.label." + serviceName + "." + type.getType() + "." + section);
                    buildSchemaTypeXML(sectionName, attributeSchema, xml, model, serviceBundle, readonly, sectionOrder.get(section));
                }
                xml.append(SECTION_END_TAG);
            }
        }
    }
    if (bPropertySheetElementNode) {
        xml.append(END_TAG);
    }
    return xml.toString();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) SchemaType(com.sun.identity.sm.SchemaType)

Example 4 with SchemaType

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

the class SCUtils method getLocalizedServiceName.

public static String getLocalizedServiceName(String serviceName, Locale locale) throws SMSException, SSOException, MissingResourceException {
    String localizedName = null;
    ServiceSchemaManager mgr = new ServiceSchemaManager(serviceName, adminSSOToken);
    ResourceBundle rb = ResourceBundle.getBundle(mgr.getI18NFileName(), locale);
    Set types = mgr.getSchemaTypes();
    if (!types.isEmpty()) {
        SchemaType type = (SchemaType) types.iterator().next();
        ServiceSchema schema = mgr.getSchema(type);
        if (schema != null) {
            String i18nKey = schema.getI18NKey();
            if ((i18nKey != null) && (i18nKey.trim().length() > 0)) {
                localizedName = rb.getString(i18nKey);
            }
        }
    }
    return localizedName;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) ResourceBundle(java.util.ResourceBundle) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) SchemaType(com.sun.identity.sm.SchemaType)

Example 5 with SchemaType

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

the class AMStoreConnection method getAttributeNames.

/**
     * Returns the service attribute names for a given service name and schema
     * type.
     * 
     * @param serviceName
     *            the name of the service
     * @param schemaType
     *            the type of service schema
     * @return Set of service attribute names
     * @throws AMException
     *             if an error is encountered while retrieving information.
     * @deprecated use <code>com.sun.identity.sm.ServiceSchemaManager.
     * getServiceAttributeNames(com.sun.identity.sm.SchemaType)</code>
     */
public Set getAttributeNames(String serviceName, AMSchema.Type schemaType) throws AMException {
    try {
        ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, token);
        SchemaType st = schemaType.getInternalSchemaType();
        return ssm.getServiceAttributeNames(st);
    } catch (SSOException se) {
        AMCommonUtils.debug.message("AMStoreConnection.getAttributeNames(String, " + "AMSchema.Type)", se);
        throw new AMException(AMSDKBundle.getString("902", locale), "902");
    } catch (SMSException se) {
        AMCommonUtils.debug.message("AMStoreConnection.getAttributeNames(String, " + "AMSchema.Type)", se);
        throw new AMException(AMSDKBundle.getString("911", locale), "911");
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) SchemaType(com.sun.identity.sm.SchemaType)

Aggregations

SchemaType (com.sun.identity.sm.SchemaType)17 Set (java.util.Set)12 ServiceSchema (com.sun.identity.sm.ServiceSchema)9 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)9 HashSet (java.util.HashSet)9 SMSException (com.sun.identity.sm.SMSException)8 Iterator (java.util.Iterator)8 SSOException (com.iplanet.sso.SSOException)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 AttributeSchema (com.sun.identity.sm.AttributeSchema)3 AMHashMap (com.iplanet.am.sdk.AMHashMap)2 SSOToken (com.iplanet.sso.SSOToken)2 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)2 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)2 IdType (com.sun.identity.idm.IdType)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ResourceBundle (java.util.ResourceBundle)2 StringTokenizer (java.util.StringTokenizer)2