use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class SchemaTest method setAttributeSchemaChoiceValues.
@Parameters({ "subschema" })
@Test(groups = { "schema", "set-attr-choicevals", "attribute-schema-ops", "subschema" })
public void setAttributeSchemaChoiceValues(String subschema) throws CLIException, SMSException, SSOException {
Object[] params = { subschema };
entering("setAttributeSchemaChoiceValues", params);
String[] args = (subschema.length() == 0) ? new String[9] : new String[11];
args[0] = "set-attr-choicevals";
args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME;
args[2] = TEST_SERVICE;
args[3] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SCHEMA_TYPE;
args[4] = "global";
args[5] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_NAME;
args[6] = "mock-single-choice";
args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.CHOICE_VALUES;
args[8] = "i18nKey1=choice1";
if (subschema.length() > 0) {
args[9] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUBSCHEMA_NAME;
args[10] = subschema;
}
CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
cmdManager.addToRequestQueue(req);
try {
cmdManager.serviceRequestQueue();
ServiceSchemaManager mgr = new ServiceSchemaManager(TEST_SERVICE, getAdminSSOToken());
ServiceSchema serviceSchema = mgr.getGlobalSchema();
if (subschema.length() > 0) {
serviceSchema = serviceSchema.getSubSchema(subschema);
}
AttributeSchema as = serviceSchema.getAttributeSchema("mock-single-choice");
String[] choiceValues = as.getChoiceValues();
assert (choiceValues.length == 1);
assert choiceValues[0].equals("choice1");
String i18nKey = as.getChoiceValueI18NKey("choice1");
assert i18nKey.equals("i18nKey1");
exiting("setAttributeSchemaChoiceValues");
} catch (CLIException e) {
this.log(Level.SEVERE, "setAttributeSchemaChoiceValues", e.getMessage());
throw e;
} catch (SMSException e) {
this.log(Level.SEVERE, "setAttributeSchemaChoiceValues", e.getMessage());
throw e;
} catch (SSOException e) {
this.log(Level.SEVERE, "setAttributeSchemaChoiceValues", e.getMessage());
throw e;
}
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class SchemaTest method removeSubSchema.
@Test(groups = { "schema", "remove-sub-schema" }, dependsOnMethods = { "addSubSchema" })
public void removeSubSchema() throws CLIException, SMSException, SSOException {
entering("removeSubSchema", null);
String[] args = { "remove-sub-schema", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, TEST_SERVICE, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SCHEMA_TYPE, "global", CLIConstants.PREFIX_ARGUMENT_LONG + RemoveSubSchema.ARGUMENT_SCHEMA_NAMES, "subschema" };
CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
cmdManager.addToRequestQueue(req);
try {
cmdManager.serviceRequestQueue();
ServiceSchemaManager mgr = new ServiceSchemaManager(TEST_SERVICE, getAdminSSOToken());
ServiceSchema globalSchema = mgr.getSchema(SchemaType.GLOBAL);
ServiceSchema s = globalSchema.getSubSchema("subschema");
assert (s == null);
exiting("removeSubSchema");
} catch (CLIException e) {
this.log(Level.SEVERE, "removeSubSchema", e.getMessage());
throw e;
} catch (SMSException e) {
this.log(Level.SEVERE, "removeSubSchema", e.getMessage());
throw e;
} catch (SSOException e) {
this.log(Level.SEVERE, "removeSubSchema", e.getMessage());
throw e;
}
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class SchemaTest method removeAttributeDefaultValues.
@Parameters({ "subschema" })
@Test(groups = { "schema", "remove-attr-defs", "attribute-schema-ops", "subschema" }, dependsOnMethods = { "showAttributeDefaultValues" })
public void removeAttributeDefaultValues(String subschema) throws CLIException, SMSException, SSOException {
Object[] params = { subschema };
entering("removeAttributeDefaultValues", params);
String[] args = (subschema.length() == 0) ? new String[7] : new String[9];
args[0] = "remove-attr-defs";
args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME;
args[2] = TEST_SERVICE;
args[3] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SCHEMA_TYPE;
args[4] = "global";
args[5] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_NAMES;
args[6] = "mock-add";
if (subschema.length() > 0) {
args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUBSCHEMA_NAME;
args[8] = subschema;
}
CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
cmdManager.addToRequestQueue(req);
try {
cmdManager.serviceRequestQueue();
ServiceSchemaManager mgr = new ServiceSchemaManager(TEST_SERVICE, getAdminSSOToken());
ServiceSchema serviceSchema = mgr.getGlobalSchema();
if (subschema.length() > 0) {
serviceSchema = serviceSchema.getSubSchema(subschema);
}
AttributeSchema as = serviceSchema.getAttributeSchema("mock-add");
Set values = as.getDefaultValues();
assert values.isEmpty();
exiting("removeAttributeDefaultValues");
} catch (CLIException e) {
this.log(Level.SEVERE, "removeAttributeDefaultValues", e.getMessage());
throw e;
} catch (SMSException e) {
this.log(Level.SEVERE, "removeAttributeDefaultValues", e.getMessage());
throw e;
} catch (SSOException e) {
this.log(Level.SEVERE, "removeAttributeDefaultValues", e.getMessage());
throw e;
}
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class DelegationManager method loadDelegationPlugin.
/**
* Loads the default implementation of DelegationInterface
*/
static synchronized DelegationInterface loadDelegationPlugin() throws DelegationException {
if (pluginInstance == null) {
try {
// get super admin user token
SSOToken privilegedToken = getAdminToken();
ServiceSchemaManager ssm = new ServiceSchemaManager(DELEGATION_SERVICE, privilegedToken);
ServiceSchema globalSchema = ssm.getGlobalSchema();
if (globalSchema != null) {
Map attributeDefaults = globalSchema.getAttributeDefaults();
if (attributeDefaults != null) {
subjectIdTypes.addAll((Set) attributeDefaults.get(SUBJECT_ID_TYPES));
}
}
if (debug.messageEnabled()) {
debug.message("Configured Subject ID Types: " + subjectIdTypes);
}
Set pluginNames = ssm.getPluginSchemaNames(DELEGATION_PLUGIN_INTERFACE, null);
if (pluginNames == null) {
throw new DelegationException(ResBundleUtils.rbName, "no_plugin_specified", null, null);
}
if (debug.messageEnabled()) {
debug.message("pluginNames=" + pluginNames);
}
// for the time being, only support one plugin
Iterator it = pluginNames.iterator();
if (it.hasNext()) {
String pluginName = (String) it.next();
PluginSchema ps = ssm.getPluginSchema(pluginName, DELEGATION_PLUGIN_INTERFACE, null);
if (ps == null) {
throw new DelegationException(ResBundleUtils.rbName, "no_plugin_specified", null, null);
}
String className = ps.getClassName();
if (debug.messageEnabled()) {
debug.message("Plugin class name:" + className);
}
pluginInstance = (DelegationInterface) Class.forName(className).newInstance();
pluginInstance.initialize(privilegedToken, null);
if (debug.messageEnabled()) {
debug.message("Successfully created " + "a delegation plugin instance");
}
} else {
throw new DelegationException(ResBundleUtils.rbName, "no_plugin_specified", null, null);
}
} catch (Exception e) {
debug.error("Unable to get an instance of plugin " + "for delegation", e);
pluginInstance = null;
throw new DelegationException(e);
}
}
return pluginInstance;
}
use of com.sun.identity.sm.ServiceSchema in project OpenAM by OpenRock.
the class FederationPlugin method setAuthModules.
private void setAuthModules(SSOToken adminSSOToken) {
try {
ServiceSchemaManager mgr = new ServiceSchemaManager("iPlanetAMAuthService", adminSSOToken);
ServiceSchema ss = mgr.getSchema(SchemaType.GLOBAL);
Map values = ss.getAttributeDefaults();
Set modules = (Set) values.get("iplanet-am-auth-authenticators");
modules.add("com.sun.identity.authentication.modules.federation.Federation");
modules.add("com.sun.identity.authentication.modules.sae.SAE");
ss.setAttributeDefaults(values);
} catch (SSOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (SMSException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
Aggregations