コード例 #1
0
  @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();
    }
  }
コード例 #2
0
ファイル: DatabaseComparer.java プロジェクト: peris/ole
 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);
   }
 }
コード例 #3
0
 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();
 }
コード例 #4
0
 @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);
 }
コード例 #5
0
 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;
   }
 }