Package org.springframework.security.authentication

Examples of org.springframework.security.authentication.AuthenticationServiceException


    try {
      loadedUser = this.getUserDetailsService().loadUserByUsername(username);
    } catch (UsernameNotFoundException notFound) {
      throw notFound;
    } catch (Exception repositoryProblem) {
      throw new AuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem);
    }

    if (loadedUser == null) {
      throw new AuthenticationServiceException(
          "UserDetailsService returned null, which is an interface contract violation");
    }
    return loadedUser;
  }
View Full Code Here


            SAMLAuthenticationToken token = new SAMLAuthenticationToken(context);
            return getAuthenticationManager().authenticate(token);

        } catch (SAMLException e) {
            logger.debug("Incoming SAML message is invalid", e);
            throw new AuthenticationServiceException("Incoming SAML message is invalid", e);
        } catch (MetadataProviderException e) {
            logger.debug("Error determining metadata contracts", e);
            throw new AuthenticationServiceException("Error determining metadata contracts", e);
        } catch (MessageDecodingException e) {
            logger.debug("Error decoding incoming SAML message", e);
            throw new AuthenticationServiceException("Error decoding incoming SAML message", e);
        } catch (org.opensaml.xml.security.SecurityException e) {
            logger.debug("Incoming SAML message is invalid", e);
            throw new AuthenticationServiceException("Incoming SAML message is invalid", e);
        }

    }
View Full Code Here

                throw new SAMLException("Unsupported profile encountered in the context " + context.getCommunicationProfileId());
            }
        } catch (SAMLRuntimeException e) {
            log.debug("Error validating SAML message", e);
            samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e);
            throw new AuthenticationServiceException("Error validating SAML message", e);
        } catch (SAMLException e) {
            log.debug("Error validating SAML message", e);
            samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e);
            throw new AuthenticationServiceException("Error validating SAML message", e);
        } catch (ValidationException e) {
            log.debug("Error validating signature", e);
            samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e);
            throw new AuthenticationServiceException("Error validating SAML message signature", e);
        } catch (org.opensaml.xml.security.SecurityException e) {
            log.debug("Error validating signature", e);
            samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e);
            throw new AuthenticationServiceException("Error validating SAML message signature", e);
        } catch (DecryptionException e) {
            log.debug("Error decrypting SAML message", e);
            samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e);
            throw new AuthenticationServiceException("Error decrypting SAML message", e);
        }

        Object userDetails = getUserDetails(credential);
        Object principal = getPrincipal(credential, userDetails);
        Collection<? extends GrantedAuthority> entitlements = getEntitlements(credential, userDetails);
View Full Code Here

            final String[] authorityStringsAsArray = privilegesFromRest.toArray(new String[privilegesFromRest.size()]);
            final List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList(authorityStringsAsArray);

            loadedUser = new SpringSecurityPrincipal(name, password, true, authorities, "principalFromRest.getUuid()");
        } catch (final Exception repositoryProblem) {
            throw new AuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem);
        }

        return loadedUser;
    }
View Full Code Here

            loadedUser = (EnMeUserAccount) this.getUserDetailsService().loadUserByUsername(
                    username);
        } catch (UsernameNotFoundException notFound) {
            throw notFound;
        } catch (Exception repositoryProblem) {
            throw new AuthenticationServiceException(
                    repositoryProblem.getMessage(), repositoryProblem);
        }

        if (loadedUser == null) {
            throw new AuthenticationServiceException(
                    "UserDetailsService returned null, which is an interface contract violation");
        }
        log.debug("loaded user "+loadedUser.getUsername());
        log.info("loader user "+loadedUser.toString());
        return loadedUser;
View Full Code Here

    String authProviderId = getRequestedProviderId(request);
    if (!authProviders.isEmpty() && authProviderId != null && authProviders.contains(authProviderId)) {
      SocialAuthenticationService<?> authService = authServiceLocator.getAuthenticationService(authProviderId);
      auth = attemptAuthService(authService, request, response);
      if (auth == null) {
        throw new AuthenticationServiceException("authentication failed");
      }
    }
    return auth;
  }
