Package org.exoplatform.services.security

Examples of org.exoplatform.services.security.IdentityRegistry


  {
    try
    {
      if (super.commit())
      {
        IdentityRegistry identityRegistry = (IdentityRegistry) getContainer()
            .getComponentInstanceOfType(IdentityRegistry.class);

        // Check for single check
        if (identityRegistry.getIdentity(this.identity.getUserId()) != null)
        {
          // already logged in
          return true;
        }

        this.identity.setSubject(this.subject);
        identityRegistry.register(this.identity);

        return true;
      }
      else
      {
View Full Code Here


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

   private ConversationState getConversationState() throws Exception
   {
      ExoContainer container = ExoContainerContext.getCurrentContainer();
      Authenticator authenticator = (Authenticator)container.getComponentInstanceOfType(Authenticator.class);

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

      if (authenticator == null)
         throw new LoginException("No Authenticator component found, check your configuration");

      Credential[] credentials =
         new Credential[]{new UsernameCredential(this.userName), new PasswordCredential(this.userPass)};

      this.userId = authenticator.validateUser(credentials);
      Identity identity = authenticator.createIdentity(this.userId);
      identityRegistry.register(identity);

      ConversationState state = new ConversationState(identity);
      // keep subject as attribute in ConversationState
      state.setAttribute(ConversationState.SUBJECT, identity.getSubject());
View Full Code Here

   private void unRegistrateIdentity()
   {
      ConversationState.setCurrent(null);

      ExoContainer container = ExoContainerContext.getCurrentContainer();
      IdentityRegistry identityRegistry =
         (IdentityRegistry)container.getComponentInstanceOfType(IdentityRegistry.class);

      // The check need for case when login failed
      if (this.userId != null)
      {
         identityRegistry.unregister(this.userId);
      }
   }
View Full Code Here

TOP

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

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.