use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class FederationPlugin method setSAMLSiteID.
private void setSAMLSiteID(SSOToken adminSSOToken) {
try {
ServiceSchemaManager mgr = new ServiceSchemaManager("iPlanetAMSAMLService", adminSSOToken);
ServiceSchema ss = mgr.getSchema(SchemaType.GLOBAL);
Map values = ss.getAttributeDefaults();
Set siteIDs = (Set) values.get("iplanet-am-saml-siteid-issuername-list");
if (siteIDs != null && !siteIDs.isEmpty()) {
String siteID = (String) siteIDs.iterator().next();
int idPos = siteID.indexOf("=" + ATTR_KEY_SAML_SITEID + "|");
if (idPos != -1) {
Map defaults = ServicesDefaultValues.getDefaultValues();
String protocol = (String) defaults.get(SetupConstants.CONFIG_VAR_SERVER_PROTO);
String hostname = (String) defaults.get(SetupConstants.CONFIG_VAR_SERVER_HOST);
String port = (String) defaults.get(SetupConstants.CONFIG_VAR_SERVER_PORT);
String encoded = SAMLSiteID.generateSourceID(protocol + "://" + hostname + ":" + port);
siteIDs.remove(siteID);
siteID = siteID.substring(0, idPos + 1) + encoded + siteID.substring(idPos + ATTR_KEY_SAML_SITEID.length() + 1);
siteIDs.add(siteID);
ss.setAttributeDefaults(values);
}
}
} catch (SSOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (SMSException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class SMDiscoveryServiceModelImpl method addMoreAttributeSchemasForModification.
protected void addMoreAttributeSchemasForModification(Set attributeSchemas) {
super.addMoreAttributeSchemasForModification(attributeSchemas);
ServiceSchemaManager mgr = getServiceSchemaManager();
try {
ServiceSchema global = mgr.getSchema(SchemaType.GLOBAL);
attributeSchemas.add(global.getAttributeSchema(AMAdminConstants.DISCOVERY_SERVICE_NAME_BOOTSTRAP_RES_OFF));
} catch (SMSException e) {
debug.error("SMDiscoveryServiceModelImpl.addMoreAttributeSchemasForModification", e);
}
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class SMDiscoveryServiceModelImpl method getDiscoEntry.
/**
* Returns resource offering entry stored in the model map for a given
* type.
*
* @param dynamic value to indicate if it is a dynamic or not.
* @return resource offering entry stored in the model map for a given
* type.
*/
public Set getDiscoEntry(boolean dynamic) {
Set set = null;
if (dynamic) {
// TO FIX
} else {
ServiceSchemaManager mgr = getServiceSchemaManager();
try {
ServiceSchema schema = mgr.getSchema(SchemaType.GLOBAL);
AttributeSchema as = schema.getAttributeSchema(AMAdminConstants.DISCOVERY_SERVICE_NAME_BOOTSTRAP_RES_OFF);
set = as.getDefaultValues();
} catch (SMSException e) {
debug.error("SMDiscoveryServiceModelImpl.getDiscoEntry", e);
}
}
return set;
}
use of com.sun.identity.sm.ServiceSchema 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.ServiceSchema in project OpenAM by OpenRock.
the class SCModelBase method setAttributeValues.
/**
* Sets the attribute values for the specified schema type.
*/
protected void setAttributeValues(SchemaType type, Map values) throws AMConsoleException {
String serviceName = getServiceName();
String attributeNames = AMAdminUtils.getString(values.keySet(), ",", false);
String[] params = { serviceName, type.getType(), attributeNames };
logEvent("ATTEMPT_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", params);
try {
ServiceSchema schema = getServiceSchemaManager().getSchema(type);
schema.setAttributeDefaults(values);
logEvent("SUCCEED_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", params);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { serviceName, type.getType(), attributeNames, 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 = { serviceName, type.getType(), attributeNames, strError };
logEvent("SMS_EXCEPTION_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", paramsEx);
throw new AMConsoleException(strError);
}
}
Aggregations