Package org.exoplatform.services.security

Examples of org.exoplatform.services.security.ConversationRegistry


   public void sessionDestroyed(HttpSessionEvent event)
   {
      HttpSession httpSession = event.getSession();
      StateKey stateKey = new HttpSessionStateKey(httpSession);

      ConversationRegistry conversationRegistry =
         (ConversationRegistry)getContainer(httpSession.getServletContext()).getComponentInstanceOfType(
            ConversationRegistry.class);

      ConversationState conversationState = conversationRegistry.unregister(stateKey);

      if (conversationState != null)
         if (log.isDebugEnabled())
            log.debug("Remove conversation state " + httpSession.getId());
View Full Code Here


   /**
    * Gives the current state
    */
   private ConversationState getCurrentState(ExoContainer container, HttpServletRequest httpRequest)
   {
      ConversationRegistry conversationRegistry =
         (ConversationRegistry)container.getComponentInstanceOfType(ConversationRegistry.class);

      IdentityRegistry identityRegistry =
         (IdentityRegistry)container.getComponentInstanceOfType(IdentityRegistry.class);

      ConversationState state = null;
      String userId = httpRequest.getRemoteUser();

      // only if user authenticated, otherwise there is no reason to do anythings
      if (userId != null)
      {
         HttpSession httpSession = httpRequest.getSession();
         StateKey stateKey = new HttpSessionStateKey(httpSession);

         if (log.isDebugEnabled())
         {
            log.debug("Looking for Conversation State " + httpSession.getId());
         }

         state = conversationRegistry.getState(stateKey);

         if (state == null)
         {
            if (log.isDebugEnabled())
            {
               log.debug("Conversation State not found, try create new one.");
            }

            Identity identity = identityRegistry.getIdentity(userId);
            if (identity != null)
            {
               state = new ConversationState(identity);
               // Keep subject as attribute in ConversationState.
               // TODO remove this, do not need it any more.
               state.setAttribute(ConversationState.SUBJECT, identity.getSubject());
            }
            else
            {
               if (restoreIdentity)
               {
                  if (log.isDebugEnabled())
                  {
                     log.debug("Not found identity for " + userId + " try to restore it. ");
                  }

                  Authenticator authenticator =
                     (Authenticator)container.getComponentInstanceOfType(Authenticator.class);
                  try
                  {
                     identity = authenticator.createIdentity(userId);
                     identityRegistry.register(identity);
                  }
                  catch (Exception e)
                  {
                     log.error("Unable restore identity. " + e.getMessage(), e);
                  }

                  if (identity != null)
                  {
                     state = new ConversationState(identity);
                  }
               }
               else
               {
                  log.error("Not found identity in IdentityRegistry for user " + userId + ", check Login Module.");
               }
            }

            if (state != null)
            {
               conversationRegistry.register(stateKey, state);
               if (log.isDebugEnabled())
               {
                  log.debug("Register Conversation state " + httpSession.getId());
               }
            }
View Full Code Here

      HttpSession httpSession = event.getSession();
      StateKey stateKey = new HttpSessionStateKey(httpSession);
      try
      {
         ExoContainer container = getContainer(httpSession.getServletContext());
         ConversationRegistry conversationRegistry =
            (ConversationRegistry)container.getComponentInstanceOfType(ConversationRegistry.class);

         ConversationState conversationState = conversationRegistry.unregister(stateKey);

         if (conversationState != null)
         {
            if (log.isDebugEnabled())
               log.debug("Remove conversation state " + httpSession.getId());
View Full Code Here

   public void sessionDestroyed(HttpSessionEvent event)
   {
      HttpSession httpSession = event.getSession();
      StateKey stateKey = new HttpSessionStateKey(httpSession);

      ConversationRegistry conversationRegistry =
         (ConversationRegistry)getContainer(httpSession.getServletContext()).getComponentInstanceOfType(
            ConversationRegistry.class);

      ConversationState conversationState = conversationRegistry.unregister(stateKey);

      if (conversationState != null)
         if (LOG.isDebugEnabled())
            LOG.debug("Remove conversation state " + httpSession.getId());
View Full Code Here

   /**
    * Gives the current state
    */
   private ConversationState getCurrentState(ExoContainer container, HttpServletRequest httpRequest)
   {
      ConversationRegistry conversationRegistry =
         (ConversationRegistry)container.getComponentInstanceOfType(ConversationRegistry.class);

      IdentityRegistry identityRegistry =
         (IdentityRegistry)container.getComponentInstanceOfType(IdentityRegistry.class);

      ConversationState state = null;
      String userId = httpRequest.getRemoteUser();

      // only if user authenticated, otherwise there is no reason to do anythings
      if (userId != null)
      {
         HttpSession httpSession = httpRequest.getSession();
         StateKey stateKey = new HttpSessionStateKey(httpSession);

         if (log.isDebugEnabled())
         {
            log.debug("Looking for Conversation State " + httpSession.getId());
         }

         state = conversationRegistry.getState(stateKey);

         if (state == null)
         {
            if (log.isDebugEnabled())
            {
               log.debug("Conversation State not found, try create new one.");
            }

            Identity identity = identityRegistry.getIdentity(userId);
            if (identity != null)
            {
               state = new ConversationState(identity);
               // Keep subject as attribute in ConversationState.
               // TODO remove this, do not need it any more.
               state.setAttribute(ConversationState.SUBJECT, identity.getSubject());
            }
            else
            {
               if (restoreIdentity)
               {
                  if (log.isDebugEnabled())
                  {
                     log.debug("Not found identity for " + userId + " try to restore it. ");
                  }

                  Authenticator authenticator =
                     (Authenticator)container.getComponentInstanceOfType(Authenticator.class);
                  try
                  {
                     identity = authenticator.createIdentity(userId);
                     identityRegistry.register(identity);
                  }
                  catch (Exception e)
                  {
                     log.error("Unable restore identity. " + e.getMessage(), e);
                  }

                  if (identity != null)
                  {
                     state = new ConversationState(identity);
                  }
               }
               else
               {
                  log.error("Not found identity in IdentityRegistry for user " + userId + ", check Login Module.");
               }
            }

            if (state != null)
            {
               conversationRegistry.register(stateKey, state);
               if (log.isDebugEnabled())
               {
                  log.debug("Register Conversation state " + httpSession.getId());
               }
            }
View Full Code Here

   public void sessionDestroyed(HttpSessionEvent event)
   {
      HttpSession httpSession = event.getSession();
      StateKey stateKey = new HttpSessionStateKey(httpSession);

      ConversationRegistry conversationRegistry =
         (ConversationRegistry)getContainer(httpSession.getServletContext()).getComponentInstanceOfType(
            ConversationRegistry.class);

      ConversationState conversationState = conversationRegistry.unregister(stateKey);

      if (conversationState != null)
         if (LOG.isDebugEnabled())
            LOG.debug("Remove conversation state " + httpSession.getId());
View Full Code Here

      HttpSession httpSession = event.getSession();
      StateKey stateKey = new HttpSessionStateKey(httpSession);
      try
      {
         ExoContainer container = getContainer(httpSession.getServletContext());
         ConversationRegistry conversationRegistry =
            (ConversationRegistry)container.getComponentInstanceOfType(ConversationRegistry.class);

         ConversationState conversationState = conversationRegistry.unregister(stateKey);

         if (conversationState != null)
         {
            if (LOG.isDebugEnabled())
               LOG.debug("Remove conversation state " + httpSession.getId());
View Full Code Here

      StateKey stateKey = new HttpSessionStateKey(httpSession);

      ExoContainer container = getContainerIfPresent(httpSession.getServletContext());
      if (container != null)
      {
         ConversationRegistry conversationRegistry =
            (ConversationRegistry)container.getComponentInstanceOfType(ConversationRegistry.class);

         ConversationState conversationState = conversationRegistry.unregister(stateKey);

         if (conversationState != null)
            if (LOG.isDebugEnabled())
               LOG.debug("Remove conversation state " + httpSession.getId());
      }
View Full Code Here

   /**
    * Gives the current state
    */
   private ConversationState getCurrentState(ExoContainer container, HttpServletRequest httpRequest)
   {
      ConversationRegistry conversationRegistry =
         (ConversationRegistry)container.getComponentInstanceOfType(ConversationRegistry.class);

      IdentityRegistry identityRegistry =
         (IdentityRegistry)container.getComponentInstanceOfType(IdentityRegistry.class);

      ConversationState state = null;
      String userId = httpRequest.getRemoteUser();

      // only if user authenticated, otherwise there is no reason to do anythings
      if (userId != null)
      {
         HttpSession httpSession = httpRequest.getSession();
         StateKey stateKey = new HttpSessionStateKey(httpSession);

         if (LOG.isDebugEnabled())
         {
            LOG.debug("Looking for Conversation State " + httpSession.getId());
         }

         state = conversationRegistry.getState(stateKey);

         if (state == null)
         {
            if (LOG.isDebugEnabled())
            {
               LOG.debug("Conversation State not found, try create new one.");
            }

            Identity identity = identityRegistry.getIdentity(userId);
            if (identity != null)
            {
               state = new ConversationState(identity);
               // Keep subject as attribute in ConversationState.
               state.setAttribute(ConversationState.SUBJECT, identity.getSubject());
            }
            else
            {
               if (restoreIdentity)
               {
                  if (LOG.isDebugEnabled())
                  {
                     LOG.debug("Not found identity for " + userId + " try to restore it. ");
                  }

                  Authenticator authenticator =
                     (Authenticator)container.getComponentInstanceOfType(Authenticator.class);
                  try
                  {
                     identity = authenticator.createIdentity(userId);
                     identityRegistry.register(identity);
                  }
                  catch (Exception e)
                  {
                     LOG.error("Unable restore identity. " + e.getMessage(), e);
                  }

                  if (identity != null)
                  {
                     state = new ConversationState(identity);
                  }
               }
               else
               {
                  LOG.error("Not found identity in IdentityRegistry for user " + userId + ", check Login Module.");
               }
            }

            if (state != null)
            {
               conversationRegistry.register(stateKey, state);
               if (LOG.isDebugEnabled())
               {
                  LOG.debug("Register Conversation state " + httpSession.getId());
               }
            }
View Full Code Here

      try
      {
         ExoContainer container = getContainerIfPresent(httpSession.getServletContext());
         if (container != null)
         {
            ConversationRegistry conversationRegistry =
               (ConversationRegistry)container.getComponentInstanceOfType(ConversationRegistry.class);

            ConversationState conversationState = conversationRegistry.unregister(stateKey);

            if (conversationState != null)
            {
               if (LOG.isDebugEnabled())
                  LOG.debug("Remove conversation state " + httpSession.getId());
View Full Code Here

TOP

Related Classes of org.exoplatform.services.security.ConversationRegistry

Copyright © 2018 www.massapicom. 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.