CompositeCredentialsSupport implements CredentialsSupport { @Override @Nullable public String getUserId(@NotNull Credentials credentials) { Collection<CredentialsSupport> all = this.credentialSupplier.get(); for (CredentialsSupport c : all) { String userId = c.getUserId(credentials); if (userId != null) { return userId; } } return null; } private  CompositeCredentialsSupport(@NotNull Supplier<Collection<CredentialsSupport>> credentialSupplier); static CredentialsSupport newInstance(@NotNull Supplier<Collection<CredentialsSupport>> credentialSupplier); @Override @NotNull Set<Class> getCredentialClasses(); @Override @Nullable String getUserId(@NotNull Credentials credentials); @Override @NotNull Map<String, ?> getAttributes(@NotNull Credentials credentials); @Override boolean setAttributes(@NotNull Credentials credentials, @NotNull Map<String, ?> attributes);  }
@Test public void testGetUserId() { assertEquals("Test1CredentialsSupport", credentialsSupport.getUserId(new TestCredentials())); assertNull(credentialsSupport.getUserId(new SimpleCredentials(null, new char[0]))); assertEquals("uid", credentialsSupport.getUserId(new SimpleCredentials("uid", new char[0]))); assertNull(credentialsSupport.getUserId(new Credentials() { })); }