@Test public void testGetNameWithUserDetailsPrincipal() throws Exception { UserDetails userDetails = new User("user", "password", Collections.<GrantedAuthority>emptyList()); Authentication authentication = new TestingAuthenticationToken(userDetails, userDetails.getPassword()); Authentication ambariAuthentication = new AmbariAuthentication(authentication, DEFAULT_USER_ID); String name = ambariAuthentication.getName(); assertEquals("user", name); }
@Override public String getName() { if (principalOverride != null) { if (principalOverride instanceof UserDetails) { return ((UserDetails) principalOverride).getUsername(); } return principalOverride.toString(); } return authentication.getName(); }
AmbariAuthentication implements Authentication, UserIdAuthentication { @Override public String getName() { if (principalOverride != null) { if (principalOverride instanceof UserDetails) { return ((UserDetails) principalOverride).getUsername(); } return principalOverride.toString(); } return authentication.getName(); } }
AmbariAuthentication implements Authentication, UserIdAuthentication { @Override public String getName() { if (principalOverride != null) { if (principalOverride instanceof UserDetails) { return ((UserDetails) principalOverride).getUsername(); } return principalOverride.toString(); } return authentication.getName(); } AmbariAuthentication(Authentication authentication, Integer userId); }
AmbariAuthentication implements Authentication, UserIdAuthentication { @Override public String getName() { if (principalOverride != null) { if (principalOverride instanceof UserDetails) { return ((UserDetails) principalOverride).getUsername(); } return principalOverride.toString(); } return authentication.getName(); } AmbariAuthentication(Authentication authentication, Integer userId); @Override Collection<? extends GrantedAuthority> getAuthorities(); @Override Object getCredentials(); @Override Object getDetails(); @Override Object getPrincipal(); @Override boolean isAuthenticated(); @Override void setAuthenticated(boolean isAuthenticated); @Override String getName(); @Override boolean equals(Object o); @Override int hashCode(); @Override Integer getUserId(); }
AmbariAuthentication implements Authentication, UserIdAuthentication { @Override public String getName() { if (principalOverride != null) { if (principalOverride instanceof UserDetails) { return ((UserDetails) principalOverride).getUsername(); } return principalOverride.toString(); } return authentication.getName(); } AmbariAuthentication(Authentication authentication, Integer userId); @Override Collection<? extends GrantedAuthority> getAuthorities(); @Override Object getCredentials(); @Override Object getDetails(); @Override Object getPrincipal(); @Override boolean isAuthenticated(); @Override void setAuthenticated(boolean isAuthenticated); @Override String getName(); @Override boolean equals(Object o); @Override int hashCode(); @Override Integer getUserId();  }