private <T> boolean genericAuthenticate(Class<T> type, String username, T credential) { for (AuthenticationPlugin authenticationPlugin : authenticationPlugins) { if (authenticationPlugin.getCredentialType().equals(type)) { try { log.log(Level.FINE, "Using authentication plugin " + authenticationPlugin + " to authenticate user " + username); @SuppressWarnings("unchecked") AuthenticationPlugin<T> authPlugin = (AuthenticationPlugin<T>) authenticationPlugin; if (authPlugin.authenticate(username, credential)) { return true; } } catch (Exception e) { log.log(Level.SEVERE, "Exception authenticating user " + username + " in authentication plugin: " + authenticationPlugin, e); } } } return false; } }
public boolean authenticate(String username, PublicKey key, ServerSession session) { try { log.log(Level.FINE, "Using authentication plugin " + authentication + " to authenticate user " + username); return keyAuthentication.authenticate(username, key); } catch (Exception e) { log.log(Level.SEVERE, "Exception authenticating user " + username + " in authentication plugin: " + authentication, e); return false; } } });
private <T> boolean genericAuthenticate(Class<T> type, String username, T credential) { for (AuthenticationPlugin authenticationPlugin : authenticationPlugins) { if (authenticationPlugin.getCredentialType().equals(type)) { try { log.log(Level.FINE, "Using authentication plugin " + authenticationPlugin + " to authenticate user " + username); @SuppressWarnings("unchecked") AuthenticationPlugin<T> authPlugin = (AuthenticationPlugin<T>) authenticationPlugin; if (authPlugin.authenticate(username, credential)) { return true; } } catch (Exception e) { log.log(Level.SEVERE, "Exception authenticating user " + username + " in authentication plugin: " + authenticationPlugin, e); } } } return false; } }
private <T> AuthInfo genericAuthenticate(Class<T> type, String username, T credential) { for (AuthenticationPlugin authenticationPlugin : authenticationPlugins) { if (authenticationPlugin.getCredentialType().equals(type)) { try { log.log(Level.FINE, "Using authentication plugin " + authenticationPlugin + " to authenticate user " + username); @SuppressWarnings("unchecked") AuthenticationPlugin<T> authPlugin = (AuthenticationPlugin<T>) authenticationPlugin; return authPlugin.authenticate(username, credential); } catch (Exception e) { log.log(Level.SEVERE, "Exception authenticating user " + username + " in authentication plugin: " + authenticationPlugin, e); } } } return AuthInfo.UNSUCCESSFUL; } }
public boolean authenticate(String _username, String _password, ServerSession session) { boolean auth; try { log.log(Level.FINE, "Using authentication plugin " + authentication + " to authenticate user " + _username); auth = passwordAuthentication.authenticate(_username, _password); } catch (Exception e) { log.log(Level.SEVERE, "Exception authenticating user " + _username + " in authentication plugin: " + authentication, e); return false; } // We store username and password in session for later reuse session.setAttribute(USERNAME, _username); session.setAttribute(PASSWORD, _password); // return auth; } });