Search in sources :

Example 11 with PagePropertiesCallback

use of com.sun.identity.authentication.spi.PagePropertiesCallback in project OpenAM by OpenRock.

the class AuthXMLUtils method getXMLForCallbacks.

/**
     * TODO-JAVADOC
     */
public static String getXMLForCallbacks(Callback[] callbacks) {
    if (callbacks == null) {
        return ("");
    }
    // Construct the xml string
    StringBuilder xmlString = new StringBuilder();
    xmlString.append(AuthXMLTags.CALLBACKS_BEGIN).append(AuthXMLTags.SPACE).append(AuthXMLTags.LENGTH).append(AuthXMLTags.EQUAL).append(AuthXMLTags.QUOTE).append(callbacks.length).append(AuthXMLTags.QUOTE).append(AuthXMLTags.ELEMENT_END);
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof HiddenValueCallback) {
            HiddenValueCallback hiddenValueCallback = (HiddenValueCallback) callbacks[i];
            xmlString.append(getHiddenValueCallbackXML(hiddenValueCallback));
        } else if (callbacks[i] instanceof NameCallback) {
            NameCallback nameCallback = (NameCallback) callbacks[i];
            xmlString.append(getNameCallbackXML(nameCallback));
        } else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback passwordCallback = (PasswordCallback) callbacks[i];
            xmlString.append(getPasswordCallbackXML(passwordCallback));
        } else if (callbacks[i] instanceof ChoiceCallback) {
            ChoiceCallback choiceCallback = (ChoiceCallback) callbacks[i];
            xmlString.append(getChoiceCallbackXML(choiceCallback));
        } else if (callbacks[i] instanceof ConfirmationCallback) {
            ConfirmationCallback conCallback = (ConfirmationCallback) callbacks[i];
            xmlString.append(getConfirmationCallbackXML(conCallback));
        } else if (callbacks[i] instanceof TextInputCallback) {
            TextInputCallback textInputCallback = (TextInputCallback) callbacks[i];
            xmlString.append(getTextInputCallbackXML(textInputCallback));
        } else if (callbacks[i] instanceof TextOutputCallback) {
            TextOutputCallback textOutputCallback = (TextOutputCallback) callbacks[i];
            xmlString.append(getTextOutputCallbackXML(textOutputCallback));
        } else if (callbacks[i] instanceof PagePropertiesCallback) {
            PagePropertiesCallback pagePCallback = (PagePropertiesCallback) callbacks[i];
            xmlString.append(getPagePropertiesCallbackXML(pagePCallback));
        } else if (callbacks[i] instanceof LanguageCallback) {
            LanguageCallback lc = (LanguageCallback) callbacks[i];
            xmlString.append(getLanguageCallbackXML(lc));
        } else if (callbacks[i] instanceof X509CertificateCallback) {
            X509CertificateCallback xc = (X509CertificateCallback) callbacks[i];
            xmlString.append(getX509CertificateCallbackXML(xc));
        } else if (callbacks[i] instanceof HttpCallback) {
            HttpCallback hc = (HttpCallback) callbacks[i];
            xmlString.append(getHttpCallbackXML(hc));
        } else if (callbacks[i] instanceof DSAMECallbackInterface) {
            DSAMECallbackInterface dsameCallback = (DSAMECallbackInterface) callbacks[i];
            xmlString.append(getCustomCallbackXML(dsameCallback));
        } else if (callbacks[i] instanceof RedirectCallback) {
            RedirectCallback redirectCallback = (RedirectCallback) callbacks[i];
            xmlString.append(getRedirectCallbackXML(redirectCallback));
        } else {
            AuthenticationCallbackXMLHelper callbackXMLHelper = AuthenticationCallbackXMLHelperFactory.getCallbackXMLHelper();
            if (callbackXMLHelper != null) {
                xmlString.append(callbackXMLHelper.getAuthenticationCallbackXML(callbacks[i]));
            }
        }
    }
    xmlString.append(AuthXMLTags.CALLBACKS_END);
    return (xmlString.toString());
}
Also used : RedirectCallback(com.sun.identity.authentication.spi.RedirectCallback) ConfirmationCallback(javax.security.auth.callback.ConfirmationCallback) PagePropertiesCallback(com.sun.identity.authentication.spi.PagePropertiesCallback) HiddenValueCallback(com.sun.identity.authentication.callbacks.HiddenValueCallback) HttpCallback(com.sun.identity.authentication.spi.HttpCallback) TextOutputCallback(javax.security.auth.callback.TextOutputCallback) ScriptTextOutputCallback(com.sun.identity.authentication.callbacks.ScriptTextOutputCallback) LanguageCallback(javax.security.auth.callback.LanguageCallback) TextInputCallback(javax.security.auth.callback.TextInputCallback) DSAMECallbackInterface(com.sun.identity.authentication.spi.DSAMECallbackInterface) ChoiceCallback(javax.security.auth.callback.ChoiceCallback) NameCallback(javax.security.auth.callback.NameCallback) PasswordCallback(javax.security.auth.callback.PasswordCallback) X509CertificateCallback(com.sun.identity.authentication.spi.X509CertificateCallback)

