Search in sources :

Example 6 with SchemaType

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

the class IdRepoJAXRPCObjectImpl method assignService_idrepo.

public void assignService_idrepo(String token, String type, String name, String serviceName, String stype, Map attrMap, String amOrgName, String amsdkDN) throws RemoteException, IdRepoException, SSOException {
    SSOToken ssoToken = getSSOToken(token);
    IdType idtype = IdUtils.getType(type);
    SchemaType schemaType = new SchemaType(stype);
    idServices.assignService(ssoToken, idtype, name, serviceName, schemaType, attrMap, amOrgName, amsdkDN);
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SchemaType(com.sun.identity.sm.SchemaType) IdType(com.sun.identity.idm.IdType)

Example 7 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 8 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 9 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 10 with SchemaType

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

the class AMModelBase method getLocalizedServiceName.

/**
     * Returns the localized service name.
     *
     * @param service Name of service.
     * @param defaultValue Default value of service name if localized service
     *        name cannot be determine.
     * @return the localized service name.
     */
public String getLocalizedServiceName(String service, String defaultValue) {
    String i18nName = defaultValue;
    try {
        ServiceSchemaManager mgr = new ServiceSchemaManager(service, ssoToken);
        String rbName = mgr.getI18NFileName();
        if ((rbName != null) && (rbName.trim().length() > 0)) {
            ResourceBundle rb = AMResBundleCacher.getBundle(rbName, locale);
            String i18nKey = null;
            Set types = mgr.getSchemaTypes();
            if (!types.isEmpty()) {
                SchemaType type = (SchemaType) types.iterator().next();
                ServiceSchema schema = mgr.getSchema(type);
                if (schema != null) {
                    i18nKey = schema.getI18NKey();
                }
            }
            if ((i18nKey != null) && (i18nKey.length() > 0)) {
                i18nName = Locale.getString(rb, i18nKey, debug);
            }
        }
    } catch (SSOException e) {
        debug.warning("AMModelBase.getLocalizedServiceName", e);
    } catch (SMSException e) {
        debug.warning("AMModelBase.getLocalizedServiceName", e);
    } catch (MissingResourceException e) {
        debug.warning("AMModelBase.getLocalizedServiceName", e);
    }
    return i18nName;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) MissingResourceException(java.util.MissingResourceException) ResourceBundle(java.util.ResourceBundle) 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