Package org.apache.shiro.authc

Examples of org.apache.shiro.authc.AuthenticationToken


        assertTrue(this.realm.hasRole(principals, ROLE_NAME));
    }

    @Test(expected = AuthenticationException.class)
    public void testInvalidUsernamePassword() {
        AuthenticationToken token = new UsernamePasswordToken("InvalidUser", "somePassword");
        this.realm.getAuthenticationInfo(token);
    }
View Full Code Here


        this.realm.getAuthenticationInfo(token);
    }

    @Test(expected = AuthenticationException.class)
    public void testGuestUsernamePassword() {
        AuthenticationToken token = new UsernamePasswordToken("Guest", "somePassword");
        this.realm.getAuthenticationInfo(token);
    }
View Full Code Here

        this.negAuthRealm = new NegotiateAuthenticationRealm();
    }

    public void testSupports() {
        assertFalse("Non-NegotiateToken should not be supported.",
                this.negAuthRealm.supports(new AuthenticationToken() {
                    private static final long serialVersionUID = 334672725950031145L;

                    @Override
                    public Object getPrincipal() {
                        return null;
View Full Code Here

        final AtomicReference<Object> authenticated = new AtomicReference<Object>();

        Mockito.doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                AuthenticationToken t = (AuthenticationToken) invocation.getArguments()[0];
                try {
                    authConnector.authenticate(t.getPrincipal().toString(), (Credentials) t.getCredentials());
                } catch (AuthenticationException e) {
                    throw new org.apache.shiro.authc.AuthenticationException(e);
                }
                authenticated.set(t.getPrincipal());
                return null;
            }
        }).when(mockSubject).login(Mockito.any(AuthenticationToken.class));

        when(mockSubject.isAuthenticated()).thenAnswer(new Answer<Boolean>() {
View Full Code Here

            if (!subject.isAuthenticated()) {

                SubjectConnectionReference connection = new SubjectConnectionReference(context, info, getEnvironment(), subject);

                if (this.authenticationPolicy.isAuthenticationRequired(connection)) {
                    AuthenticationToken token = this.authenticationTokenFactory.getAuthenticationToken(connection);
                    if (token == null) {
                        String msg = "Unable to obtain authentication credentials for newly established connection.  " +
                                "Authentication is required.";
                        throw new AuthenticationException(msg);
                    }
View Full Code Here

TOP

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

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.