Package org.exoplatform.services.security

Examples of org.exoplatform.services.security.ConversationState


         // login via Authenticator
         Authenticator authr = (Authenticator)container.getComponentInstanceOfType(Authenticator.class);
         String validUser =
            authr.validateUser(new Credential[]{new UsernameCredential("root"), new PasswordCredential("exo")});
         Identity id = authr.createIdentity(validUser);
         ConversationState s = new ConversationState(id);
         ConversationState.setCurrent(s);

         ctx = new CliAppContext(repService.getDefaultRepository(), PARAMETERS_KEY);
         Node root = ctx.getSession().getRootNode();
         ctx.setCurrentItem(root);
View Full Code Here


            "Credentials for the authentication should be CredentialsImpl or SimpleCredentials type");
      }

      SessionFactory sessionFactory = (SessionFactory)container.getComponentInstanceOfType(SessionFactory.class);

      ConversationState newState =
         new ConversationState(new Identity(name, userState.getIdentity().getMemberships(), userState.getIdentity()
            .getRoles()));
      return sessionFactory.createSession(newState);

   }
View Full Code Here

            "Credentials for the authentication should be CredentialsImpl or SimpleCredentials type");
      }

      SessionFactory sessionFactory = (SessionFactory)container.getComponentInstanceOfType(SessionFactory.class);

      ConversationState newState =
         new ConversationState(new Identity(name, userState.getIdentity().getMemberships(), userState.getIdentity()
            .getRoles()));
      return sessionFactory.createSession(newState);

   }
View Full Code Here

   {

      if (getState() == OFFLINE)
         LOG.warn("Repository " + getName() + " is OFFLINE.");

      ConversationState state;

      if (credentials != null)
         state = authenticationPolicy.authenticate(credentials);
      else
         state = authenticationPolicy.authenticate();
View Full Code Here

            OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
            WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
            PortalRequestContext prContext = Util.getPortalRequestContext();
            UIApplication uiApp = context.getUIApplication();

            ConversationState state = ConversationState.getCurrent();
            String userName = ((User) state.getAttribute(CacheUserProfileFilter.USER_PROFILE)).getUserName();
            User user = service.getUserHandler().findUserByName(userName);

            if (user != null) {
                UserProfile userProfile = (UserProfile)prContext.getAttribute(UserProfileLifecycle.USER_PROFILE_ATTRIBUTE_NAME);
View Full Code Here

      SessionFactory sessionFactory = workspaceContainer.getSessionFactory();

      Identity id = new Identity(DynamicIdentity.DYNAMIC, membershipEntries);

      return sessionFactory.createSession(new ConversationState(id));
   }
View Full Code Here

   {

      if (getState() == OFFLINE)
         LOG.warn("Repository " + getName() + " is OFFLINE.");

      ConversationState state;

      if (credentials != null)
         state = authenticationPolicy.authenticate(credentials);
      else
         state = authenticationPolicy.authenticate();
View Full Code Here

      ExoContainer container = getContainer();

      try
      {
         ExoContainerContext.setCurrentContainer(container);
         ConversationState state = getCurrentState(container, httpRequest);
         // NOTE may be set as null
         ConversationState.setCurrent(state);
         if (state != null && log.isDebugEnabled())
            log.debug(">>> Memberships " + state.getIdentity().getMemberships());
         chain.doFilter(request, response);
      }
      finally
      {
         try
View Full Code Here

         (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.");
View Full Code Here

      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

TOP

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

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.