Skip to content

Commit 5890b24

Browse files
committed
Come back with the findbug issue - not sure how to do the deep copy
1 parent 3868dca commit 5890b24

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

src/main/java/org/jenkinsci/plugins/reverse_proxy_auth/types/CrowdAuthorizationType.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ public class CrowdAuthorizationType extends AuthorizationTypeMappingFactory {
8787
*/
8888
private static final String FILE_NAME = "types/CrowdAuthorizationType/ReverseProxyCrowdSecurityRealm.groovy";
8989

90-
public void setAuthorities(GrantedAuthority[] authorities) {
91-
this.authorities = new GrantedAuthority[0];
92-
this.authorities = authorities;
93-
}
94-
9590
@DataBoundConstructor
9691
public CrowdAuthorizationType(String crowdUrl, String crowdApplicationName, String crowdApplicationPassword, int updateInterval) {
9792
this.crowdUrl = crowdUrl;
@@ -114,22 +109,22 @@ public GrantedAuthority[] retrieveAuthorities(String userFromHeader, HttpServlet
114109
GrantedAuthority [] storedGrants = authContext.get(userFromHeader);
115110

116111
if (storedGrants != null && storedGrants.length > 1) {
117-
setAuthorities(retrieveAuthoritiesIfNecessary(authorityUpdateCache, updateInterval, userFromHeader, storedGrants));
112+
authorities = retrieveAuthoritiesIfNecessary(authorityUpdateCache, updateInterval, userFromHeader, storedGrants);
118113
} else {
119114
try {
120115
UserDetails userDetails = getSecurityRealm().loadUserByUsername(userFromHeader);
121-
setAuthorities(userDetails.getAuthorities());
116+
authorities = userDetails.getAuthorities();
122117

123118
Set<GrantedAuthority> tempLocalAuthorities = new HashSet<GrantedAuthority>(Arrays.asList(authorities));
124119
tempLocalAuthorities.add(AUTHENTICATED_AUTHORITY);
125-
setAuthorities(tempLocalAuthorities.toArray(new GrantedAuthority[0]));
120+
authorities = tempLocalAuthorities.toArray(new GrantedAuthority[0]);
126121

127122
} catch (UsernameNotFoundException e) {
128123
LOGGER.log(Level.WARNING, "User not found in the Crowd directory: " + e.getMessage());
129124

130125
Set<GrantedAuthority> tempLocalAuthorities = new HashSet<GrantedAuthority>();
131126
tempLocalAuthorities.add(AUTHENTICATED_AUTHORITY);
132-
setAuthorities(tempLocalAuthorities.toArray(new GrantedAuthority[0]));
127+
authorities = tempLocalAuthorities.toArray(new GrantedAuthority[0]);
133128
}
134129
}
135130
authContext.put(userFromHeader, authorities);

src/main/java/org/jenkinsci/plugins/reverse_proxy_auth/types/LdapAuthorizationType.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,6 @@ public String getLDAPURL() {
205205
*/
206206
public transient GrantedAuthority[] authorities = new GrantedAuthority[0];
207207

208-
public void setAuthorities(GrantedAuthority[] authorities) {
209-
this.authorities = new GrantedAuthority[0];
210-
this.authorities = authorities;
211-
}
212-
213-
214208
@DataBoundConstructor
215209
public LdapAuthorizationType(String server, String rootDN, boolean inhibitInferRootDN,
216210
String userSearchBase, String userSearch, String groupSearchBase, String groupSearchFilter, String groupMembershipFilter, String groupNameAttribute, String managerDN, String managerPassword,
@@ -331,22 +325,22 @@ public GrantedAuthority[] retrieveAuthorities(String userFromHeader, HttpServlet
331325
GrantedAuthority [] storedGrants = authContext.get(userFromHeader);
332326

333327
if (storedGrants != null && storedGrants.length > 1) {
334-
setAuthorities(retrieveAuthoritiesIfNecessary(authorityUpdateCache, updateInterval, userFromHeader, storedGrants));
328+
authorities = retrieveAuthoritiesIfNecessary(authorityUpdateCache, updateInterval, userFromHeader, storedGrants);
335329
} else {
336330
try {
337331
LdapUserDetails userDetails = (LdapUserDetails) getSecurityRealm().loadUserByUsername(userFromHeader);
338332
authorities = userDetails.getAuthorities();
339333

340334
Set<GrantedAuthority> tempLocalAuthorities = new HashSet<GrantedAuthority>(Arrays.asList(authorities));
341335
tempLocalAuthorities.add(AUTHENTICATED_AUTHORITY);
342-
setAuthorities(tempLocalAuthorities.toArray(new GrantedAuthority[0]));
336+
authorities = tempLocalAuthorities.toArray(new GrantedAuthority[0]);
343337

344338
} catch (UsernameNotFoundException e) {
345339
LOGGER.log(Level.WARNING, "User not found in the LDAP directory: " + e.getMessage());
346340

347341
Set<GrantedAuthority> tempLocalAuthorities = new HashSet<GrantedAuthority>();
348342
tempLocalAuthorities.add(AUTHENTICATED_AUTHORITY);
349-
setAuthorities(tempLocalAuthorities.toArray(new GrantedAuthority[0]));
343+
authorities = tempLocalAuthorities.toArray(new GrantedAuthority[0]);
350344
}
351345
}
352346
authContext.put(userFromHeader, authorities);

0 commit comments

Comments
 (0)