throw new AuthenticationFailedException();
}
final UsernamePasswordAuthentication upa = (UsernamePasswordAuthentication) ftpAuthRequest;
final String principal = upa.getUsername();
final String credentials = upa.getPassword();
org.springframework.security.Authentication gsAuth = new UsernamePasswordAuthenticationToken(
principal, credentials);
try {
gsAuth = authManager.authenticate(gsAuth);
} catch (org.springframework.security.AuthenticationException authEx) {
throw new AuthenticationFailedException(authEx);
}
try {
// gather the user
BaseUser user = getUserByName(principal);
user.setPassword(credentials);
// is the user enabled?
if (!user.getEnabled()) {
throw new AuthenticationFailedException();
}
// scary message for admins if the username/password has not
// been changed
if (DEFAULT_USER.equals(user.getName()) && DEFAULT_PASSWORD.equals(credentials)) {
LOGGER.log(Level.SEVERE, "The default admin/password combination has not been "
+ "modified, this makes the embedded FTP server an "
+ "open file host for everybody to use!!!");
}
final File dataRoot = dataDir.findOrCreateDataRoot();
// enable only admins and non anonymous users
boolean isGSAdmin = false;
for (GrantedAuthority authority : gsAuth.getAuthorities()) {
final String userRole = authority.getAuthority();
if (ADMIN_ROLE.equals(userRole)) {
isGSAdmin = true;
break;
}