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);
}
}
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);
}
}
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><propertysheet></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();
}
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;
}
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");
}
}
Aggregations