Class SessionIdService


  • @RequestScoped
    @Named
    public class SessionIdService
    extends java.lang.Object
    Version:
    December 8, 2018
    Author:
    Yuriy Zabrovarnyy, Yuriy Movchan, Javier Rojas Blum
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String SESSION_CUSTOM_STATE  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<java.lang.String> acrValuesList​(java.lang.String acrValues)
      By definition we expects space separated acr values as it is defined in spec.
      io.jans.as.common.model.session.SessionId assertAuthenticatedSessionCorrespondsToNewRequest​(io.jans.as.common.model.session.SessionId session, java.lang.String acrValuesStr)  
      java.lang.String computeSessionState​(io.jans.as.common.model.session.SessionId sessionId, java.lang.String clientId, java.lang.String redirectUri)  
      void externalEvent​(SessionEvent event)  
      java.util.List<io.jans.as.common.model.session.SessionId> findByUser​(java.lang.String userDn)  
      io.jans.as.common.model.session.SessionId generateAuthenticatedSessionId​(jakarta.servlet.http.HttpServletRequest httpRequest, java.lang.String userDn)  
      io.jans.as.common.model.session.SessionId generateAuthenticatedSessionId​(jakarta.servlet.http.HttpServletRequest httpRequest, java.lang.String userDn, java.lang.String prompt)  
      io.jans.as.common.model.session.SessionId generateAuthenticatedSessionId​(jakarta.servlet.http.HttpServletRequest httpRequest, java.lang.String userDn, java.util.Map<java.lang.String,​java.lang.String> sessionIdAttributes)  
      io.jans.as.common.model.session.SessionId generateUnauthenticatedSessionId​(java.lang.String userDn)  
      io.jans.as.common.model.session.SessionId generateUnauthenticatedSessionId​(java.lang.String userDn, java.util.Date authenticationDate, io.jans.as.common.model.session.SessionIdState state, java.util.Map<java.lang.String,​java.lang.String> sessionIdAttributes, boolean persist)  
      java.lang.String getAcr​(io.jans.as.common.model.session.SessionId session)  
      java.util.Set<io.jans.as.common.model.session.SessionId> getCurrentSessions()  
      int getServerSessionIdLifetimeInSeconds()  
      java.util.Map<java.lang.String,​java.lang.String> getSessionAttributes​(io.jans.as.common.model.session.SessionId sessionId)  
      @Nullable io.jans.as.common.model.session.SessionId getSessionByDn​(@Nullable java.lang.String dn)  
      @Nullable io.jans.as.common.model.session.SessionId getSessionByDn​(@Nullable java.lang.String dn, boolean silently)  
      @Nullable io.jans.as.common.model.session.SessionId getSessionById​(@Nullable java.lang.String sessionId, boolean silently)  
      @Nullable io.jans.as.common.model.session.SessionId getSessionBySid​(@Nullable java.lang.String sid)  
      io.jans.as.common.model.session.SessionId getSessionId()  
      io.jans.as.common.model.session.SessionId getSessionId​(jakarta.servlet.http.HttpServletRequest request)  
      io.jans.as.common.model.session.SessionId getSessionId​(java.lang.String sessionId)  
      io.jans.as.common.model.session.SessionId getSessionId​(java.lang.String sessionId, boolean silently)  
      io.jans.as.common.model.common.User getUser​(io.jans.as.common.model.session.SessionId sessionId)  
      boolean isExpired​(io.jans.as.common.model.session.SessionId sessionId)  
      boolean isSessionIdAuthenticated​(io.jans.as.common.model.session.SessionId sessionId)  
      boolean isSessionValid​(io.jans.as.common.model.session.SessionId sessionId)  
      boolean persistSessionId​(io.jans.as.common.model.session.SessionId sessionId)  
      boolean persistSessionId​(io.jans.as.common.model.session.SessionId sessionId, boolean forcePersistence)  
      boolean reinitLogin​(io.jans.as.common.model.session.SessionId session, boolean force)  
      boolean remove​(io.jans.as.common.model.session.SessionId sessionId)  
      void remove​(java.util.List<io.jans.as.common.model.session.SessionId> list)  
      io.jans.as.common.model.session.SessionId resetToStep​(io.jans.as.common.model.session.SessionId session, int resetToStep)  
      io.jans.as.common.model.session.SessionId setSessionIdStateAuthenticated​(jakarta.servlet.http.HttpServletRequest httpRequest, jakarta.servlet.http.HttpServletResponse httpResponse, io.jans.as.common.model.session.SessionId sessionId, java.lang.String userDn)  
      boolean updateSessionId​(io.jans.as.common.model.session.SessionId sessionId)  
      boolean updateSessionId​(io.jans.as.common.model.session.SessionId sessionId, boolean updateLastUsedAt)  
      boolean updateSessionId​(io.jans.as.common.model.session.SessionId sessionId, boolean updateLastUsedAt, boolean forceUpdate, boolean modified)  
      void updateSessionIdIfNeeded​(io.jans.as.common.model.session.SessionId sessionId, boolean modified)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SESSION_CUSTOM_STATE

        public static final java.lang.String SESSION_CUSTOM_STATE
        See Also:
        Constant Field Values
    • Constructor Detail

      • SessionIdService

        public SessionIdService()
    • Method Detail

      • getCurrentSessions

        public java.util.Set<io.jans.as.common.model.session.SessionId> getCurrentSessions()
      • getAcr

        public java.lang.String getAcr​(io.jans.as.common.model.session.SessionId session)
      • assertAuthenticatedSessionCorrespondsToNewRequest

        public io.jans.as.common.model.session.SessionId assertAuthenticatedSessionCorrespondsToNewRequest​(io.jans.as.common.model.session.SessionId session,
                                                                                                           java.lang.String acrValuesStr)
                                                                                                    throws AcrChangedException
        Throws:
        AcrChangedException
      • reinitLogin

        public boolean reinitLogin​(io.jans.as.common.model.session.SessionId session,
                                   boolean force)
        Parameters:
        session -
        force -
        Returns:
        returns whether session was updated
      • resetToStep

        public io.jans.as.common.model.session.SessionId resetToStep​(io.jans.as.common.model.session.SessionId session,
                                                                     int resetToStep)
      • getSessionId

        public io.jans.as.common.model.session.SessionId getSessionId()
      • getSessionAttributes

        public java.util.Map<java.lang.String,​java.lang.String> getSessionAttributes​(io.jans.as.common.model.session.SessionId sessionId)
      • generateAuthenticatedSessionId

        public io.jans.as.common.model.session.SessionId generateAuthenticatedSessionId​(jakarta.servlet.http.HttpServletRequest httpRequest,
                                                                                        java.lang.String userDn,
                                                                                        java.lang.String prompt)
                                                                                 throws InvalidSessionStateException
        Throws:
        InvalidSessionStateException
      • generateAuthenticatedSessionId

        public io.jans.as.common.model.session.SessionId generateAuthenticatedSessionId​(jakarta.servlet.http.HttpServletRequest httpRequest,
                                                                                        java.lang.String userDn,
                                                                                        java.util.Map<java.lang.String,​java.lang.String> sessionIdAttributes)
                                                                                 throws InvalidSessionStateException
        Throws:
        InvalidSessionStateException
      • generateUnauthenticatedSessionId

        public io.jans.as.common.model.session.SessionId generateUnauthenticatedSessionId​(java.lang.String userDn)
      • generateUnauthenticatedSessionId

        public io.jans.as.common.model.session.SessionId generateUnauthenticatedSessionId​(java.lang.String userDn,
                                                                                          java.util.Date authenticationDate,
                                                                                          io.jans.as.common.model.session.SessionIdState state,
                                                                                          java.util.Map<java.lang.String,​java.lang.String> sessionIdAttributes,
                                                                                          boolean persist)
      • computeSessionState

        public java.lang.String computeSessionState​(io.jans.as.common.model.session.SessionId sessionId,
                                                    java.lang.String clientId,
                                                    java.lang.String redirectUri)
      • setSessionIdStateAuthenticated

        public io.jans.as.common.model.session.SessionId setSessionIdStateAuthenticated​(jakarta.servlet.http.HttpServletRequest httpRequest,
                                                                                        jakarta.servlet.http.HttpServletResponse httpResponse,
                                                                                        io.jans.as.common.model.session.SessionId sessionId,
                                                                                        java.lang.String userDn)
      • persistSessionId

        public boolean persistSessionId​(io.jans.as.common.model.session.SessionId sessionId)
      • persistSessionId

        public boolean persistSessionId​(io.jans.as.common.model.session.SessionId sessionId,
                                        boolean forcePersistence)
      • updateSessionId

        public boolean updateSessionId​(io.jans.as.common.model.session.SessionId sessionId)
      • updateSessionId

        public boolean updateSessionId​(io.jans.as.common.model.session.SessionId sessionId,
                                       boolean updateLastUsedAt)
      • updateSessionId

        public boolean updateSessionId​(io.jans.as.common.model.session.SessionId sessionId,
                                       boolean updateLastUsedAt,
                                       boolean forceUpdate,
                                       boolean modified)
      • isExpired

        public boolean isExpired​(io.jans.as.common.model.session.SessionId sessionId)
      • getServerSessionIdLifetimeInSeconds

        public int getServerSessionIdLifetimeInSeconds()
      • updateSessionIdIfNeeded

        public void updateSessionIdIfNeeded​(io.jans.as.common.model.session.SessionId sessionId,
                                            boolean modified)
      • getSessionById

        @Nullable
        public @Nullable io.jans.as.common.model.session.SessionId getSessionById​(@Nullable
                                                                                  @Nullable java.lang.String sessionId,
                                                                                  boolean silently)
      • getSessionByDn

        @Nullable
        public @Nullable io.jans.as.common.model.session.SessionId getSessionByDn​(@Nullable
                                                                                  @Nullable java.lang.String dn)
      • getSessionBySid

        @Nullable
        public @Nullable io.jans.as.common.model.session.SessionId getSessionBySid​(@Nullable
                                                                                   @Nullable java.lang.String sid)
      • getSessionByDn

        @Nullable
        public @Nullable io.jans.as.common.model.session.SessionId getSessionByDn​(@Nullable
                                                                                  @Nullable java.lang.String dn,
                                                                                  boolean silently)
      • getSessionId

        public io.jans.as.common.model.session.SessionId getSessionId​(jakarta.servlet.http.HttpServletRequest request)
      • getSessionId

        public io.jans.as.common.model.session.SessionId getSessionId​(java.lang.String sessionId)
      • getSessionId

        public io.jans.as.common.model.session.SessionId getSessionId​(java.lang.String sessionId,
                                                                      boolean silently)
      • remove

        public boolean remove​(io.jans.as.common.model.session.SessionId sessionId)
      • remove

        public void remove​(java.util.List<io.jans.as.common.model.session.SessionId> list)
      • isSessionValid

        public boolean isSessionValid​(io.jans.as.common.model.session.SessionId sessionId)
      • isSessionIdAuthenticated

        public boolean isSessionIdAuthenticated​(io.jans.as.common.model.session.SessionId sessionId)
      • acrValuesList

        public java.util.List<java.lang.String> acrValuesList​(java.lang.String acrValues)
        By definition we expects space separated acr values as it is defined in spec. But we also try maybe some client sent it to us as json array. So we try both.
        Returns:
        acr value list
      • getUser

        public io.jans.as.common.model.common.User getUser​(io.jans.as.common.model.session.SessionId sessionId)
      • findByUser

        public java.util.List<io.jans.as.common.model.session.SessionId> findByUser​(java.lang.String userDn)
      • externalEvent

        public void externalEvent​(SessionEvent event)