@Test public void authenticateFail() { byte[] user2 = "user2".getBytes(); byte[] credentials = new byte[64]; System.arraycopy(user2, 0, credentials, 0, user2.length); UUID sessionId = SessionId.generateUUID(); assertTrue(!authenticator.authenticate(sessionId, credentials)); }
@Override public boolean authenticate(UUID sessionId, byte[] credentials) { this.entity = Credentials.getEntity(credentials); this.sessionId = sessionId; Subject subject = new Subject(); try { URL url = getClass().getClassLoader().getResource("jaas-directory.config"); System.setProperty("java.security.auth.login.config", url.toString()); LoginContext context = new LoginContext(CONFIG_NAME, subject, this.callbackHandler); context.login(); System.out.format("Authenticated session ID=%s credentials=%s\n", sessionId.toString(), entity.getName()); return true; } catch (LoginException e) { System.out.format("Authentication failed for session ID=%s credentials=%s; %s\n", sessionId.toString(), entity.getName(), e.getMessage()); return false; } }
SimpleAuthenticator extends AbstractAuthenticator { @Override public boolean authenticate(UUID sessionId, byte[] credentials) { this.entity = Credentials.getEntity(credentials); this.sessionId = sessionId; Subject subject = new Subject(); try { URL url = getClass().getClassLoader().getResource("jaas-directory.config"); System.setProperty("java.security.auth.login.config", url.toString()); LoginContext context = new LoginContext(CONFIG_NAME, subject, this.callbackHandler); context.login(); System.out.format("Authenticated session ID=%s credentials=%s\n", sessionId.toString(), entity.getName()); return true; } catch (LoginException e) { System.out.format("Authentication failed for session ID=%s credentials=%s; %s\n", sessionId.toString(), entity.getName(), e.getMessage()); return false; } } }
SimpleAuthenticator extends AbstractAuthenticator { @Override public boolean authenticate(UUID sessionId, byte[] credentials) { this.entity = Credentials.getEntity(credentials); this.sessionId = sessionId; Subject subject = new Subject(); try { URL url = getClass().getClassLoader().getResource("jaas-directory.config"); System.setProperty("java.security.auth.login.config", url.toString()); LoginContext context = new LoginContext(CONFIG_NAME, subject, this.callbackHandler); context.login(); System.out.format("Authenticated session ID=%s credentials=%s\n", sessionId.toString(), entity.getName()); return true; } catch (LoginException e) { System.out.format("Authentication failed for session ID=%s credentials=%s; %s\n", sessionId.toString(), entity.getName(), e.getMessage()); return false; } }  }
SimpleAuthenticator extends AbstractAuthenticator { @Override public boolean authenticate(UUID sessionId, byte[] credentials) { this.entity = Credentials.getEntity(credentials); this.sessionId = sessionId; Subject subject = new Subject(); try { URL url = getClass().getClassLoader().getResource("jaas-directory.config"); System.setProperty("java.security.auth.login.config", url.toString()); LoginContext context = new LoginContext(CONFIG_NAME, subject, this.callbackHandler); context.login(); System.out.format("Authenticated session ID=%s credentials=%s\n", sessionId.toString(), entity.getName()); return true; } catch (LoginException e) { System.out.format("Authentication failed for session ID=%s credentials=%s; %s\n", sessionId.toString(), entity.getName(), e.getMessage()); return false; } }  @Override boolean authenticate(UUID sessionId, byte[] credentials); SimpleAuthenticator withDirectory(Directory directory); }
SimpleAuthenticator extends AbstractAuthenticator { @Override public boolean authenticate(UUID sessionId, byte[] credentials) { this.entity = Credentials.getEntity(credentials); this.sessionId = sessionId; Subject subject = new Subject(); try { URL url = getClass().getClassLoader().getResource("jaas-directory.config"); System.setProperty("java.security.auth.login.config", url.toString()); LoginContext context = new LoginContext(CONFIG_NAME, subject, this.callbackHandler); context.login(); System.out.format("Authenticated session ID=%s credentials=%s\n", sessionId.toString(), entity.getName()); return true; } catch (LoginException e) { System.out.format("Authentication failed for session ID=%s credentials=%s; %s\n", sessionId.toString(), entity.getName(), e.getMessage()); return false; } }  @Override boolean authenticate(UUID sessionId, byte[] credentials); SimpleAuthenticator withDirectory(Directory directory);  }