Package org.exoplatform.services.security

Examples of org.exoplatform.services.security.UsernameCredential


         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);
         subject.getPublicCredentials().add(new UsernameCredential(username));
         return true;
      }
      catch (final Throwable e)
      {
         throw new LoginException(e.getMessage());
View Full Code Here


            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));
         }
         return true;

      }
      catch (final Throwable e)
View Full Code Here

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

      cservice = (CommandService)container.getComponentInstanceOfType(CommandService.class);

      // 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 BasicAppContext(repService.getDefaultRepository());
View Full Code Here

      // we need to login (see BasicAppContext, 38) and set current item before ctx using
      // 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);
View Full Code Here

                    Identity identity = authenticator.createIdentity(username);

                    sharedState.put("exo.security.identity", identity);
                    sharedState.put("javax.security.auth.login.name", username);

                    subject.getPublicCredentials().add(new UsernameCredential(username));

                    // Add empty password to subject and remove password key, so that SharedStateLoginModule won't be processed
                    subject.getPrivateCredentials().add("");
                    sharedState.remove("javax.security.auth.login.password");
View Full Code Here

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

   public void testAuthenticator() throws Exception
   {
      assertNotNull(authenticator);
      assertTrue(authenticator instanceof OrganizationAuthenticatorImpl);
      Credential[] cred = new Credential[]{new UsernameCredential("admin"), new PasswordCredential("admin")};
      String userId = authenticator.validateUser(cred);
      assertEquals("admin", userId);
      Identity identity = authenticator.createIdentity(userId);
      assertTrue(identity.isMemberOf("/platform/administrators", "manager"));
      assertTrue(identity.getGroups().size() > 0);
View Full Code Here

      UserHandler uh = orgService.getUserHandler();
      User user = uh.createUserInstance("testGetLastExceptionOnValidateUser");
      user.setPassword("foo");
      assertNotNull(authenticator);
      assertTrue(authenticator instanceof OrganizationAuthenticatorImpl);
      Credential[] cred = new Credential[]{new UsernameCredential("testGetLastExceptionOnValidateUser"), new PasswordCredential("foo")};
      String userId = authenticator.validateUser(cred);
      assertEquals("testGetLastExceptionOnValidateUser", userId);
      assertNull(authenticator.getLastExceptionOnValidateUser());
      assertNull(authenticator.getLastExceptionOnValidateUser());
      uh.setEnabled("testGetLastExceptionOnValidateUser", false, false);
View Full Code Here

               Identity identity = authenticator.createIdentity(username);

               sharedState.put("exo.security.identity", identity);
               sharedState.put("javax.security.auth.login.name", username);

               subject.getPublicCredentials().add(new UsernameCredential(username));

               // Add empty password to subject and remove password key, so that SharedStateLoginModule won't be processed
               subject.getPrivateCredentials().add("");
               sharedState.remove("javax.security.auth.login.password");
View Full Code Here

TOP

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

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.