### Question:
PluginAuthenticationInfo extends ShiroAuthenticationInfo implements CustomCredentialsMatcherSupplier { public static PluginAuthenticationInfo createCacheable( AuthenticationInfo authenticationInfo, String realmName, SecureHasher secureHasher ) { if ( authenticationInfo instanceof CustomCacheableAuthenticationInfo ) { CustomCacheableAuthenticationInfo info = (CustomCacheableAuthenticationInfo) authenticationInfo; return new PluginAuthenticationInfo( authenticationInfo.principal(), realmName, info.credentialsMatcher() ); } else if ( authenticationInfo instanceof CacheableAuthenticationInfo ) { byte[] credentials = ((CacheableAuthenticationInfo) authenticationInfo).credentials(); SimpleHash hashedCredentials = secureHasher.hash( credentials ); return PluginAuthenticationInfo.create( authenticationInfo, hashedCredentials, realmName ); } else { return PluginAuthenticationInfo.create( authenticationInfo, realmName ); } } private  PluginAuthenticationInfo( Object principal, String realmName,
            CustomCacheableAuthenticationInfo.CredentialsMatcher credentialsMatcher ); private  PluginAuthenticationInfo( Object principal, Object hashedCredentials, ByteSource credentialsSalt,
            String realmName ); @Override CustomCacheableAuthenticationInfo.CredentialsMatcher getCredentialsMatcher(); static PluginAuthenticationInfo createCacheable(
            AuthenticationInfo authenticationInfo,
            String realmName,
            SecureHasher secureHasher );  }### Answer:
@Test public void shouldCreateCorrectAuthenticationInfo() { PluginAuthenticationInfo internalAuthInfo = PluginAuthenticationInfo.createCacheable( AuthenticationInfo.of( "thePrincipal" ), "theRealm", null ); assertThat( (List<String>)internalAuthInfo.getPrincipals().asList(), containsInAnyOrder( "thePrincipal" ) ); }
@Test public void shouldCreateCorrectAuthenticationInfoFromCacheable() { SecureHasher hasher = mock( SecureHasher.class ); when( hasher.hash( any() ) ).thenReturn( new SimpleHash( "some-hash" ) ); PluginAuthenticationInfo internalAuthInfo = PluginAuthenticationInfo.createCacheable( CacheableAuthenticationInfo.of( "thePrincipal", new byte[]{1} ), "theRealm", hasher ); assertThat( (List<String>)internalAuthInfo.getPrincipals().asList(), containsInAnyOrder( "thePrincipal" ) ); }
@Test public void shouldCreateCorrectAuthenticationInfoFromCustomCacheable() { SecureHasher hasher = mock( SecureHasher.class ); when( hasher.hash( any() ) ).thenReturn( new SimpleHash( "some-hash" ) ); PluginAuthenticationInfo internalAuthInfo = PluginAuthenticationInfo.createCacheable( CustomCacheableAuthenticationInfo.of( "thePrincipal", ignoredAuthToken -> true ), "theRealm", hasher ); assertThat( (List<String>)internalAuthInfo.getPrincipals().asList(), containsInAnyOrder( "thePrincipal" ) ); }