@Test public void testAuthWithSubject() { AuthenticatedUser expected = mock(AuthenticatedUser.class); when(mockSaslNegotiator.getAuthenticatedUser()).thenReturn(expected); when(mockSaslNegotiator.getUser()).thenReturn("audited_user"); when(mockSaslNegotiator.getSubject()).thenReturn(Optional.of("subject_user")); SaslNegotiator negotiator = auditAuthenticator.newSaslNegotiator(); AuthenticatedUser actual = negotiator.getAuthenticatedUser(); assertThat(actual).isSameAs(expected); verify(mockAuditAdapter, times(1)).auditAuth(eq("audited_user"), eq("subject_user"), eq(Status.ATTEMPT), anyLong()); verify(mockAuditAdapter, times(1)).auditAuth(eq("audited_user"), eq("subject_user"), eq(Status.SUCCEEDED), anyLong()); }
@Override public SaslNegotiator newSaslNegotiator() { return new AuditSaslNegotiator(wrappedAuthenticator.newDecoratedSaslNegotiator()); }
AuditAuthenticator implements IAuthenticator { @Override public SaslNegotiator newSaslNegotiator() { return new AuditSaslNegotiator(wrappedAuthenticator.newDecoratedSaslNegotiator()); } }
AuditAuthenticator implements IAuthenticator { @Override public SaslNegotiator newSaslNegotiator() { return new AuditSaslNegotiator(wrappedAuthenticator.newDecoratedSaslNegotiator()); } AuditAuthenticator();   AuditAuthenticator(IDecoratedAuthenticator wrappedAuthenticator, AuditAdapter auditAdapter); }
AuditAuthenticator implements IAuthenticator { @Override public SaslNegotiator newSaslNegotiator() { return new AuditSaslNegotiator(wrappedAuthenticator.newDecoratedSaslNegotiator()); } AuditAuthenticator();   AuditAuthenticator(IDecoratedAuthenticator wrappedAuthenticator, AuditAdapter auditAdapter); @Override boolean requireAuthentication(); @Override Set<? extends IResource> protectedResources(); @Override void validateConfiguration(); @Override void setup(); @Override SaslNegotiator newSaslNegotiator(); @Override AuthenticatedUser legacyAuthenticate(Map<String, String> credentials); }
AuditAuthenticator implements IAuthenticator { @Override public SaslNegotiator newSaslNegotiator() { return new AuditSaslNegotiator(wrappedAuthenticator.newDecoratedSaslNegotiator()); } AuditAuthenticator();   AuditAuthenticator(IDecoratedAuthenticator wrappedAuthenticator, AuditAdapter auditAdapter); @Override boolean requireAuthentication(); @Override Set<? extends IResource> protectedResources(); @Override void validateConfiguration(); @Override void setup(); @Override SaslNegotiator newSaslNegotiator(); @Override AuthenticatedUser legacyAuthenticate(Map<String, String> credentials);  }