Search in sources :

Example 16 with ResponseProvider

use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.

the class ResponseProviderEditViewBean method handleButton1Request.

private void handleButton1Request(CachedPolicy cachedPolicy) throws ModelControlException {
    ResponseProvider deleted = null;
    submitCycle = true;
    String origName = (String) getPageSessionAttribute(EDIT_RESPONSEPROVIDER_NAME);
    Policy policy = cachedPolicy.getPolicy();
    try {
        ResponseProvider provider = createResponseProvider();
        if (provider != null) {
            String name = (String) propertySheetModel.getValue(RESPONSEPROVIDER_NAME);
            if (origName.equals(name)) {
                policy.replaceResponseProvider(name, provider);
            } else {
                deleted = policy.removeResponseProvider(origName);
                policy.addResponseProvider(name, provider);
            }
            deleted = null;
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.responseProvider.updated");
            cachedPolicy.setPolicyModified(true);
        }
    } catch (NameAlreadyExistsException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
    } catch (NameNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    } finally {
        if (deleted != null) {
            try {
                policy.addResponseProvider(origName, deleted);
            } catch (NameAlreadyExistsException e) {
                debug.warning("ResponseProviderEditViewBean.handleButton1Request", e);
            }
        }
    }
    forwardTo();
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 17 with ResponseProvider

use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.

the class ResponseProviderOpViewBeanBase method createResponseProvider.

protected ResponseProvider createResponseProvider() throws ModelControlException, AMConsoleException {
    ResponseProvider provider = null;
    String providerType = (String) propertySheetModel.getValue(RESPONSEPROVIDER_TYPE);
    String providerName = getResponseProviderName();
    if (providerName != null) {
        Map values = getValues(providerType);
        if (values != null) {
            provider = createResponseProvider(providerType, values);
        }
    }
    return provider;
}
Also used : ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) Map(java.util.Map)

Example 18 with ResponseProvider

use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.

the class ResponseProviderTypeManager method getResponseProvider.

/**
     * Returns an instance of the <code>ResponseProvider</code>
     * given the response provider type name.
     *
     * @param responseProviderTypeName response provider type name.
     * @return an instance of the <code>ResponseProvider</code>
     * given the response provider type name.
     * @throws NameNotFoundException if the <code>ResponseProvider</code> 
     * not found
     * @throws PolicyException for any other abnormal condition
     */
public ResponseProvider getResponseProvider(String responseProviderTypeName) throws NameNotFoundException, PolicyException {
    PluginSchema ps = PolicyManager.getPluginSchema(RESPONSE_PROVIDER, responseProviderTypeName);
    if (ps == null) {
        throw (new NameNotFoundException(ResBundleUtils.rbName, "invalid_response_provider", null, responseProviderTypeName, PolicyException.RESPONSE_PROVIDER_COLLECTION));
    }
    // Construct the object
    ResponseProvider respProvider = null;
    try {
        String className = ps.getClassName();
        respProvider = (ResponseProvider) Class.forName(className).newInstance();
    } catch (Exception e) {
        throw (new PolicyException(e));
    }
    respProvider.initialize(pm.getPolicyConfig());
    return respProvider;
}
Also used : ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) SSOException(com.iplanet.sso.SSOException)

Example 19 with ResponseProvider

use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.

the class ResponseProviders method clone.

/**
     * Returns a deep copy of this object with the identical
     * set of <code>ResponseProvider</code> objects
     *
     * @return a deep copy of this object 
     */
public Object clone() {
    ResponseProviders answer = null;
    try {
        answer = (ResponseProviders) super.clone();
    } catch (CloneNotSupportedException se) {
        answer = new ResponseProviders();
    }
    answer.name = name;
    answer.description = description;
    answer.providers = new HashMap();
    Iterator items = providers.keySet().iterator();
    while (items.hasNext()) {
        Object item = items.next();
        ResponseProvider responseProvider = (ResponseProvider) providers.get(item);
        answer.providers.put(item, responseProvider.clone());
    }
    return (answer);
}
Also used : ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider)

Aggregations

ResponseProvider (com.sun.identity.policy.interfaces.ResponseProvider)19 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)7 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)7 Policy (com.sun.identity.policy.Policy)6 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)5 PolicyException (com.sun.identity.policy.PolicyException)5 HashSet (java.util.HashSet)5 Set (java.util.Set)5 IDRepoResponseProvider (com.sun.identity.policy.plugins.IDRepoResponseProvider)4 Map (java.util.Map)4 SSOException (com.iplanet.sso.SSOException)3 PolicyManager (com.sun.identity.policy.PolicyManager)3 ResponseProviderTypeManager (com.sun.identity.policy.ResponseProviderTypeManager)3 HashMap (java.util.HashMap)3 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)2 EntitlementException (com.sun.identity.entitlement.EntitlementException)2 ResourceAttribute (com.sun.identity.entitlement.ResourceAttribute)2 NameAlreadyExistsException (com.sun.identity.policy.NameAlreadyExistsException)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 SSOToken (com.iplanet.sso.SSOToken)1