Examples of SAMLSSORespDTO


Examples of org.wso2.carbon.identity.sso.saml.dto.SAMLSSORespDTO

            //authenticate the user, if required
            if (!isAuthencated && authMode.equals(SAMLSSOConstants.AuthnModes.USERNAME_PASSWORD)) {
                if (!authenticate(authnReqDTO.getUsername(), authnReqDTO.getPassword())) {
                    log.warn("Authentication Failure, invalid username or password.");
                    SAMLSSORespDTO errorResp = buildErrorResponse(authnReqDTO.getId(), SAMLSSOConstants.StatusCodes.AUTHN_FAILURE,
                            "Authentication Failure, invalid username or password.");
                    errorResp.setLoginPageURL(authnReqDTO.getLoginPageURL());
                    return errorResp;
                }
                SAMLSSOServiceProviderDO spDO = new SAMLSSOServiceProviderDO();
                spDO.setIssuer(authnReqDTO.getIssuer());
                spDO.setAssertionConsumerUrl(authnReqDTO.getAssertionConsumerURL());
                spDO.setCertAlias(authnReqDTO.getCertAlias());
                spDO.setLogoutURL(authnReqDTO.getLogoutURL());
                sessionPersistenceManager.persistSession(sessionId, authnReqDTO.getUsername(),
                                                         spDO, authnReqDTO.getRpSessionId());
            }

            if (isAuthencated && authMode.equals(SAMLSSOConstants.AuthnModes.USERNAME_PASSWORD)) {
                SessionInfoData sessionInfo = sessionPersistenceManager.getSessionInfo(sessionId);
                authnReqDTO.setUsername(sessionInfo.getSubject());
                sessionPersistenceManager.persistSession(sessionId, authnReqDTO.getIssuer(),
                        authnReqDTO.getAssertionConsumerURL(), authnReqDTO.getRpSessionId());
            }

            if(isAuthencated && authMode.equals(SAMLSSOConstants.AuthnModes.OPENID)){
                SAMLSSOServiceProviderDO spDO = new SAMLSSOServiceProviderDO();
                spDO.setIssuer(authnReqDTO.getIssuer());
                spDO.setAssertionConsumerUrl(authnReqDTO.getAssertionConsumerURL());
                spDO.setCertAlias(authnReqDTO.getCertAlias());
                spDO.setLogoutURL(authnReqDTO.getLogoutURL());
                sessionPersistenceManager.persistSession(sessionId, authnReqDTO.getUsername(),
                                                         spDO, authnReqDTO.getRpSessionId());
            }

            //Build the response for the successful scenario
            ResponseBuilder respBuilder = new ResponseBuilder();
            Response response = respBuilder.buildResponse(authnReqDTO, sessionId);
            SAMLSSORespDTO samlssoRespDTO = new SAMLSSORespDTO();
            samlssoRespDTO.setRespString(SAMLSSOUtil.encode(SAMLSSOUtil.marshall(response)));
            samlssoRespDTO.setSessionEstablished(true);
            samlssoRespDTO.setAssertionConsumerURL(authnReqDTO.getAssertionConsumerURL());
            samlssoRespDTO.setLoginPageURL(authnReqDTO.getLoginPageURL());
            return samlssoRespDTO;

        } catch (Exception e) {
            log.error("Error processing the authentication request",e);
            SAMLSSORespDTO errorResp =  buildErrorResponse(authnReqDTO.getId(), SAMLSSOConstants.StatusCodes.AUTHN_FAILURE,
                            "Authentication Failure, invalid username or password.");
            errorResp.setLoginPageURL(authnReqDTO.getLoginPageURL());
            return errorResp;
        }
    }
View Full Code Here

Examples of org.wso2.carbon.identity.sso.saml.dto.SAMLSSORespDTO

        else{
            authReqDTO.setUsername(valiationDTO.getSubject());
        }

        SAMLSSOReqValidationResponseDTO responseDTO = new SAMLSSOReqValidationResponseDTO();
        SAMLSSORespDTO respDTO = process(authReqDTO, sessionId, true, authMode);
        responseDTO.setValid(true);
        responseDTO.setResponse(respDTO.getRespString());
        responseDTO.setAssertionConsumerURL(respDTO.getAssertionConsumerURL());
        responseDTO.setLoginPageURL(respDTO.getLoginPageURL());
        return responseDTO;
    }
View Full Code Here

Examples of org.wso2.carbon.identity.sso.saml.dto.SAMLSSORespDTO

        responseDTO.setLoginPageURL(respDTO.getLoginPageURL());
        return responseDTO;
    }

    private SAMLSSORespDTO buildErrorResponse(String id, String status, String statMsg) throws Exception {
        SAMLSSORespDTO samlSSORespDTO = new SAMLSSORespDTO();
        ErrorResponseBuilder errRespBuilder = new ErrorResponseBuilder();
        Response resp = errRespBuilder.buildResponse(id, status, statMsg);
        samlSSORespDTO.setRespString(SAMLSSOUtil.encode(SAMLSSOUtil.marshall(resp)));
        samlSSORespDTO.setSessionEstablished(false);
        return samlSSORespDTO;
    }
View Full Code Here

Examples of org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSORespDTO

        authnReqDTO.setSubject(validationResponseDTO.getSubject());
        authnReqDTO.setRpSessionId(validationResponseDTO.getRpSessionId());
        authnReqDTO.setAssertionString(validationResponseDTO.getAssertionString());

        // authenticate the user
        SAMLSSORespDTO authRespDTO = ssoServiceClient.authenticate(authnReqDTO, ssoTokenID);

        if (authRespDTO.getSessionEstablished()) {  // authentication is SUCCESSFUL
            storeSSOTokenCookie(ssoTokenID, httpServletRequest, httpServletResponse);
            String respSessionAuthID = sessionManager.addNewSession(new FESessionBean(authRespDTO, sessionBean.getRelayState()));
            sessionManager.removeSession(authSessionID);    // remove the SAMLSSORespDTO
            httpServletResponse.sendRedirect(getAdminConsoleURL(httpServletRequest) + "sso-saml/redirect_ajaxprocessor.jsp?" + SAMLSSOProviderConstants.FE_SESSION_KEY + "=" + respSessionAuthID);
        } else {    // authentication FAILURE
            validationResponseDTO.setValid(false);
            httpServletResponse.sendRedirect(calculateLoginPage(
                        getAdminConsoleURL(httpServletRequest), authRespDTO.getLoginPageURL())+ "?" + SAMLSSOProviderConstants.FE_SESSION_KEY + "=" + authSessionID);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.