Search in sources :

Example 6 with SessionId

use of org.gluu.oxauth.model.common.SessionId in project oxAuth by GluuFederation.

the class AuthorizeAction method permissionGranted.

public void permissionGranted() {
    final SessionId session = getSession();
    permissionGranted(session);
}
Also used : SessionId(org.gluu.oxauth.model.common.SessionId)

Example 7 with SessionId

use of org.gluu.oxauth.model.common.SessionId in project oxAuth by GluuFederation.

the class AuthorizeAction method permissionDenied.

public void permissionDenied() {
    final SessionId session = getSession();
    authorizeService.permissionDenied(session);
}
Also used : SessionId(org.gluu.oxauth.model.common.SessionId)

Example 8 with SessionId

use of org.gluu.oxauth.model.common.SessionId in project oxAuth by GluuFederation.

the class ConsentGatheringSessionService method getConsentSession.

public SessionId getConsentSession(HttpServletRequest httpRequest, HttpServletResponse httpResponse, String userDn, boolean create) {
    String cookieId = cookieService.getConsentSessionIdFromCookie(httpRequest);
    log.trace("Cookie - consent_session_id: {}", cookieId);
    if (StringUtils.isNotBlank(cookieId)) {
        SessionId sessionId = sessionIdService.getSessionId(cookieId);
        if (sessionId != null) {
            log.trace("Loaded consent_session_id from cookie, session: {}", sessionId);
            return sessionId;
        } else {
            log.error("Failed to load consent_session_id from cookie: {}", cookieId);
        }
    } else {
        if (!create) {
            log.error("consent_session_id cookie is not set.");
        }
    }
    if (!create) {
        return null;
    }
    log.trace("Generating new consent_session_id ...");
    SessionId session = sessionIdService.generateUnauthenticatedSessionId(userDn);
    cookieService.createCookieWithState(session.getId(), session.getSessionState(), session.getOPBrowserState(), httpRequest, httpResponse, CookieService.CONSENT_SESSION_ID_COOKIE_NAME);
    log.trace("consent_session_id cookie created.");
    return session;
}
Also used : SessionId(org.gluu.oxauth.model.common.SessionId)

Example 9 with SessionId

use of org.gluu.oxauth.model.common.SessionId in project oxAuth by GluuFederation.

the class Authenticator method authenticate.

/**
 * Tries to authenticate an user, returns <code>true</code> if the
 * authentication succeed
 *
 * @return Returns <code>true</code> if the authentication succeed
 */
public boolean authenticate() {
    HttpServletRequest servletRequest = (HttpServletRequest) facesContext.getExternalContext().getRequest();
    final SessionId sessionId = getSessionId(servletRequest);
    if (sessionIdService.isSessionIdAuthenticated(sessionId)) {
        // #1029 : session is already authenticated, we run into second authorization
        // request
        errorHandlerService.handleError("login.userAlreadyAuthenticated", AuthorizeErrorResponseType.RETRY, "Session is already authenticated. Please re-send authorization request. If AS errorHandlingMethod=remote then RP can get redirect with error and re-send authorization request automatically.");
        return false;
    }
    lastResult = authenticateImpl(servletRequest, true, false, false);
    if (Constants.RESULT_SUCCESS.equals(lastResult)) {
        return true;
    } else if (Constants.RESULT_FAILURE.equals(lastResult)) {
        authenticationFailed();
    } else if (Constants.RESULT_NO_PERMISSIONS.equals(lastResult)) {
        handlePermissionsError();
    } else if (Constants.RESULT_EXPIRED.equals(lastResult)) {
        handleSessionInvalid();
    } else if (Constants.RESULT_AUTHENTICATION_FAILED.equals(lastResult)) {
        // Do nothing to keep compatibility with older versions
        if (facesMessages.getMessages().size() == 0) {
            addMessage(FacesMessage.SEVERITY_ERROR, "login.failedToAuthenticate");
        }
    }
    return false;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SessionId(org.gluu.oxauth.model.common.SessionId)

Example 10 with SessionId

use of org.gluu.oxauth.model.common.SessionId in project oxAuth by GluuFederation.

the class Authenticator method getFullNumber.

private String getFullNumber() {
    String phone = null;
    SessionId sessionId = sessionIdService.getSessionId();
    if (sessionId != null) {
        if (phone == null || phone.isEmpty()) {
            phone = sessionId.getSessionAttributes().get("mobile_number");
        }
        if (phone == null || phone.isEmpty()) {
            phone = sessionId.getSessionAttributes().get("mobile");
        }
    }
    return phone == null ? "UNKNOW USER PHONE." : phone;
}
Also used : SessionId(org.gluu.oxauth.model.common.SessionId)

Aggregations

SessionId (org.gluu.oxauth.model.common.SessionId)52 CustomScriptConfiguration (org.gluu.model.custom.script.conf.CustomScriptConfiguration)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)8 User (org.gluu.oxauth.model.common.User)7 Date (java.util.Date)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 URISyntaxException (java.net.URISyntaxException)4 HashMap (java.util.HashMap)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 AuthorizationGrant (org.gluu.oxauth.model.common.AuthorizationGrant)4 EntryPersistenceException (org.gluu.persist.exception.EntryPersistenceException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 BaseComponentTest (org.gluu.oxauth.BaseComponentTest)3 SimpleUser (org.gluu.oxauth.model.common.SimpleUser)3 AcrChangedException (org.gluu.oxauth.model.exception.AcrChangedException)3 InvalidSessionStateException (org.gluu.oxauth.model.exception.InvalidSessionStateException)3 Client (org.gluu.oxauth.model.registration.Client)3 ConsentGatheringContext (org.gluu.oxauth.service.external.context.ConsentGatheringContext)3 UmaGatherContext (org.gluu.oxauth.uma.authorization.UmaGatherContext)3 Parameters (org.testng.annotations.Parameters)3