Search in sources :

Example 11 with ResponseProvider

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

the class ResponseProviderEditViewBean method getDefaultValues.

protected Map getDefaultValues() {
    Map values = null;
    String providerName = (String) getPageSessionAttribute(ResponseProviderOpViewBeanBase.PG_SESSION_PROVIDER_NAME);
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        ResponseProvider provider = policy.getResponseProvider(providerName);
        values = provider.getProperties();
    } catch (NameNotFoundException e) {
        debug.warning("ResponseProviderEditViewBean.getDefaultValues", e);
    } catch (AMConsoleException e) {
        debug.warning("ResponseProviderEditViewBean.getDefaultValues", e);
    }
    return values;
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map)

Example 12 with ResponseProvider

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

the class ResponseProviderAddViewBean method handleButton2Request.

/**
     * Handles create policy request.
     *
     * @param event Request invocation event
     */
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
    boolean forwarded = false;
    submitCycle = true;
    try {
        ResponseProvider provider = createResponseProvider();
        if (provider != null) {
            CachedPolicy cachedPolicy = getCachedPolicy();
            Policy policy = cachedPolicy.getPolicy();
            String name = (String) propertySheetModel.getValue(RESPONSEPROVIDER_NAME);
            policy.addResponseProvider(name, provider);
            backTrail();
            forwardToPolicyViewBean();
            forwarded = true;
        }
    } catch (NameAlreadyExistsException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    if (!forwarded) {
        forwardTo();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 13 with ResponseProvider

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

the class PrivilegeUtils method toResourceAttributes.

private static Set<ResourceAttribute> toResourceAttributes(Policy policy) throws PolicyException, EntitlementException {
    Set rpNames = policy.getResponseProviderNames();
    Set nrps = new HashSet();
    for (Object rpNameObj : rpNames) {
        String rpName = (String) rpNameObj;
        ResponseProvider rp = policy.getResponseProvider(rpName);
        Object[] nrp = new Object[2];
        nrp[0] = rpName;
        nrp[1] = rp;
        nrps.add(nrp);
    }
    return nrpsToResourceAttributes(nrps);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) IDRepoResponseProvider(com.sun.identity.policy.plugins.IDRepoResponseProvider) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) HashSet(java.util.HashSet)

Example 14 with ResponseProvider

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

the class PolicyOpViewBeanBase method handleTblResponseProvidersEditLinkRequest.

public void handleTblResponseProvidersEditLinkRequest(RequestInvocationEvent event) throws ModelControlException {
    PolicyModel model = (PolicyModel) getModel();
    String name = hexToString((String) getDisplayFieldValue(TBL_RESPONSE_ATTRIBUTES_ACTION_HREF));
    setPageSessionAttribute(ResponseProviderEditViewBean.CALLING_VIEW_BEAN, getClass().getName());
    setPageSessionAttribute(ResponseProviderEditViewBean.EDIT_RESPONSEPROVIDER_NAME, name);
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        ResponseProvider provider = policy.getResponseProvider(name);
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        String responseProviderType = model.getResponseProviderTypeName(realmName, provider);
        String viewBeanURL = model.getResponseProviderViewBeanURL(realmName, responseProviderType);
        unlockPageTrail();
        if ((viewBeanURL != null) && (viewBeanURL.trim().length() > 0)) {
            forwardToResponseProviderURL(viewBeanURL, name, responseProviderType, realmName, "edit");
        } else {
            forwardToResponseProviderEditViewBean(model, realmName, name, responseProviderType);
        }
    } catch (NameNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblResponseProvidersEditLinkRequest", e);
        redirectToStartURL();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 15 with ResponseProvider

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

the class PolicyOpViewBeanBase method populateResponseProvidersTable.

protected void populateResponseProvidersTable() throws AMConsoleException {
    tblResponseProvidersModel.clearAll();
    CachedPolicy cachedPolicy = getCachedPolicy();
    Policy policy = cachedPolicy.getPolicy();
    Set responseProviderNames = policy.getResponseProviderNames();
    if ((responseProviderNames != null) && !responseProviderNames.isEmpty()) {
        PolicyModel model = (PolicyModel) getModel();
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        Map localizedRespAttrTypeNames = model.getActiveResponseProviderTypes(realmName);
        boolean firstEntry = true;
        for (Iterator i = responseProviderNames.iterator(); i.hasNext(); ) {
            if (firstEntry) {
                firstEntry = false;
            } else {
                tblResponseProvidersModel.appendRow();
            }
            try {
                String name = (String) i.next();
                ResponseProvider provider = policy.getResponseProvider(name);
                tblResponseProvidersModel.setValue(TBL_RESPONSE_ATTRIBUTES_DATA_NAME, name);
                String respAttrTypeName = model.getResponseProviderTypeName(realmName, provider);
                String displayName = (String) localizedRespAttrTypeNames.get(respAttrTypeName);
                if (displayName == null) {
                    displayName = respAttrTypeName;
                }
                tblResponseProvidersModel.setValue(TBL_RESPONSE_ATTRIBUTES_DATA_TYPE, displayName);
                tblResponseProvidersModel.setValue(TBL_RESPONSE_ATTRIBUTES_ACTION_HREF, stringToHex(name));
            } catch (NameNotFoundException e) {
                debug.warning("PolicyOpViewBeanBase.populateResponseProvidersTable", e);
            }
        }
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Set(java.util.Set) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) Iterator(java.util.Iterator) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) HashMap(java.util.HashMap) Map(java.util.Map)

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