Examples of AuthenticationCredentialsNotFoundException


Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

    @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

Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

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

Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

        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

Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

    @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

Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

   * @return current user;
   */
  public User getCurrentUser() {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth == null) {
      throw new AuthenticationCredentialsNotFoundException("No authentication");
    }
    Object obj = auth.getPrincipal();
    if (!(obj instanceof SecuredUser)) {
      throw new AuthenticationCredentialsNotFoundException("Invalid authentication with " + obj);
    }
    SecuredUser securedUser = (SecuredUser) obj;
    return securedUser.getUser();
  }
View Full Code Here

Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

            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
TOP
Copyright © 2018 www.massapi.com. 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.