Search in sources :

Example 1 with STSInstanceModel

use of com.sun.identity.console.sts.model.STSInstanceModel in project OpenAM by OpenRock.

the class STSEditViewBeanBase method instanceNameUpdated.

/*
    The deploymentUrl of an existing sts instance cannot be edited, as it constitutes (along with the realm) the dn of the
    rest-sts instance state. This method returns true if the changes include the deployment url.
     */
private boolean instanceNameUpdated(String realm, String instanceName) throws ModelControlException, AMConsoleException {
    STSInstanceModel model = (STSInstanceModel) getModel();
    Map<String, Set<String>> currentPersistedInstanceState;
    try {
        currentPersistedInstanceState = model.getInstanceState(stsType, realm, instanceName);
    } catch (AMConsoleException e) {
        throw new ModelControlException(e.getMessage(), e);
    }
    AMPropertySheet ps = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
    Map<String, Set<String>> updatedValues = ps.getAttributeValues(currentPersistedInstanceState, model);
    return !CollectionUtils.isEmpty(updatedValues.get(SharedSTSConstants.DEPLOYMENT_URL_ELEMENT));
}
Also used : Set(java.util.Set) AMPropertySheet(com.sun.identity.console.base.AMPropertySheet) RestSTSInstanceModel(com.sun.identity.console.sts.model.RestSTSInstanceModel) STSInstanceModel(com.sun.identity.console.sts.model.STSInstanceModel) SoapSTSInstanceModel(com.sun.identity.console.sts.model.SoapSTSInstanceModel) ModelControlException(com.iplanet.jato.model.ModelControlException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 2 with STSInstanceModel

use of com.sun.identity.console.sts.model.STSInstanceModel in project OpenAM by OpenRock.

the class STSEditViewBeanBase method getUpdatedConfigurationState.

/**
     * Called to harvest the full set of updated configuration properties.
     * @param realm
     * @param instanceName
     * @return The set up updated properties. An empty-set will be returned if no properties updated.
     * @throws ModelControlException thrown by AMPropertySheet#getAttributeValues if model for property-sheet cannot be
     * obtained
     * @throws AMConsoleException thrown by AMPropertySheet#getAttributeValues if passwords are mis-matched.
     */
private Map<String, Set<String>> getUpdatedConfigurationState(String realm, String instanceName) throws ModelControlException, AMConsoleException {
    STSInstanceModel model = (STSInstanceModel) getModel();
    Map<String, Set<String>> currentPersistedInstanceState;
    try {
        currentPersistedInstanceState = model.getInstanceState(stsType, realm, instanceName);
    } catch (AMConsoleException e) {
        throw new ModelControlException(e.getMessage(), e);
    }
    AMPropertySheet ps = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
    Map<String, Set<String>> updatedValues = ps.getAttributeValues(currentPersistedInstanceState, model);
    if (updatedValues.isEmpty()) {
        return updatedValues;
    } else {
        currentPersistedInstanceState.putAll(updatedValues);
        return currentPersistedInstanceState;
    }
}
Also used : Set(java.util.Set) AMPropertySheet(com.sun.identity.console.base.AMPropertySheet) RestSTSInstanceModel(com.sun.identity.console.sts.model.RestSTSInstanceModel) STSInstanceModel(com.sun.identity.console.sts.model.STSInstanceModel) SoapSTSInstanceModel(com.sun.identity.console.sts.model.SoapSTSInstanceModel) ModelControlException(com.iplanet.jato.model.ModelControlException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 3 with STSInstanceModel

use of com.sun.identity.console.sts.model.STSInstanceModel in project OpenAM by OpenRock.

the class STSEditViewBeanBase method beginDisplay.

public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    final String instanceName = (String) getPageSessionAttribute(STSHomeViewBean.INSTANCE_NAME);
    final String currentRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    if (!submitCycle) {
        STSInstanceModel model = (STSInstanceModel) getModel();
        Map map;
        try {
            map = model.getInstanceState(stsType, currentRealm, instanceName);
        } catch (AMConsoleException e) {
            throw new ModelControlException(e);
        }
        if (!map.isEmpty()) {
            AMPropertySheet ps = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
            propertySheetModel.clear();
            ps.setAttributeValues(map, getModel());
        } else {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", MessageFormat.format(model.getLocalizedString("rest.sts.view.no.instance.message"), instanceName));
        }
    }
}
Also used : AMPropertySheet(com.sun.identity.console.base.AMPropertySheet) RestSTSInstanceModel(com.sun.identity.console.sts.model.RestSTSInstanceModel) STSInstanceModel(com.sun.identity.console.sts.model.STSInstanceModel) SoapSTSInstanceModel(com.sun.identity.console.sts.model.SoapSTSInstanceModel) ModelControlException(com.iplanet.jato.model.ModelControlException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map)

Example 4 with STSInstanceModel

use of com.sun.identity.console.sts.model.STSInstanceModel in project OpenAM by OpenRock.

the class STSAddViewBeanBase method handleButton1Request.

/**
     * Handles save button request. Validates the rest sts configuration state, and invokes the model to publish a
     * rest sts instance corresponding to this state.
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    try {
        Map<String, Set<String>> configurationState = (Map<String, Set<String>>) getAttributeSettings();
        STSInstanceModel model = (STSInstanceModel) getModel();
        STSInstanceModelResponse validationResponse = model.validateConfigurationState(stsType, configurationState);
        if (validationResponse.isSuccessful()) {
            final String currentRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
            try {
                STSInstanceModelResponse creationResponse = model.createInstance(stsType, configurationState, currentRealm);
                if (creationResponse.isSuccessful()) {
                    setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", creationResponse.getMessage());
                    forwardToAMViewBean();
                } else {
                    setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", creationResponse.getMessage());
                }
            } catch (AMConsoleException e) {
                throw new ModelControlException(e);
            }
        } else {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", validationResponse.getMessage());
        }
    } catch (AMConsoleException e) {
        //will be entered if getAttributeSettings throws a AMConsoleException because passwords are mis-matched.
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : Set(java.util.Set) STSInstanceModelResponse(com.sun.identity.console.sts.model.STSInstanceModelResponse) RestSTSInstanceModel(com.sun.identity.console.sts.model.RestSTSInstanceModel) SoapSTSInstanceModel(com.sun.identity.console.sts.model.SoapSTSInstanceModel) STSInstanceModel(com.sun.identity.console.sts.model.STSInstanceModel) ModelControlException(com.iplanet.jato.model.ModelControlException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map)

Example 5 with STSInstanceModel

use of com.sun.identity.console.sts.model.STSInstanceModel in project OpenAM by OpenRock.

the class STSEditViewBeanBase method handleButton1Request.

/**
     * Handles save button request. Validates the rest sts configuration state, and invokes the model to publish a
     * rest sts instance corresponding to this state.
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    final String currentRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    final String instanceName = (String) getPageSessionAttribute(STSHomeViewBean.INSTANCE_NAME);
    try {
        Map<String, Set<String>> configurationState = getUpdatedConfigurationState(currentRealm, instanceName);
        if (configurationState.isEmpty()) {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", getModel().getLocalizedString("rest.sts.view.no.updates"));
        } else {
            if (instanceNameUpdated(currentRealm, instanceName)) {
                setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", MessageFormat.format(getModel().getLocalizedString("rest.sts.view.no.edit.deployment.url"), instanceName));
            } else {
                STSInstanceModel model = (STSInstanceModel) getModel();
                STSInstanceModelResponse validationResponse = model.validateConfigurationState(stsType, configurationState);
                if (validationResponse.isSuccessful()) {
                    try {
                        STSInstanceModelResponse creationResponse = model.updateInstance(stsType, configurationState, currentRealm, instanceName);
                        if (creationResponse.isSuccessful()) {
                            forwardToSTSHomeViewBean();
                        } else {
                            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", creationResponse.getMessage());
                        }
                    } catch (AMConsoleException e) {
                        throw new ModelControlException(e);
                    }
                } else {
                    setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", validationResponse.getMessage());
                }
            }
        }
    } catch (AMConsoleException e) {
        //getUpdatedConfigurationState will throw this exception if passwords are mis-matched.
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : Set(java.util.Set) STSInstanceModelResponse(com.sun.identity.console.sts.model.STSInstanceModelResponse) RestSTSInstanceModel(com.sun.identity.console.sts.model.RestSTSInstanceModel) STSInstanceModel(com.sun.identity.console.sts.model.STSInstanceModel) SoapSTSInstanceModel(com.sun.identity.console.sts.model.SoapSTSInstanceModel) ModelControlException(com.iplanet.jato.model.ModelControlException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

ModelControlException (com.iplanet.jato.model.ModelControlException)5 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)5 RestSTSInstanceModel (com.sun.identity.console.sts.model.RestSTSInstanceModel)5 STSInstanceModel (com.sun.identity.console.sts.model.STSInstanceModel)5 SoapSTSInstanceModel (com.sun.identity.console.sts.model.SoapSTSInstanceModel)5 Set (java.util.Set)4 AMPropertySheet (com.sun.identity.console.base.AMPropertySheet)3 STSInstanceModelResponse (com.sun.identity.console.sts.model.STSInstanceModelResponse)2 Map (java.util.Map)2