Package org.apache.shiro.authc

Examples of org.apache.shiro.authc.AuthenticationException


                throw new IncorrectCredentialsException("Authentication Failed. Password for account " + token.getPrincipal() + " was incorrect!", ice.getCause());
            } catch (LockedAccountException lae) {
                throw new LockedAccountException("Authentication Failed. The account for username " + token.getPrincipal() + " is locked."
                        + "Please contact your administrator to unlock it.", lae.getCause());
            } catch (AuthenticationException ae) {
                throw new AuthenticationException("Authentication Failed.", ae.getCause());
            }
        }
    }
View Full Code Here


                throw new IncorrectCredentialsException("Authentication Failed. Password for account " + token.getPrincipal() + " was incorrect!", ice.getCause());
            } catch (LockedAccountException lae) {
                throw new LockedAccountException("Authentication Failed. The account for username " + token.getPrincipal() + " is locked."
                    + "Please contact your administrator to unlock it.", lae.getCause());
            } catch (AuthenticationException ae) {
                throw new AuthenticationException("Authentication Failed.", ae.getCause());
            }
        }
    }
View Full Code Here

    @Override
    protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) throws Exception {
        String token = getHeaderParameter(request);
        if (token == null) {
            logger.debug("Header Authorization token is null, throw exception.");
            throw new AuthenticationException(ErrorMessages.INVALID_CREDENTIAL);
        }
        return new GatewayAuthenticaionToken(token);
    }
View Full Code Here

    @Override
    protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) throws Exception {
        String token = getHeaderParameter(request);
        if (token == null) {
            logger.debug("Header Authorization token is null, throw exception ");
            throw new AuthenticationException(ErrorMessages.INVALID_CREDENTIAL);
        }
        return new UserAuthenticationToken(token);
    }
View Full Code Here

        logger.debug("Attempting to get authentication info for" + ((UserAuthenticationToken) authcToken).getToken());

        User theUser = securityService.getUserFromAuthenticationToken(token.getToken());

        if (theUser == null) {
            throw new AuthenticationException(ErrorMessages.INVALID_CREDENTIAL);
        }

        logger.debug("UserId is set to " + theUser.getUser().getId());

        // token is expired
View Full Code Here

        logger.debug("Attempting to get gateway api authentication info for" + ((GatewayAuthenticaionToken) authcToken).getToken());

        Connection connection = securityService.getByApiKey(token.getToken(), GatewayProvider.TYPE);

        if (connection == null) {
            throw new AuthenticationException(ErrorMessages.INVALID_CREDENTIAL);
        }

        logger.debug("ConnectionId is set to " + connection.getId());

        // all is well so far...
View Full Code Here

    @Ignore("Integration Tests depended on sensitive account keys, ignoring until better harness is in place.")
    public void testCreateEvent_ReadEventWithNoLoggedInUser() throws Exception {
        // Test creating an event with no logged in user
        EventService eventService = applicationManager.getEventService();
        SecurityService mockSecurityService = mock(SecurityService.class);
        when(mockSecurityService.getCurrentUser()).thenThrow(new AuthenticationException());
        ReflectionTestUtils.setField(eventService, "securityService", mockSecurityService);


        Event event = eventService.createEvent(EventId.READ, testUser, null);
        Assert.assertNull(event);
View Full Code Here

    @Ignore("Integration Tests depended on sensitive account keys, ignoring until better harness is in place.")
    public void testCreateEvent_CreateSobaMessageWithNoLoggedInUser() throws Exception {
        // Test creating an event with no logged in user
        EventService eventService = applicationManager.getEventService();
        SecurityService mockSecurityService = mock(SecurityService.class);
        when(mockSecurityService.getCurrentUser()).thenThrow(new AuthenticationException());
        ReflectionTestUtils.setField(eventService, "securityService", mockSecurityService);


        // Test creating a SobaObject event with no logged in user
        Connection connection = new Connection.Builder()
View Full Code Here

        SecurityService ssMock = Mockito.mock(SecurityService.class);
        EventDAO edMock = Mockito.mock(EventDAO.class);
        EventServiceImpl esImpl = new EventServiceImpl();

        // Return null for the current user
        Mockito.when(ssMock.getCurrentUser()).thenThrow(new AuthenticationException("A user must be logged in!"));

        // Use reflection to set the EventDAO in EventServiceImpl
        ReflectionTestUtils.setField(esImpl, "eventDAO", edMock);

        mockMessageService = mock(MessageService.class);
View Full Code Here

    public Connection getCurrentGatewayConnection() {
        final String apiKey = (String) SecurityUtils.getSubject().getPrincipal();
        if (apiKey != null) {
            return getByApiKey(apiKey, GatewayProvider.TYPE);
        } else {
            throw new AuthenticationException("A gateway connection must be logged in!");
        }
    }
View Full Code Here

TOP

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

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.