View Full Code Here

    @Override
    public Authentication attemptAuthentication(HttpServletRequest request,
            HttpServletResponse response) throws AuthenticationException {
        if (!request.getMethod().equals("POST")) {
            throw new AuthenticationServiceException(
                    "Authentication method not supported: "
                            + request.getMethod());
        }

        String username = obtainUsername(request);
        String password = obtainPassword(request);

        // Validates username and password
        username = username.trim();

        String localValue = obtainLanguage(request);
        String[] locals = localValue.split("_");
        Locale locale = new Locale(locals[0], locals[1]);
        request.getSession().setAttribute("WW_TRANS_I18N_LOCALE", locale);
        request.getSession().setAttribute("locale", localValue);
        Locale.setDefault(locale);

        User user = UserUtil.getUser(username);
        Md5PasswordEncoder encoder = new Md5PasswordEncoder();
        password = encoder.encodePassword(password, AuthenticationFilter.SALT);
        if (user == null || !user.getPassword().equals(password)) {
            ResourceBundle rb = CommonUtil.getResourceBundle();
            String errorMessage = rb.getString("error.login.denied");
            throw new AuthenticationServiceException(errorMessage);
        }

        UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(
                username, password);
        setDetails(request, authRequest);
View Full Code Here

                if (details.isEnabled()==false) {
                    log (new DisabledException("User "+user+" is disabled"));
                    return null;
                }
            } catch (IOException ex ) {
                log(new AuthenticationServiceException(ex.getLocalizedMessage(),ex));
                return null;
            } catch (UsernameNotFoundException ex) {
                log(ex);
            } catch (AuthenticationException ex) {
                log(ex);
                return null;
            }
        }
                       
        Connection con = null;
        try {
            con =DriverManager.getConnection(connectUrl, user, password);
        } catch (SQLInvalidAuthorizationSpecException ex) {
            log(new BadCredentialsException("Bad credentials for "+user, ex));
            return null;
        } catch (SQLException ex) {
            log(new AuthenticationServiceException("JDBC connect error", ex));
            return null;
        } finally {
            if (con!=null) {
                try {
                    con.close();
                } catch (SQLException ex2) {
                    // do nothing, give up
                }
            }
               
        }
        UsernamePasswordAuthenticationToken result = null;
        Set<GrantedAuthority> roles = new HashSet<GrantedAuthority>();
        if (details!=null) {           
            roles.addAll(details.getAuthorities());                       
        } else {       
            RoleCalculator calc = new RoleCalculator(getSecurityManager().getActiveRoleService());
            try {
                roles.addAll(calc.calculateRoles(new GeoServerUser(user)));
            } catch (IOException e) {
                throw new AuthenticationServiceException(e.getLocalizedMessage(),e);
            }                       
        }  
        roles.add(GeoServerRole.AUTHENTICATED_ROLE);
        result = new UsernamePasswordAuthenticationToken(authentication.getPrincipal(),null,roles);
        result.setDetails(authentication.getDetails());
View Full Code Here

  private boolean postOnly = true;
 
  @Override
  public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
        if (postOnly && !request.getMethod().equals("POST")) {
            throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());
        }

        String username = obtainUsername(request);
        String password = obtainPassword(request);
    String company  = obtainCompany(request);
View Full Code Here

        loadedUser = this.getUserDetailsService().loadUserByUsername(username);
      }
        } catch (UsernameNotFoundException notFound) {
            throw notFound;
        } catch (Exception repositoryProblem) {
            throw new AuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem);
        }

        if (loadedUser == null) {
            throw new AuthenticationServiceException(
                    "UserDetailsService returned null, which is an interface contract violation");
        }
        return loadedUser;
    }
View Full Code Here

TOP

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

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.