Examples of AuthenticationCredentialsNotFoundException


Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

public class AuthenticationCredentialsNotFoundEventTests {

    @Test(expected=IllegalArgumentException.class)
    public void testRejectsNulls() {
        new AuthenticationCredentialsNotFoundEvent(null, SecurityConfig.createList("TEST"),
                new AuthenticationCredentialsNotFoundException("test"));
    }
View Full Code Here

Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

    }

    @Test(expected=IllegalArgumentException.class)
    public void testRejectsNulls2() {
        new AuthenticationCredentialsNotFoundEvent(new SimpleMethodInvocation(), null,
                new AuthenticationCredentialsNotFoundException("test"));
    }
View Full Code Here

Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

        // invalid user. someone has either spoofed a cookie or the user account
        // is no longer in
        // the database.
        logger.warning("No user exists for principal found in security context authentication: " + username);
        SecurityContextHolder.clearContext();
        throw new AuthenticationCredentialsNotFoundException("Invalid user credentials found - username " + username
            + " does not exist in this wiki installation");
      }
    }
    return user;
  }
View Full Code Here

Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

   * @throws AuthenticationCredentialsNotFoundException If authentication
   *  credentials are unavailable.
   */
  public static WikiUserDetails initWikiUserDetails(Authentication auth) throws AuthenticationCredentialsNotFoundException {
    if (auth == null) {
      throw new AuthenticationCredentialsNotFoundException("No authentication credential available");
    }
    if (auth instanceof AnonymousAuthenticationToken || !(auth.getPrincipal() instanceof UserDetails)) {
      // anonymous user
      return new WikiUserDetails(ANONYMOUS_USER_USERNAME, "", true, true, true, true, auth.getAuthorities());
    }
View Full Code Here

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

Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

      }

      return savedToken;
    }

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

Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

            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

Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

            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

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

Examples of org.springframework.security.authentication.AuthenticationCredentialsNotFoundException

     * @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
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.