Search in sources :

Example 1 with PagePropertiesCallback

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

the class LoginViewBean method addLoginCallbackMessage.

// Method to generate HTML page from Callback objects
protected void addLoginCallbackMessage(Callback[] callbacks) throws Exception {
    loginDebug.message("In addLoginCallbackMessage()");
    buttonOptions = null;
    pageState = null;
    for (int i = 0; i < callbacks.length; i++) {
        if (loginDebug.messageEnabled()) {
            loginDebug.message("In addLoginCallbackMessage() callback : " + callbacks[i]);
        }
        if (callbacks[i] instanceof ConfirmationCallback) {
            ConfirmationCallback conc = (ConfirmationCallback) callbacks[i];
            buttonOptions = conc.getOptions();
            defaultButtonIndex = conc.getDefaultOption();
            String defaultButton = buttonOptions[defaultButtonIndex];
        } else if (callbacks[i] instanceof PagePropertiesCallback) {
            PagePropertiesCallback ppc = (PagePropertiesCallback) callbacks[i];
            TextHeaderVal = ppc.getHeader();
            pageTemplate = ppc.getTemplateName();
            pageImage = ppc.getImage();
            requiredList = ppc.getRequire();
            pageState = ppc.getPageState();
            infoText = ppc.getInfoText();
            int lsize = 0;
            if ((requiredList != null) && (!requiredList.isEmpty())) {
                loginDebug.message("PPC - list not null & not empty");
                lsize = requiredList.size();
            }
            if (loginDebug.messageEnabled()) {
                loginDebug.message("PagePropertiesCallback - header : " + TextHeaderVal + " template : " + pageTemplate + " image : " + pageImage + " Required list : " + requiredList + " List size : " + lsize + "Info Text : " + infoText + " Page State : " + pageState);
            }
            // empty callback processing
            if (callbacks.length == 1) {
                onePageLogin = true;
                processLoginDisplay();
                break;
            }
        }
    }
}
Also used : ConfirmationCallback(javax.security.auth.callback.ConfirmationCallback) PagePropertiesCallback(com.sun.identity.authentication.spi.PagePropertiesCallback)

Example 2 with PagePropertiesCallback

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

the class LoginViewBean method processLoginDisplay.

