SimpleCredentialsSupport implements CredentialsSupport { @Override @NotNull public Map<String, ?> getAttributes(@NotNull Credentials credentials) { if (credentials instanceof SimpleCredentials) { final SimpleCredentials sc = (SimpleCredentials) credentials; return Maps.asMap(ImmutableSet.copyOf(sc.getAttributeNames()), new Function<String, Object>() { @Nullable @Override public Object apply(String input) { return sc.getAttribute(input); } }); } else { return Collections.emptyMap(); } } private  SimpleCredentialsSupport(); static CredentialsSupport getInstance(); @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 testGetAttributes() { Map<String, ?> attributes = credentialsSupport.getAttributes(new TestCredentials()); assertNotNull(attributes); assertTrue(attributes.isEmpty()); SimpleCredentials sc = new SimpleCredentials("uid", new char[0]); attributes = credentialsSupport.getAttributes(sc); assertNotNull(attributes); assertTrue(attributes.isEmpty()); Map<String, ?> expected = ImmutableMap.of("a", "a", "b", Boolean.TRUE, "c", new TestCredentials()); for (Map.Entry<String, ?> entry : expected.entrySet()) { sc.setAttribute(entry.getKey(), entry.getValue()); } attributes = credentialsSupport.getAttributes(sc); assertNotNull(attributes); assertEquals(3, attributes.size()); assertEquals(expected, attributes); }