Skip to content

Commit 29b233d

Browse files
committed
Fix the windbags issue
1 parent 5890b24 commit 29b233d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import javax.servlet.http.HttpServletRequest;
2323
import java.io.IOException;
2424
import java.util.Arrays;
25+
import java.util.Collections;
2526
import java.util.HashSet;
2627
import java.util.Hashtable;
2728
import java.util.Set;
@@ -59,7 +60,7 @@ public class CrowdAuthorizationType extends AuthorizationTypeMappingFactory {
5960
* The authorities that are granted to the authenticated user.
6061
* It is not necessary, that the authorities will be stored in the config.xml, they blow up the config.xml
6162
*/
62-
public transient GrantedAuthority[] authorities = new GrantedAuthority[0];
63+
private transient GrantedAuthority[] authorities = new GrantedAuthority[0];
6364

6465
/**
6566
* The username retrieved from the header field, which is represented by the forwardedUser attribute.
@@ -128,7 +129,8 @@ public GrantedAuthority[] retrieveAuthorities(String userFromHeader, HttpServlet
128129
}
129130
}
130131
authContext.put(userFromHeader, authorities);
131-
return authorities;
132+
133+
return Collections.unmodifiableList(Arrays.asList(authorities)).toArray(new GrantedAuthority[authorities.length]);
132134
}
133135

134136
@Override

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.net.Socket;
3636
import java.net.UnknownHostException;
3737
import java.util.Arrays;
38+
import java.util.Collections;
3839
import java.util.HashSet;
3940
import java.util.Hashtable;
4041
import java.util.Set;
@@ -203,7 +204,7 @@ public String getLDAPURL() {
203204
* The authorities that are granted to the authenticated user.
204205
* It is not necessary, that the authorities will be stored in the config.xml, they blow up the config.xml
205206
*/
206-
public transient GrantedAuthority[] authorities = new GrantedAuthority[0];
207+
private transient GrantedAuthority[] authorities = new GrantedAuthority[0];
207208

208209
@DataBoundConstructor
209210
public LdapAuthorizationType(String server, String rootDN, boolean inhibitInferRootDN,
@@ -344,7 +345,7 @@ public GrantedAuthority[] retrieveAuthorities(String userFromHeader, HttpServlet
344345
}
345346
}
346347
authContext.put(userFromHeader, authorities);
347-
return authorities;
348+
return Collections.unmodifiableList(Arrays.asList(authorities)).toArray(new GrantedAuthority[authorities.length]);
348349
}
349350

350351

0 commit comments

Comments
 (0)