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);
}
}
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);
}
}
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));
}
}
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));
}
}
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);
}
Aggregations