Search in sources :

Example 1 with PluginSchema

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;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) PluginSchema(com.sun.identity.sm.PluginSchema) Iterator(java.util.Iterator) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException)

Example 2 with PluginSchema

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;
}
Also used : PluginSchema(com.sun.identity.sm.PluginSchema) Iterator(java.util.Iterator)

Example 3 with PluginSchema

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);
    }
}
Also used : PluginSchema(com.sun.identity.sm.PluginSchema) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Aggregations

PluginSchema (com.sun.identity.sm.PluginSchema)3 SSOException (com.iplanet.sso.SSOException)2 SMSException (com.sun.identity.sm.SMSException)2 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)2 Iterator (java.util.Iterator)2 SSOToken (com.iplanet.sso.SSOToken)1 CLIException (com.sun.identity.cli.CLIException)1 IOutput (com.sun.identity.cli.IOutput)1 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)1 IdRepoException (com.sun.identity.idm.IdRepoException)1 ServiceSchema (com.sun.identity.sm.ServiceSchema)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1