Skip to content

Commit

Permalink
Fixed spotlessJavaCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
hrcornejo committed Sep 29, 2023
1 parent 45ec79c commit 0792a0b
Showing 1 changed file with 31 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<GrantedAuthority>();
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<GrantedAuthority>();
crowdUserDetails
.getAuthorities()
.forEach(
authority ->
authorities.add(
new SimpleGrantedAuthority(authority.getAuthority().toLowerCase())));

return new CrowdUserDetails(crowdUserDetails.getRemotePrincipal(), authorities);
}
};
cusd.setCrowdClient(crowdClient());
cusd.setAuthorityPrefix("");

Expand Down

0 comments on commit 0792a0b

Please sign in to comment.