From 0792a0b6d7279cde4e69f7226476db122f99a1f4 Mon Sep 17 00:00:00 2001 From: "Rodriguez,Hector (IT EDP)" Date: Fri, 29 Sep 2023 16:15:56 +0200 Subject: [PATCH] Fixed spotlessJavaCheck --- .../crowd/CrowdSecurityConfiguration.java | 55 +++++++++++-------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/opendevstack/provision/authentication/crowd/CrowdSecurityConfiguration.java b/src/main/java/org/opendevstack/provision/authentication/crowd/CrowdSecurityConfiguration.java index f8bc8a62..8f57b25d 100644 --- a/src/main/java/org/opendevstack/provision/authentication/crowd/CrowdSecurityConfiguration.java +++ b/src/main/java/org/opendevstack/provision/authentication/crowd/CrowdSecurityConfiguration.java @@ -28,7 +28,6 @@ import com.atlassian.crowd.integration.springsecurity.user.CrowdUserDetails; import com.atlassian.crowd.integration.springsecurity.user.CrowdUserDetailsService; import com.atlassian.crowd.integration.springsecurity.user.CrowdUserDetailsServiceImpl; -import com.atlassian.crowd.model.user.UserWithAttributes; import com.atlassian.crowd.service.client.ClientProperties; import com.atlassian.crowd.service.client.ClientPropertiesImpl; import com.atlassian.crowd.service.client.CrowdClient; @@ -310,31 +309,39 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception { @Bean public CrowdUserDetailsService crowdUserDetailsService() throws IOException { - CrowdUserDetailsServiceImpl cusd = new CrowdUserDetailsServiceImpl() { - @Override - public CrowdUserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { - return updateCrowdUserDetails(super.loadUserByUsername(username)); - } - - @Override - public CrowdUserDetails loadUserByToken(String token) throws CrowdSSOTokenInvalidException, DataAccessException { - return updateCrowdUserDetails(super.loadUserByToken(token)); - } + CrowdUserDetailsServiceImpl cusd = + new CrowdUserDetailsServiceImpl() { + @Override + public CrowdUserDetails loadUserByUsername(String username) + throws UsernameNotFoundException, DataAccessException { + return updateCrowdUserDetails(super.loadUserByUsername(username)); + } - /** - * Return the groups of user in LowerCase to avoid problems with the rest of authorization. - * @param crowdUserDetails CrowdUserDetails obtained with Authorities not processed - * @return CrowdUserDetails with Authorities in lowercase - */ - CrowdUserDetails updateCrowdUserDetails(CrowdUserDetails crowdUserDetails) { - ArrayList authorities = new ArrayList(); - crowdUserDetails.getAuthorities().forEach( - authority -> authorities.add(new SimpleGrantedAuthority(authority.getAuthority().toLowerCase()))); - - return new CrowdUserDetails(crowdUserDetails.getRemotePrincipal(), authorities); - } + @Override + public CrowdUserDetails loadUserByToken(String token) + throws CrowdSSOTokenInvalidException, DataAccessException { + return updateCrowdUserDetails(super.loadUserByToken(token)); + } - }; + /** + * Return the groups of user in LowerCase to avoid problems with the rest of + * authorization. + * + * @param crowdUserDetails CrowdUserDetails obtained with Authorities not processed + * @return CrowdUserDetails with Authorities in lowercase + */ + CrowdUserDetails updateCrowdUserDetails(CrowdUserDetails crowdUserDetails) { + ArrayList authorities = new ArrayList(); + crowdUserDetails + .getAuthorities() + .forEach( + authority -> + authorities.add( + new SimpleGrantedAuthority(authority.getAuthority().toLowerCase()))); + + return new CrowdUserDetails(crowdUserDetails.getRemotePrincipal(), authorities); + } + }; cusd.setCrowdClient(crowdClient()); cusd.setAuthorityPrefix("");