protected void processLoginDisplay() throws Exception {
    loginDebug.message("In processLoginDisplay()");
    String tmp = "";
    try {
        if (!onePageLogin) {
            if (AuthUtils.isNewRequest(ac)) {
                loginDebug.message("In processLoginDisplay() : Session New ");
                getLoginDisplay();
                return;
            }
        }
        String page_state = request.getParameter("page_state");
        if (loginDebug.messageEnabled()) {
            loginDebug.message("Submit with Page State : " + page_state);
        }
        if ((page_state != null) && (page_state.length() != 0)) {
            callbacks = AuthUtils.getCallbacksPerState(ac, page_state);
            if (callbacks == null) {
                errorCode = AMAuthErrorCode.AUTH_TIMEOUT;
                ErrorMessage = AuthUtils.getErrorVal(AMAuthErrorCode.AUTH_TIMEOUT, AuthUtils.ERROR_MESSAGE);
                errorTemplate = AuthUtils.getErrorVal(AMAuthErrorCode.AUTH_TIMEOUT, AuthUtils.ERROR_TEMPLATE);
                return;
            }
            //Get Callbacks in order to set the page state
            Callback[] callbacksForPageState = AuthUtils.getRecdCallback(ac);
            for (int i = 0; i < callbacksForPageState.length; i++) {
                if (loginDebug.messageEnabled()) {
                    loginDebug.message("In processLoginDisplay() callbacksForPageState : " + callbacksForPageState[i]);
                }
                if (callbacksForPageState[i] instanceof PagePropertiesCallback) {
                    PagePropertiesCallback ppc = (PagePropertiesCallback) callbacksForPageState[i];
                    if (loginDebug.messageEnabled()) {
                        loginDebug.message("setPageState in PPC to : " + page_state);
                    }
                    ppc.setPageState(page_state);
                    break;
                }
            }
        } else {
            callbacks = AuthUtils.getRecdCallback(ac);
        }
        indexType = AuthUtils.getIndexType(ac);
        // Assign user specified values
        for (int i = 0; i < callbacks.length; i++) {
            if (loginDebug.messageEnabled()) {
                loginDebug.message("In processLoginDisplay() callback : " + callbacks[i]);
            }
            if (callbacks[i] instanceof NameCallback) {
                NameCallback nc = (NameCallback) callbacks[i];
                tmp = (String) reqDataHash.get(TOKEN + Integer.toString(i));
                if (tmp == null) {
                    tmp = (String) reqDataHash.get(TOKEN_OLD + Integer.toString(i));
                }
                if ((bAuthLevel) || (tmp == null)) {
                    tmp = "";
                }
                nc.setName(tmp.trim());
            } else if (callbacks[i] instanceof PasswordCallback) {
                PasswordCallback pc = (PasswordCallback) callbacks[i];
                tmp = (String) reqDataHash.get(TOKEN + Integer.toString(i));
                if (tmp == null) {
                    tmp = (String) reqDataHash.get(TOKEN_OLD + Integer.toString(i));
                }
                if (tmp == null) {
                    tmp = "";
                }
                pc.setPassword(tmp.toCharArray());
            } else if (callbacks[i] instanceof ChoiceCallback) {
                ChoiceCallback cc = (ChoiceCallback) callbacks[i];
                choice = (String) reqDataHash.get(TOKEN + Integer.toString(i));
                if (choice == null) {
                    choice = (String) reqDataHash.get(TOKEN_OLD + Integer.toString(i));
                }
                if (loginDebug.messageEnabled()) {
                    loginDebug.message("choice : " + choice);
                }
                String[] choices = cc.getChoices();
                if (choice == null) {
                    if (loginDebug.messageEnabled()) {
                        loginDebug.message("No selected choice.");
                    }
                } else if (choice.indexOf("|") != -1) {
                    StringTokenizer st = new StringTokenizer(choice, "|");
                    int cnt = st.countTokens();
                    int[] selectIndexs = new int[cnt];
                    int j = 0;
                    if (loginDebug.messageEnabled()) {
                        loginDebug.message("No of tokens : " + Integer.toString(cnt));
                    }
                    while (st.hasMoreTokens()) {
                        choice = st.nextToken();
                        if (choice != null && choice.length() != 0) {
                            int selected = Integer.parseInt(choice);
                            choice = choices[selected];
                            selectIndexs[j++] = selected;
                            if (loginDebug.messageEnabled()) {
                                loginDebug.message("selected  choice : " + choice + " & selected index : " + selected);
                            }
                        }
                    }
                    cc.setSelectedIndexes(selectIndexs);
                    if (loginDebug.messageEnabled()) {
                        loginDebug.message("Selected indexes : " + selectIndexs);
                    }
                } else {
                    int selected = Integer.parseInt(choice);
                    cc.setSelectedIndex(selected);
                    choice = choices[selected];
                    if (loginDebug.messageEnabled()) {
                        loginDebug.message("selected ONE choice : " + choice + " & selected ONE index : " + selected);
                    }
                }
            } else if (callbacks[i] instanceof ConfirmationCallback) {
                ConfirmationCallback conc = (ConfirmationCallback) callbacks[i];
                buttonOptions = conc.getOptions();
                tmp = (String) reqDataHash.get(BUTTON);
                if (tmp == null) {
                    tmp = (String) reqDataHash.get(BUTTON_OLD);
                }
                if (tmp == null) {
                    tmp = "";
                }
                int selectedIndex = 0;
                for (int j = 0; j < buttonOptions.length; j++) {
                    if ((buttonOptions[j].trim()).equals(tmp.trim())) {
                        selectedIndex = j;
                    }
                }
                conc.setSelectedIndex(selectedIndex);
                if (loginDebug.messageEnabled()) {
                    loginDebug.message("selected  button : " + buttonOptions[selectedIndex] + " & selected button index : " + selectedIndex);
                }
            } else if (callbacks[i] instanceof RedirectCallback) {
                RedirectCallback rc = (RedirectCallback) callbacks[i];
                String status = request.getParameter(rc.getStatusParameter());
                clearCookie(rc.getRedirectBackUrlCookieName());
                loginDebug.message("Redirect callback : set status");
                rc.setStatus(status);
            }
        }
        // testing
        if (loginDebug.messageEnabled()) {
            loginDebug.message(" length 0f callbacks : " + callbacks.length);
            loginDebug.message(" Index type : " + indexType + " Index name : " + indexName);
        }
        if ((indexType == AuthContext.IndexType.LEVEL) || (indexType == AuthContext.IndexType.COMPOSITE_ADVICE)) {
            if (loginDebug.messageEnabled()) {
                loginDebug.message("In processLoginDisplay(), Index type" + " is Auth Level or Composite Advice and selected Module " + "or Service is : " + choice);
            }
            indexName = AMAuthUtils.getDataFromRealmQualifiedData(choice);
            String qualifiedRealm = AMAuthUtils.getRealmFromRealmQualifiedData(choice);
            String orgDN = null;
            if ((qualifiedRealm != null) && (qualifiedRealm.length() != 0)) {
                orgDN = DNMapper.orgNameToDN(qualifiedRealm);
                ac.setOrgDN(orgDN);
            }
            int type = AuthUtils.getCompositeAdviceType(ac);
            if (type == AuthUtils.MODULE) {
                indexType = AuthContext.IndexType.MODULE_INSTANCE;
            } else if (type == AuthUtils.SERVICE) {
                indexType = AuthContext.IndexType.SERVICE;
            } else if (type == AuthUtils.REALM) {
                indexType = AuthContext.IndexType.SERVICE;
                orgDN = DNMapper.orgNameToDN(choice);
                indexName = AuthUtils.getOrgConfiguredAuthenticationChain(orgDN);
                ac.setOrgDN(orgDN);
            } else {
                indexType = AuthContext.IndexType.MODULE_INSTANCE;
            }
            bAuthLevel = true;
            if ((indexName != null) && (indexType == AuthContext.IndexType.MODULE_INSTANCE)) {
                if (indexName.equalsIgnoreCase("Application")) {
                    onePageLogin = true;
                }
            }
            if (loginDebug.messageEnabled()) {
                loginDebug.message("Index type : " + indexType);
                loginDebug.message("Index name : " + indexName);
                loginDebug.message("qualified orgDN : " + orgDN);
            }
            getLoginDisplay();
        } else {
            // Submit the information to auth module
            ac.submitRequirements(callbacks);
            // Check if more information is required
            if (loginDebug.messageEnabled()) {
                loginDebug.message("before hasMoreRequirements: Status is: " + ac.getStatus());
            }
            if (ac.hasMoreRequirements()) {
                loginDebug.message("Has more requirements after Submit ");
                callbacks = ac.getRequirements();
                for (int i = 0; i < callbacks.length; i++) {
                    if (callbacks[i] instanceof HttpCallback) {
                        processHttpCallback((HttpCallback) callbacks[i]);
                        return;
                    } else if (callbacks[i] instanceof RedirectCallback) {
                        processRedirectCallback((RedirectCallback) callbacks[i]);
                        return;
                    }
                }
                addLoginCallbackMessage(callbacks);
                if (!LoginFail) {
                    //if the login already failed, then LoginState is already
                    //nullified, hence any attempt of calling this method
                    //the errormessage/code/template should be already set
                    //so a proper error page is shown.
                    AuthUtils.setCallbacksPerState(ac, pageState, callbacks);
                }
            } else {
                if (loginDebug.messageEnabled()) {
                    loginDebug.message("No more Requirements : Status is : " + ac.getStatus());
                }
                if (ac.getStatus() == AuthContext.Status.SUCCESS) {
                    LoginSuccess = true;
                    ResultVal = rb.getString("authentication.successful");
                    /*
                         * redirect to 'goto' parameter or SPI hook or default
                         * redirect URL.
                         */
                    redirect_url = AuthUtils.getLoginSuccessURL(ac);
                    if ((redirect_url != null) && (redirect_url.length() != 0)) {
                        if (loginDebug.messageEnabled()) {
                            loginDebug.message("LoginSuccessURL (in case of " + " successful auth) : " + redirect_url);
                        }
                    }
                } else if (ac.getStatus() == AuthContext.Status.FAILED) {
                    handleAuthLoginException(null);
                    /*
                         * redirect to 'goto' parameter or SPI hook or default
                         * redirect URL.
                         */
                    redirect_url = AuthUtils.getLoginFailedURL(ac);
                    if ((redirect_url != null) && (redirect_url.length() != 0)) {
                        if (loginDebug.messageEnabled()) {
                            loginDebug.message("LoginFailedURL : " + redirect_url);
                        }
                    }
                } else {
                    /*
                         * redirect to 'goto' parameter or SPI hook or default
                         * redirect URL.
                         */
                    redirect_url = AuthUtils.getLoginFailedURL(ac);
                    if (loginDebug.warningEnabled()) {
                        loginDebug.warning("Login Status is " + ac.getStatus() + " - redirect to loginFailedURL : " + redirect_url);
                    }
                    setErrorMessage(null);
                }
            }
        }
    } catch (Exception e) {
        if (loginDebug.messageEnabled()) {
            loginDebug.message("Error in processing LoginDisplay : ", e);
        }
        setErrorMessage(e);
        throw new L10NMessageImpl(bundleName, "loginDisplay.process", new Object[] { e.getMessage() });
    }
}
Also used : RedirectCallback(com.sun.identity.authentication.spi.RedirectCallback) ConfirmationCallback(javax.security.auth.callback.ConfirmationCallback) PagePropertiesCallback(com.sun.identity.authentication.spi.PagePropertiesCallback) L10NMessageImpl(com.sun.identity.shared.locale.L10NMessageImpl) HttpCallback(com.sun.identity.authentication.spi.HttpCallback) ModelControlException(com.iplanet.jato.model.ModelControlException) AuthLoginException(com.sun.identity.authentication.spi.AuthLoginException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) ChoiceCallback(javax.security.auth.callback.ChoiceCallback) StringTokenizer(java.util.StringTokenizer) PasswordCallback(javax.security.auth.callback.PasswordCallback) Callback(javax.security.auth.callback.Callback) PagePropertiesCallback(com.sun.identity.authentication.spi.PagePropertiesCallback) HttpCallback(com.sun.identity.authentication.spi.HttpCallback) RedirectCallback(com.sun.identity.authentication.spi.RedirectCallback) ChoiceCallback(javax.security.auth.callback.ChoiceCallback) NameCallback(javax.security.auth.callback.NameCallback) ConfirmationCallback(javax.security.auth.callback.ConfirmationCallback) NameCallback(javax.security.auth.callback.NameCallback) PasswordCallback(javax.security.auth.callback.PasswordCallback)

