Package org.apache.shiro.authc

Examples of org.apache.shiro.authc.AuthenticationInfo


    PublicKey testUsersKey = new MockPublicKey("key1");
    publicKeyRepository.addPublicKey("test-user", testUsersKey);

    PublicKeyAuthenticatingRealm realm = new PublicKeyAuthenticatingRealm(publicKeyRepository);

    AuthenticationInfo authInfo =
        realm.getAuthenticationInfo(new PublicKeyAuthenticationToken("test-user", testUsersKey));
    Assert.assertEquals("test-user", authInfo.getPrincipals().getPrimaryPrincipal());
  }
View Full Code Here


    publicKeyRepository.addPublicKey("foo-bar", foosKey);

    PublicKeyAuthenticatingRealm realm = new PublicKeyAuthenticatingRealm(publicKeyRepository);

    for (PublicKey publicKey : keySet) {
      AuthenticationInfo authInfo =
          realm.getAuthenticationInfo(new PublicKeyAuthenticationToken("test-user", publicKey));
      Assert.assertEquals("test-user", authInfo.getPrincipals().getPrimaryPrincipal());
    }

    try {
      realm.getAuthenticationInfo(new PublicKeyAuthenticationToken("test-user", foosKey));
      Assert.fail("expected AuthenticationException");
View Full Code Here

  public void testValidAuthentication()
      throws Exception
  {
    SecuritySystem plexusSecurity = this.lookup(SecuritySystem.class);
    AuthenticationToken token = new UsernamePasswordToken("admin-simple", "admin123");
    AuthenticationInfo authInfo = plexusSecurity.authenticate(token);

    // check
    Assert.assertNotNull(authInfo);
  }
View Full Code Here

    @Test
    public void testConfigure() {
        final MockRealm mockRealm = createMock(MockRealm.class);
        AuthenticationToken authToken = createMock(AuthenticationToken.class);
        AuthenticationInfo info = new SimpleAuthenticationInfo("mockUser", "password", "mockRealm");

        expect(mockRealm.supports(authToken)).andReturn(true);
        expect(mockRealm.getAuthenticationInfo(authToken)).andReturn(info);

        replay(mockRealm);
View Full Code Here

     * @return the {@link AuthenticationInfo} acquired after a successful authentication attempt
     * @throws AuthenticationException if the authentication attempt fails or if a
     *                                 {@link NamingException} occurs.
     */
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
        AuthenticationInfo info;
        try {
            info = queryForAuthenticationInfo(token, getContextFactory());
        } catch (AuthenticationNotSupportedException e) {
            String msg = "Unsupported configured authentication mechanism";
            throw new UnsupportedAuthenticationMechanismException(msg, e);
View Full Code Here

        expect(cookie.isSecure()).andReturn(false);
        expect(cookie.isHttpOnly()).andReturn(true);

        UsernamePasswordToken token = new UsernamePasswordToken("user", "secret");
        token.setRememberMe(true);
        AuthenticationInfo account = new SimpleAuthenticationInfo("user", "secret", "test");

        replay(mockSubject);
        replay(mockRequest);
        replay(cookie);
View Full Code Here

        for (final Realm realm : realms) {
            // only obtain roles from those realm(s) that authenticated this subject
            if(!realmNames.contains(realm.getName())) {
                continue;
            }
            final AuthenticationInfo authenticationInfo = realm.getAuthenticationInfo(token);
            if(authenticationInfo instanceof AuthorizationInfo) {
                final AuthorizationInfo authorizationInfo = (AuthorizationInfo) authenticationInfo;
                final Collection<String> realmRoles = authorizationInfo.getRoles();
                for (final String role : realmRoles) {
                    roles.add(realm.getName() + ":" + role);
View Full Code Here

        strategy = new AllSuccessfulStrategy();
    }

    @Test
    public void beforeAllAttempts() {
        AuthenticationInfo info = strategy.beforeAllAttempts(null, null);
        assertNotNull(info);
    }
View Full Code Here

    @Test
    public void testBasic() {
        CredentialsMatcher matcher = (CredentialsMatcher) ClassUtils.newInstance(getMatcherClass());
        byte[] hashed = hash("password").getBytes();
        AuthenticationInfo account = new SimpleAuthenticationInfo("username", hashed, "realmName");
        AuthenticationToken token = new UsernamePasswordToken("username", "password");
        assertTrue(matcher.doCredentialsMatch(token, account));
    }
View Full Code Here

        //simulate an account with SHA-1 hashed password (no salt)
        final String username = "username";
        final String password = "password";
        final Object hashedPassword = new Sha1Hash(password).getBytes();
        AuthenticationInfo account = new AuthenticationInfo() {
            public PrincipalCollection getPrincipals() {
                return new SimplePrincipalCollection(username, "realmName");
            }

            public Object getCredentials() {
View Full Code Here

TOP

Related Classes of org.apache.shiro.authc.AuthenticationInfo

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.