Package org.springframework.security.authentication

Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException


  public static CartUserDetails getUserDetails(){
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (!(auth instanceof AnonymousAuthenticationToken)) {
      return (CartUserDetails)auth.getPrincipal();
    }
    throw new AuthenticationCredentialsNotFoundException("User details not found");
  }
View Full Code Here


      }

      return savedToken;
    }

    throw new AuthenticationCredentialsNotFoundException("No authentication credentials found");
  }
View Full Code Here

            SecurityContextHolder.getContext().setAuthentication(null);
            DummyFilterChain dummyFilter = new DummyFilterChain();
            filter.doFilter(request, response, dummyFilter);
            Authentication auth = SecurityContextHolder.getContext().getAuthentication();
            if (auth == null) {
                AuthenticationException ex = new AuthenticationCredentialsNotFoundException("Anonymous access denied");
                authenticationEntryPoint.commence(request, response, ex);
                return false;
            }
            return dummyFilter.isCalled();
        } catch (ServletException e) {
View Full Code Here

            MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE })
    public @ResponseBody
    UserList exec() throws Exception {
        final SecurityContext context = SecurityContextHolder.getContext();
        if (context == null || context.getAuthentication() == null) {
            throw new AuthenticationCredentialsNotFoundException("User needs to log in");
        }
        User me = userRepository.findOneByUsername(context.getAuthentication().getName());

        if (me == null) {
            throw new AccessDeniedException(SecurityContextHolder.class.getSimpleName() + " has a user that is not in the database: " +
View Full Code Here

            throws AuthenticationCredentialsNotFoundException {
        // need to check to see if the current user has a SwitchUserGrantedAuthority
        Authentication current = SecurityContextHolder.getContext().getAuthentication();

        if (null == current) {
            throw new AuthenticationCredentialsNotFoundException(messages.getMessage(
                    "SwitchUserFilter.noCurrentUser", "No current user associated with this request"));
        }

        // check to see if the current user did actual switch to another user
        // if so, get the original source user so we can switch back
        Authentication original = getSourceAuthentication(current);

        if (original == null) {
            logger.error("Could not find original user Authentication object!");
            throw new AuthenticationCredentialsNotFoundException(messages.getMessage(
                    "SwitchUserFilter.noOriginalAuthentication",
                    "Could not find original Authentication object"));
        }

        // get the source user details
View Full Code Here

     * @param reason        to be provided in the exception detail
     * @param secureObject  that was being called
     * @param configAttribs that were defined for the secureObject
     */
    private void credentialsNotFound(String reason, Object secureObject, Collection<ConfigAttribute> configAttribs) {
        AuthenticationCredentialsNotFoundException exception = new AuthenticationCredentialsNotFoundException(reason);

        AuthenticationCredentialsNotFoundEvent event = new AuthenticationCredentialsNotFoundEvent(secureObject,
                configAttribs, exception);
        publishEvent(event);

View Full Code Here

    @Override
    public void assertAccess(final String resourceDescription, final Object protectedResource) {
        final SecurityContext context = SecurityContextHolder.getContext();

        if (context == null || context.getAuthentication() == null) {
            throw new AuthenticationCredentialsNotFoundException(resourceDescription + " requires an authenticated user");
        } else if (this.requiredRoles.isEmpty()) {
            if (!context.getAuthentication().getAuthorities().isEmpty()) {
                return;
            }
        } else {
View Full Code Here

        a.printStackTrace();
      }
      filterChain.doFilter(request, response);
    }
    else {
      throw new AuthenticationCredentialsNotFoundException("No valid user found to authenticate");
    }
  }
View Full Code Here

        when(cloudsealManager.getSsoUrl()).thenReturn("http://demo.cloudseal.com/idp/saml");
        when(request.getSession()).thenReturn(session);

        ArgumentCaptor<String> redirectUrlCaptor = ArgumentCaptor.forClass(String.class);

        classUnderTest.commence(request, response, new AuthenticationCredentialsNotFoundException("must authenticate"));

        verify(cloudsealManager).generateSamlAuthRequest("http://www.mycorp.com/saml/sp",
                                                    "http://www.mycorp.com/cloudseal_acs",
                                                    "http://www.mycorp.com/cloudseal_acs", id);
        verify(session).setAttribute(CloudsealEntryPoint.AUTH_REQUEST_ID, id);
View Full Code Here

    @RequestMapping("/verifyEmail")
    public String verifyEmail(@RequestParam String email, @RequestParam String mac, HttpSession session) {
        if (!crypto.isMacValid(email, mac)) {
            LOGGER.warn("Mac code is not valid for email(\"" + email + "\").");
            session.setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, new AuthenticationCredentialsNotFoundException("Email verification code is corrupted. Your email hasn't been verified."));
            return "redirect:../pages/dashboard.html";
        }
        final SecurityHelper.UserDetails userDetails = securityHelper.getUserDetailsByEmail(email);
        if (userDetails == null) {
            LOGGER.warn("Account with email(\"" + email + "\") doesn't exist.");
            session.setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, new AuthenticationCredentialsNotFoundException("Account with this email doesn't exist."));
            return "redirect:../pages/dashboard.html";
        }
        if (userDetails.emailVerified) {
            session.setAttribute(SUCCESS_MESSAGE, "Your email already has been verified. Please log in.");
        } else {
View Full Code Here

TOP

Related Classes of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

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.