Example 12 with PagePropertiesCallback

use of com.sun.identity.authentication.spi.PagePropertiesCallback in project OpenAM by OpenRock.

the class AuthXMLUtils method createPagePropertiesCallback.

static PagePropertiesCallback createPagePropertiesCallback(Node childNode, Callback callback) {
    PagePropertiesCallback pagePropertiesCallback = null;
    if (callback != null) {
        if (callback instanceof PagePropertiesCallback) {
            pagePropertiesCallback = (PagePropertiesCallback) callback;
        }
    }
    if (pagePropertiesCallback == null) {
        boolean errState = false;
        String errStateAttr = XMLUtils.getNodeAttributeValue(childNode, AuthXMLTags.ERROR_STATE);
        if ((errStateAttr != null) && errStateAttr.equals("true")) {
            errState = true;
        }
        String moduleName = getValueOfChildNode(childNode, "ModuleName");
        String pageState = getValueOfChildNode(childNode, "PageState");
        String header = getValueOfChildNode(childNode, "HeaderValue");
        String image = getValueOfChildNode(childNode, "ImageName");
        int timeOut = Integer.parseInt(getValueOfChildNode(childNode, "PageTimeOutValue"));
        String template = getValueOfChildNode(childNode, "TemplateName");
        List<String> required = stringToList(getValueOfChildNode(childNode, "RequiredList"));
        List<String> attributes = stringToList(getValueOfChildNode(childNode, "AttributeList"));
        List<String> infoText = stringToList(getValueOfChildNode(childNode, "InfoTextList"));
        pagePropertiesCallback = new PagePropertiesCallback(moduleName, header, image, timeOut, template, errState, pageState);
        pagePropertiesCallback.setRequire(required);
        pagePropertiesCallback.setAttribute(attributes);
        pagePropertiesCallback.setInfoText(infoText);
    }
    return pagePropertiesCallback;
}
Also used : PagePropertiesCallback(com.sun.identity.authentication.spi.PagePropertiesCallback)

Example 13 with PagePropertiesCallback

use of com.sun.identity.authentication.spi.PagePropertiesCallback in project OpenAM by OpenRock.

the class RestAuthenticationHandler method createJsonCallbackResponse.

private JsonValue createJsonCallbackResponse(String authId, LoginConfiguration loginConfiguration, LoginProcess loginProcess, JsonValue jsonCallbacks) throws SignatureException, RestAuthException {
    PagePropertiesCallback pagePropertiesCallback = loginProcess.getPagePropertiesCallback();
    JsonObject jsonResponseObject = JsonValueBuilder.jsonValue();
    if (authId == null) {
        authId = authIdHelper.createAuthId(loginConfiguration, loginProcess.getAuthContext());
    }
    jsonResponseObject.put(AUTH_ID, authId);
    AuditRequestContext.putProperty(AUTH_ID, authId);
    if (pagePropertiesCallback != null) {
        jsonResponseObject.put("template", pagePropertiesCallback.getTemplateName());
        String moduleName = pagePropertiesCallback.getModuleName();
        String state = pagePropertiesCallback.getPageState();
        jsonResponseObject.put("stage", moduleName + state);
        jsonResponseObject.put("header", pagePropertiesCallback.getHeader());
    }
    jsonResponseObject.put("callbacks", jsonCallbacks.getObject());
    return jsonResponseObject.build();
}
Also used : PagePropertiesCallback(com.sun.identity.authentication.spi.PagePropertiesCallback) JsonObject(org.forgerock.openam.utils.JsonObject)

Aggregations

PagePropertiesCallback (com.sun.identity.authentication.spi.PagePropertiesCallback)13 Callback (javax.security.auth.callback.Callback)8 NameCallback (javax.security.auth.callback.NameCallback)6 ChoiceCallback (javax.security.auth.callback.ChoiceCallback)5 ConfirmationCallback (javax.security.auth.callback.ConfirmationCallback)5 PasswordCallback (javax.security.auth.callback.PasswordCallback)5 HttpCallback (com.sun.identity.authentication.spi.HttpCallback)4 RedirectCallback (com.sun.identity.authentication.spi.RedirectCallback)4 Test (org.testng.annotations.Test)4 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 JsonValue (org.forgerock.json.JsonValue)2 LoginProcess (org.forgerock.openam.core.rest.authn.core.LoginProcess)2 AuthContextLocalWrapper (org.forgerock.openam.core.rest.authn.core.wrappers.AuthContextLocalWrapper)2 ModelControlException (com.iplanet.jato.model.ModelControlException)1 SSOException (com.iplanet.sso.SSOException)1 AuthContext (com.sun.identity.authentication.AuthContext)1 Status (com.sun.identity.authentication.AuthContext.Status)1 HiddenValueCallback (com.sun.identity.authentication.callbacks.HiddenValueCallback)1