@Override public User authenticate(Authentication authentication) throws AuthenticationFailedException { if (authentication instanceof UsernamePasswordAuthentication) { UsernamePasswordAuthentication usernameAndPassword = (UsernamePasswordAuthentication) authentication; String username = usernameAndPassword.getUsername(); User user = users.get(username); if (null == user) { throw new AuthenticationFailedException("unknown user '" + username + "'"); } String password = usernameAndPassword.getPassword(); if (getPasswordEncryptor().matches(password, user.getPassword())) { return user; } else { throw new AuthenticationFailedException("password wrong"); } } throw new AuthenticationFailedException("try harder"); } }
@Override public User authenticate(Authentication authentication) throws AuthenticationFailedException { if (authentication instanceof AnonymousAuthentication) { for (FTPUser user : mUsers) { if (user.isAnonymous()) return user.create(); } throw new AuthenticationFailedException(); } if (mUsers.isEmpty()) throw new AuthenticationFailedException(); if (authentication instanceof UsernamePasswordAuthentication) { UsernamePasswordAuthentication auth = (UsernamePasswordAuthentication) authentication; final String username = auth.getUsername(); final String password = auth.getPassword(); for (FTPUser user : mUsers) { if (username.equals(user.getName()) && TextUtils.equals(password, user.getPassword())) return user.create(); } } throw new AuthenticationFailedException(); }
throw new AuthenticationFailedException("Authentication failed"); throw new AuthenticationFailedException("Authentication failed"); return getUserByName(user); } else { throw new AuthenticationFailedException("Authentication failed"); return getUserByName("anonymous"); } else { throw new AuthenticationFailedException("Authentication failed");
throw new AuthenticationFailedException("Authentication failed"); return getUserByName(user); } else { throw new AuthenticationFailedException( "Authentication failed"); throw new AuthenticationFailedException( "Authentication failed", e); throw new AuthenticationFailedException( "Authentication failed"); throw new AuthenticationFailedException( "Authentication failed", ex); } finally { return getUserByName("anonymous"); } else { throw new AuthenticationFailedException( "Authentication failed"); throw e; } catch (FtpException e) { throw new AuthenticationFailedException( "Authentication failed", e);
throw new AuthenticationFailedException("Authentication failed"); throw new AuthenticationFailedException("Authentication failed"); return this.getUserByName(user); } else { throw new AuthenticationFailedException("Authentication failed"); return getUserByName("anonymous"); } else { throw new AuthenticationFailedException("Authentication failed");
throw new AuthenticationFailedException("Authentication failed"); throw new AuthenticationFailedException("Authentication failed"); return getUserByName(user); } else { throw new AuthenticationFailedException("Authentication failed"); return getUserByName("anonymous"); } else { throw new AuthenticationFailedException("Authentication failed");
throws AuthenticationFailedException { if (!(ftpAuthRequest instanceof UsernamePasswordAuthentication)) { throw new AuthenticationFailedException(); gsAuth = authManager.authenticate(gsAuth); } catch (org.springframework.security.core.AuthenticationException authEx) { throw new AuthenticationFailedException(authEx); throw new AuthenticationFailedException(); } catch (Exception e) { LOGGER.log(Level.INFO, "FTP authentication failure", e); throw new AuthenticationFailedException(e);
@Override public User authenticate(Authentication authentication) throws AuthenticationFailedException { if (authentication instanceof UsernamePasswordAuthentication) { UsernamePasswordAuthentication auth = (UsernamePasswordAuthentication) authentication; if (doesExist(auth.getUsername())) { String pw = auth.getPassword(); if (!StringUtils.isBlank(pw)) { String encryptedPW = EncryptionUtil.encrypt(pw); String storedPW = prefsBean.getPassword(); if (storedPW.equals(encryptedPW)) { return buildUser(); } } } } else if(authentication instanceof AnonymousAuthentication) { if(prefsBean.isAnonymousLogin()) { return anonymousUser(); } } throw new AuthenticationFailedException(); }