@Test(expected = IllegalStateException.class) public void testGetUserPrincipalBeforeLogin() { authentication.getUserPrincipal(); }
@Nullable @Override public Principal getUserPrincipal() { if (tokenInfo == null) { throw new IllegalStateException("Token info can only be retrieved after successful authentication."); } if (tokenInfo instanceof TokenProviderImpl.TokenInfoImpl) { return ((TokenProviderImpl.TokenInfoImpl) tokenInfo).getPrincipal(); } else { return null; } }
TokenAuthentication implements Authentication { @Nullable @Override public Principal getUserPrincipal() { if (tokenInfo == null) { throw new IllegalStateException("Token info can only be retrieved after successful authentication."); } if (tokenInfo instanceof TokenProviderImpl.TokenInfoImpl) { return ((TokenProviderImpl.TokenInfoImpl) tokenInfo).getPrincipal(); } else { return null; } } }
TokenAuthentication implements Authentication { @Nullable @Override public Principal getUserPrincipal() { if (tokenInfo == null) { throw new IllegalStateException("Token info can only be retrieved after successful authentication."); } if (tokenInfo instanceof TokenProviderImpl.TokenInfoImpl) { return ((TokenProviderImpl.TokenInfoImpl) tokenInfo).getPrincipal(); } else { return null; } } TokenAuthentication(@NotNull TokenProvider tokenProvider); }
TokenAuthentication implements Authentication { @Nullable @Override public Principal getUserPrincipal() { if (tokenInfo == null) { throw new IllegalStateException("Token info can only be retrieved after successful authentication."); } if (tokenInfo instanceof TokenProviderImpl.TokenInfoImpl) { return ((TokenProviderImpl.TokenInfoImpl) tokenInfo).getPrincipal(); } else { return null; } } TokenAuthentication(@NotNull TokenProvider tokenProvider); @Override boolean authenticate(@Nullable Credentials credentials); @Nullable @Override String getUserId(); @Nullable @Override Principal getUserPrincipal(); }
TokenAuthentication implements Authentication { @Nullable @Override public Principal getUserPrincipal() { if (tokenInfo == null) { throw new IllegalStateException("Token info can only be retrieved after successful authentication."); } if (tokenInfo instanceof TokenProviderImpl.TokenInfoImpl) { return ((TokenProviderImpl.TokenInfoImpl) tokenInfo).getPrincipal(); } else { return null; } } TokenAuthentication(@NotNull TokenProvider tokenProvider); @Override boolean authenticate(@Nullable Credentials credentials); @Nullable @Override String getUserId(); @Nullable @Override Principal getUserPrincipal();  }