@Override protected void login(LoginController controller, Credentials credentials) throws IOException { try { client = new CloudFrontService( new AWSCredentials(credentials.getUsername(), credentials.getPassword())) { @Override protected HttpClient initHttpConnection() { return CloudFrontDistributionConfiguration.this.http(); } }; // Provoke authentication error for (String container : this.getContainers()) { for (Distribution.Method method : getMethods(container)) { // Cache first container this.cache(this.getOrigin(method, container), method); break; } break; } } catch (CloudFrontServiceException e) { log.warn(String.format("Invalid account: %s", e.getMessage())); this.message(Locale.localizedString("Login failed", "Credentials")); controller.fail(host.getProtocol(), credentials); this.login(); } }
public Connection getConnection(Credentials c) { try { Class.forName("com.mysql.jdbc.Driver"); return DriverManager.getConnection(c.getUrl(), c.getUsername(), c.getPassword()); } catch (Throwable e) { throw new IllegalArgumentException(e); } }
protected ApplicationUser findApplicationUserByCredentials(final Credentials credentials) { return getEntityManager() .createQuery( "SELECT au FROM ApplicationUser au WHERE au.username = :username AND au.password = :password", ApplicationUser.class) .setParameter(USERNAME, credentials.getUsername()) .setParameter(PASSWORD, credentials.getPassword()) .getSingleResult(); }
@Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); Request modifiedRequest = request .newBuilder() .addHeader( "Authorization", "Basic " + Base64.getEncoder() .encodeToString( (credentials.getUsername() + ":" + credentials.getPassword()) .getBytes())) .build(); return chain.proceed(modifiedRequest); }
public Connection connection() { Connection conn; try { Class.forName(credentials.getDriver()).newInstance(); conn = DriverManager.getConnection( credentials.getUrl(), credentials.getUsername(), credentials.getPassword()); return conn; } catch (InstantiationException ex) { Logger.getLogger(GetSQLConnection.class.getName()).log(Level.SEVERE, null, ex); return null; } catch (IllegalAccessException ex) { Logger.getLogger(GetSQLConnection.class.getName()).log(Level.SEVERE, null, ex); return null; } catch (SQLException ex) { Logger.getLogger(GetSQLConnection.class.getName()).log(Level.SEVERE, null, ex); return null; } catch (ClassNotFoundException ex) { Logger.getLogger(GetSQLConnection.class.getName()).log(Level.SEVERE, null, ex); return null; } }