Example 3 with PagePropertiesCallback

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

the class RestAuthenticationHandlerTest method shouldInitiateAuthenticationViaGET4.

@Test
public void shouldInitiateAuthenticationViaGET4() throws AuthLoginException, L10NMessageImpl, JSONException, IOException, RestAuthResponseException, SignatureException, RestAuthException {
    //Given
    HttpServletRequest request = mock(HttpServletRequest.class);
    HttpServletResponse httpResponse = mock(HttpServletResponse.class);
    String authIndexType = null;
    String indexValue = null;
    String sessionUpgradeSSOTokenId = null;
    Callback[] callbacks = new Callback[0];
    AuthContextLocalWrapper authContextLocalWrapper = mock(AuthContextLocalWrapper.class);
    LoginProcess loginProcess = mock(LoginProcess.class);
    given(loginProcess.getLoginStage()).willReturn(LoginStage.REQUIREMENTS_WAITING);
    given(loginProcess.getCallbacks()).willReturn(callbacks);
    given(loginProcess.getAuthContext()).willReturn(authContextLocalWrapper);
    PagePropertiesCallback pagePropertiesCallback = mock(PagePropertiesCallback.class);
    given(pagePropertiesCallback.getTemplateName()).willReturn("TEMPLATE_NAME");
    given(pagePropertiesCallback.getModuleName()).willReturn("MODULE_NAME");
    given(pagePropertiesCallback.getPageState()).willReturn("PAGE_STATE");
    JsonValue jsonCallbacks = new JsonValue(new HashMap<String, Object>());
    jsonCallbacks.add("KEY", "VALUE");
    Map<String, String> responseHeaders = new HashMap<String, String>();
    responseHeaders.put("HEADER_KEY", "HEADER_VALUE");
    JsonValue jsonResponse = new JsonValue(new HashMap<String, Object>());
    jsonResponse.add("KEY", "VALUE");
    RestAuthResponseException restAuthResponseException = new RestAuthResponseException(999, responseHeaders, jsonResponse);
    given(loginAuthenticator.getLoginProcess(Matchers.<LoginConfiguration>anyObject())).willReturn(loginProcess);
    given(restAuthCallbackHandlerManager.handleCallbacks(request, httpResponse, callbacks)).willThrow(restAuthResponseException);
    given(authIdHelper.createAuthId(Matchers.<LoginConfiguration>anyObject(), eq(authContextLocalWrapper))).willReturn("AUTH_ID");
    //When
    try {
        restAuthenticationHandler.initiateAuthentication(request, httpResponse, authIndexType, indexValue, sessionUpgradeSSOTokenId);
    } catch (RestAuthResponseException e) {
        JsonValue response = e.getJsonResponse();
        assertEquals(response.size(), 2);
        assertEquals(response.get("authId").asString(), "AUTH_ID");
        assertEquals(response.get("KEY").asString(), "VALUE");
        Map<String, String> headers = e.getResponseHeaders();
        assertEquals(headers.get("HEADER_KEY"), "HEADER_VALUE");
        assertEquals(e.getStatusCode(), 999);
        return;
    }
    //Then
    fail();
}
Also used : PagePropertiesCallback(com.sun.identity.authentication.spi.PagePropertiesCallback) HashMap(java.util.HashMap) JsonValue(org.forgerock.json.JsonValue) HttpServletResponse(javax.servlet.http.HttpServletResponse) AuthContextLocalWrapper(org.forgerock.openam.core.rest.authn.core.wrappers.AuthContextLocalWrapper) LoginProcess(org.forgerock.openam.core.rest.authn.core.LoginProcess) HttpServletRequest(javax.servlet.http.HttpServletRequest) PagePropertiesCallback(com.sun.identity.authentication.spi.PagePropertiesCallback) Callback(javax.security.auth.callback.Callback) RestAuthResponseException(org.forgerock.openam.core.rest.authn.exceptions.RestAuthResponseException) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.testng.annotations.Test)

