use of com.sun.identity.sm.PluginSchema 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.PluginSchema in project OpenAM by OpenRock.
the class PolicyManager method getViewBeanURL.
/**
* Gets the view bean URL given the plugin type
* and the plugin java class name
*
* @param pluginType type of plugin such as Subject, Referral, Condition
* @param pluginClassName name of java class name implementing the plugin
* type
*
* @return view bean URL defined for pluginType with name pluginName
*/
static String getViewBeanURL(String pluginType, String pluginClassName) {
String viewBeanURL = null;
if (pluginType != null) {
Iterator items = PolicyManager.getPluginSchemaNames(pluginType).iterator();
while (items.hasNext()) {
String pluginName = (String) items.next();
PluginSchema ps = PolicyManager.getPluginSchema(pluginType, pluginName);
if (pluginClassName.equals(ps.getClassName())) {
viewBeanURL = ps.getPropertiesViewBeanURL();
break;
}
}
}
return viewBeanURL;
}
use of com.sun.identity.sm.PluginSchema in project OpenAM by OpenRock.
the class SetPluginSchemaPropertiesViewBeanURL method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
String url = getStringOptionValue(ARGUMENT_URL);
String interfaceName = getStringOptionValue(ARGUMENT_INTERFACE_NAME);
String pluginName = getStringOptionValue(ARGUMENT_PLUGIN_NAME);
ServiceSchemaManager ssm = getServiceSchemaManager();
IOutput outputWriter = getOutputWriter();
try {
String[] params = { serviceName, pluginName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SET_PLUGIN_SCHEMA_PROP_VIEWBEAN_URL", params);
PluginSchema ps = ssm.getPluginSchema(pluginName, interfaceName, "/");
ps.setPropertiesViewBeanURL(url);
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SET_PLUGIN_SCHEMA_PROP_VIEWBEAN_URL", params);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-plugin-interface-succeed"), (Object[]) params));
} catch (SSOException e) {
String[] args = { serviceName, pluginName, e.getMessage() };
debugError("SetPluginSchemaPropertiesViewBeanURL.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_PLUGIN_SCHEMA_PROP_VIEWBEAN_URL", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { serviceName, pluginName, e.getMessage() };
debugError("SetPluginSchemaPropertiesViewBeanURL.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_PLUGIN_SCHEMA_PROP_VIEWBEAN_URL", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
Aggregations