Package org.exoplatform.services.security

Examples of org.exoplatform.services.security.Authenticator


            // Now add our user to requested group
            log.info("User " + identity.getUserId() + " will be added to group " + groupId + " as " + membershipType + ".");
            addUserToPlatformUsers(identity.getUserId());

            // Recreate identity
            Authenticator authenticator = (Authenticator) getContainer().getComponentInstanceOfType(Authenticator.class);
            identity = authenticator.createIdentity(identity.getUserId());
            sharedState.put("exo.security.identity", identity);
            return true;
        } catch (Exception e) {
            LoginException le = new LoginException();
            le.initCause(e);
View Full Code Here


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

      }

      String userId = (String)sharedState.get("javax.security.auth.login.name");
      try
      {
         Authenticator authenticator = (Authenticator)getContainer().getComponentInstanceOfType(Authenticator.class);

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

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

         if (singleLogin && identityRegistry.getIdentity(userId) != null)
            throw new LoginException("User " + userId + " already logined.");

         Identity identity = authenticator.createIdentity(userId);
         // TODO Remove subject from identity if nod need it in eXo environment.
         // Do not need implement logout by self if use tomcat 6.0.21 and later.
         // See deprecation comments in
         // org.exoplatform.services.security.web.JAASConversationStateListener
         identity.setSubject(subject);
View Full Code Here

         String username = (String)sharedState.get("javax.security.auth.login.name");
         String password = (String)sharedState.get("javax.security.auth.login.password");
         if (username == null || password == null)
            return false;

         Authenticator authenticator = (Authenticator)getContainer().getComponentInstanceOfType(Authenticator.class);

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

         Credential[] credentials =
            new Credential[]{new UsernameCredential(username), new PasswordCredential(password)};

         String userId = authenticator.validateUser(credentials);
         Identity identity = authenticator.createIdentity(userId);

         sharedState.put("exo.security.identity", identity);
         sharedState.put("javax.security.auth.login.name", userId);
         // TODO use PasswordCredential wrapper
         subject.getPrivateCredentials().add(password);
View Full Code Here

            String password = new String(((PasswordCallback)callbacks[1]).getPassword());
            ((PasswordCallback)callbacks[1]).clearPassword();
            if (username == null || password == null)
               return false;

            Authenticator authenticator = (Authenticator)getContainer().getComponentInstanceOfType(Authenticator.class);

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

            Credential[] credentials =
               new Credential[]{new UsernameCredential(username), new PasswordCredential(password)};

            String userId = authenticator.validateUser(credentials);
            identity = authenticator.createIdentity(userId);
            sharedState.put("javax.security.auth.login.name", userId);
            // TODO use PasswordCredential wrapper
            subject.getPrivateCredentials().add(password);
            subject.getPublicCredentials().add(new UsernameCredential(username));
         }
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

      }

      String userId = (String)sharedState.get("javax.security.auth.login.name");
      try
      {
         Authenticator authenticator = (Authenticator)getContainer().getComponentInstanceOfType(Authenticator.class);

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

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

         if (singleLogin && identityRegistry.getIdentity(userId) != null)
            throw new LoginException("User " + userId + " already logined.");

         Identity identity = authenticator.createIdentity(userId);
         identity.setSubject(subject);

         identityRegistry.register(identity);

      }
View Full Code Here

            String password = new String(((PasswordCallback)callbacks[1]).getPassword());
            ((PasswordCallback)callbacks[1]).clearPassword();
            if (username == null || password == null)
               return false;

            Authenticator authenticator = (Authenticator)getContainer().getComponentInstanceOfType(Authenticator.class);

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

            Credential[] credentials =
               new Credential[]{new UsernameCredential(username), new PasswordCredential(password)};

            String userId = authenticator.validateUser(credentials);
            identity = authenticator.createIdentity(userId);
            sharedState.put("javax.security.auth.login.name", userId);
            // TODO use PasswordCredential wrapper
            subject.getPrivateCredentials().add(password);
            subject.getPublicCredentials().add(new UsernameCredential(username));
         }
View Full Code Here

            User user = service.getUserHandler().findUserByName(username);
            String currentPass = uiForm.getUIStringInput("currentpass").getValue();
            String newPass = uiForm.getUIStringInput("newpass").getValue();
            String confirmnewPass = uiForm.getUIStringInput("confirmnewpass").getValue();

            Authenticator authenticator = uiForm.getApplicationComponent(Authenticator.class);
            boolean authenticated;
            try {
                UsernameCredential usernameCred = new UsernameCredential(username);
                PasswordCredential passwordCred = new PasswordCredential(currentPass);
                authenticator.validateUser(new Credential[] { usernameCred, passwordCred });
                authenticated = true;
            } catch (Exception ex) {
                authenticated = false;
            }
View Full Code Here

            if (log.isDebugEnabled())
            {
               log.debug("Try create identity");
            }

            Authenticator authenticator = (Authenticator)getContainer().getComponentInstanceOfType(Authenticator.class);

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

            String userId = authenticator.validateUser(getCredentials());

            identity = authenticator.createIdentity(userId);
            sharedState.put("javax.security.auth.login.name", userId);
            // TODO use PasswordCredential wrapper
            subject.getPrivateCredentials().add(getPassword());
            subject.getPublicCredentials().add(getUsername());
         }
View Full Code Here

TOP

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

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.