@Test public void getPrincipalInfo() { LogAuditLoginModule module = new LogAuditLoginModule(); Map<String, String> options = new HashMap<>(); options.put("logger", "test"); Subject subject = new Subject(); subject.getPrincipals().add(new ClientPrincipal("ssh", "/127.0.0.1")); subject.getPrincipals().add(new ClientPrincipal("ssh", "/127.0.0.2")); subject.getPrincipals().add((UserPrincipal) () -> "noexist"); module.initialize(subject, new NamePasswordCallbackHandler("myuser", "mypassword"), null, options); Assert.assertEquals("ssh(/127.0.0.1), ssh(/127.0.0.2)", module.getPrincipalInfo()); }
protected String getPrincipalInfo() { String principalInfo; List<String> principalInfos = subject.getPrincipals(ClientPrincipal.class).stream().map(ClientPrincipal::getName).collect(toList()); if (principalInfos.size() > 0) { principalInfo = String.join(", ", principalInfos); } else { principalInfo = "no client principals found"; } return principalInfo; }
AbstractAuditLoginModule implements LoginModule { protected String getPrincipalInfo() { String principalInfo; List<String> principalInfos = subject.getPrincipals(ClientPrincipal.class).stream().map(ClientPrincipal::getName).collect(toList()); if (principalInfos.size() > 0) { principalInfo = String.join(", ", principalInfos); } else { principalInfo = "no client principals found"; } return principalInfo; } }
AbstractAuditLoginModule implements LoginModule { protected String getPrincipalInfo() { String principalInfo; List<String> principalInfos = subject.getPrincipals(ClientPrincipal.class).stream().map(ClientPrincipal::getName).collect(toList()); if (principalInfos.size() > 0) { principalInfo = String.join(", ", principalInfos); } else { principalInfo = "no client principals found"; } return principalInfo; }  }
AbstractAuditLoginModule implements LoginModule { protected String getPrincipalInfo() { String principalInfo; List<String> principalInfos = subject.getPrincipals(ClientPrincipal.class).stream().map(ClientPrincipal::getName).collect(toList()); if (principalInfos.size() > 0) { principalInfo = String.join(", ", principalInfos); } else { principalInfo = "no client principals found"; } return principalInfo; }  void initialize(Subject subject, CallbackHandler callbackHandler,
                           Map<String, ?> sharedState, Map<String, ?> options); boolean login(); boolean commit(); boolean abort(); boolean logout(); }
AbstractAuditLoginModule implements LoginModule { protected String getPrincipalInfo() { String principalInfo; List<String> principalInfos = subject.getPrincipals(ClientPrincipal.class).stream().map(ClientPrincipal::getName).collect(toList()); if (principalInfos.size() > 0) { principalInfo = String.join(", ", principalInfos); } else { principalInfo = "no client principals found"; } return principalInfo; }  void initialize(Subject subject, CallbackHandler callbackHandler,
                           Map<String, ?> sharedState, Map<String, ?> options); boolean login(); boolean commit(); boolean abort(); boolean logout();  }