Example 4 with PagePropertiesCallback

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

the class RestAuthenticationHandlerTest method shouldInitiateAuthenticationViaGET2.

@Test
public void shouldInitiateAuthenticationViaGET2() throws AuthLoginException, L10NMessageImpl, JSONException, IOException, RestAuthResponseException, SignatureException, RestAuthException {
    //Given
    HttpServletRequest request = mock(HttpServletRequest.class);
    HttpServletResponse httpResponse = mock(HttpServletResponse.class);
    String authIndexType = null;
    String indexValue = null;
    String sessionUpgradeSSOTokenId = null;
    Callback callbackOne = mock(Callback.class);
    Callback callbackTwo = mock(Callback.class);
    Callback[] callbacks = new Callback[] { callbackOne, callbackTwo };
    PagePropertiesCallback pagePropertiesCallback = mock(PagePropertiesCallback.class);
    given(pagePropertiesCallback.getTemplateName()).willReturn("TEMPLATE_NAME");
    given(pagePropertiesCallback.getModuleName()).willReturn("MODULE_NAME");
    given(pagePropertiesCallback.getPageState()).willReturn("PAGE_STATE");
    given(pagePropertiesCallback.getHeader()).willReturn("HEADER");
    AuthContextLocalWrapper authContextLocalWrapper = mock(AuthContextLocalWrapper.class);
    LoginProcess loginProcess = mock(LoginProcess.class);
    given(loginProcess.getLoginStage()).willReturn(LoginStage.REQUIREMENTS_WAITING);
    given(loginProcess.getCallbacks()).willReturn(callbacks);
    given(loginProcess.getPagePropertiesCallback()).willReturn(pagePropertiesCallback);
    given(loginProcess.getAuthContext()).willReturn(authContextLocalWrapper);
    JsonValue jsonCallbacks = new JsonValue(new HashMap<String, Object>());
    jsonCallbacks.add("KEY", "VALUE");
    given(loginAuthenticator.getLoginProcess(Matchers.<LoginConfiguration>anyObject())).willReturn(loginProcess);
    given(restAuthCallbackHandlerManager.handleCallbacks(request, httpResponse, callbacks)).willReturn(jsonCallbacks);
    given(authIdHelper.createAuthId(Matchers.<LoginConfiguration>anyObject(), eq(authContextLocalWrapper))).willReturn("AUTH_ID");
    //When
    JsonValue response = restAuthenticationHandler.initiateAuthentication(request, httpResponse, authIndexType, indexValue, sessionUpgradeSSOTokenId);
    //Then
    assertEquals(response.size(), 5);
    assertEquals(response.get("authId").asString(), "AUTH_ID");
    assertEquals(response.get("template").asString(), "TEMPLATE_NAME");
    assertEquals(response.get("stage").asString(), "MODULE_NAMEPAGE_STATE");
    assertEquals(response.get("header").asString(), "HEADER");
    assertEquals(response.get("callbacks").get("KEY").asString(), "VALUE");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PagePropertiesCallback(com.sun.identity.authentication.spi.PagePropertiesCallback) Callback(javax.security.auth.callback.Callback) PagePropertiesCallback(com.sun.identity.authentication.spi.PagePropertiesCallback) JsonValue(org.forgerock.json.JsonValue) HttpServletResponse(javax.servlet.http.HttpServletResponse) AuthContextLocalWrapper(org.forgerock.openam.core.rest.authn.core.wrappers.AuthContextLocalWrapper) LoginProcess(org.forgerock.openam.core.rest.authn.core.LoginProcess) Test(org.testng.annotations.Test)

Example 5 with PagePropertiesCallback

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

the class OpenAMAuthHandler method isNextCallbackSetAvailable.

/**
     * Obtains the next set of OpenAM authorization callbacks, updating our info set or sets the callbacks to null if
     * unable to acquire and update the info set and sends an accessReject response in that case. Returns true if
     * callback set was loaded into holder. Returns false if they couldn't be loaded or were empty which may be a valid
     * state depending on the caller. Sets holder.authPhase = TERMINATED if something happened causing the
     * authentication process to fail.
     *
     * @param context
     * @param holder
     * @return
     */
private boolean isNextCallbackSetAvailable(RadiusResponse response, ContextHolder holder) {
    final boolean moreCallbacksAvailable = holder.getAuthContext().hasMoreRequirements();
    if (!moreCallbacksAvailable) {
        // cLog.warning("--- no callbacks available, set callbacks=null in isNextCallbackSetAvailable");
        holder.setCallbacks(null);
        return false;
    }
    // true means do NOT filter PagePropertiesCallbacks
    final Callback[] callbacks = holder.getAuthContext().getRequirements(true);
    holder.setCallbacks(callbacks);
    if (holder.getCallbacks() == null) {
        // cLog.warning("--- callbacks == null after ac.getReqs() called in isNextCallbackSetAvailable");
        return false;
    }
    // process page properties piece
    if (callbacks[0] instanceof PagePropertiesCallback) {
        // not a formal callback, openam specific
        final PagePropertiesCallback pp = (PagePropertiesCallback) callbacks[0];
        holder.setCallbackSetProps(pp);
        // since page properties cb is at zero index
        holder.setIdxOfCurrentCallback(1);
        final String moduleName = pp.getModuleName();
        if (!moduleName.equals(holder.getModuleName())) {
            // entering new module
            holder.setModuleName(moduleName);
            holder.incrementChainModuleIndex();
            holder.setIdxOfCallbackSetInModule(0);
        // cLog.warning("New Module Incurred: " + holder.moduleName + " with callbacks["
        // + holder.callbacks.length + "]");
        } else {
            holder.incrementIdxOfCallbackSetInModule();
        // cLog.warning("New Callback Set[" + holder.callbacks.length + "] Incurred in Module: "
        // + holder.moduleName);
        }
        // update the
        holder.setMillisExpiryForCurrentCallbacks(1000L * pp.getTimeOutValue());
        holder.setMillisExpiryPoint(System.currentTimeMillis() + holder.getMillisExpiryForCurrentCallbacks());
    } else {
        LOG.error("Callback at index 0 is not of type PagePropertiesCallback!!!");
        rejectAccessAndTerminateProcess(response, holder);
        return false;
    }
    // now fail fast if we find unsupportable callback types
    boolean httpCbIncurred = false;
    boolean redirectCbIncurred = false;
    for (int i = 1; i < callbacks.length; i++) {
        final Callback cb = callbacks[i];
        if (cb instanceof HttpCallback) {
            httpCbIncurred = true;
            break;
        } else if (cb instanceof RedirectCallback) {
            redirectCbIncurred = true;
            break;
        }
    }
    if (httpCbIncurred || redirectCbIncurred) {
        LOG.error("Radius can not support " + (httpCbIncurred ? HttpCallback.class.getSimpleName() : RedirectCallback.class.getSimpleName()) + " used by module " + holder.getChainModuleIndex() + " with name " + holder.getModuleName() + " in chain '" + this.authChain + "'. Denying Access.");
        rejectAccessAndTerminateProcess(response, holder);
        return false;
    }
    return true;
}
Also used : RedirectCallback(com.sun.identity.authentication.spi.RedirectCallback) PagePropertiesCallback(com.sun.identity.authentication.spi.PagePropertiesCallback) HttpCallback(com.sun.identity.authentication.spi.HttpCallback) RedirectCallback(com.sun.identity.authentication.spi.RedirectCallback) PasswordCallback(javax.security.auth.callback.PasswordCallback) ChoiceCallback(javax.security.auth.callback.ChoiceCallback) NameCallback(javax.security.auth.callback.NameCallback) ConfirmationCallback(javax.security.auth.callback.ConfirmationCallback) Callback(javax.security.auth.callback.Callback) PagePropertiesCallback(com.sun.identity.authentication.spi.PagePropertiesCallback) HttpCallback(com.sun.identity.authentication.spi.HttpCallback)

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