@@ -56,7 +56,7 @@ public class LdapAttrPlugin extends AbstractLdapPlugin {
56
56
static final String FILE_PARAM = "file" ;
57
57
static final String INSTANCE_PARAM = "instance" ;
58
58
59
- static final String SESSION_ALLOWED_PREFIX = "opengrok-ldap-attr-plugin-allowed" ;
59
+ private static final String SESSION_ALLOWED_PREFIX = "opengrok-ldap-attr-plugin-allowed" ;
60
60
private String sessionAllowed = SESSION_ALLOWED_PREFIX ;
61
61
62
62
/**
@@ -69,7 +69,6 @@ public class LdapAttrPlugin extends AbstractLdapPlugin {
69
69
*/
70
70
private String ldapAttr ;
71
71
private final Set <String > whitelist = new TreeSet <>();
72
- private String filePath ;
73
72
private Integer ldapUserInstance ;
74
73
75
74
public LdapAttrPlugin () {
@@ -90,11 +89,12 @@ public void load(Map<String, Object> parameters) {
90
89
init (parameters );
91
90
}
92
91
93
- void init (Map <String , Object > parameters ) {
92
+ private void init (Map <String , Object > parameters ) {
94
93
if ((ldapAttr = (String ) parameters .get (ATTR_PARAM )) == null ) {
95
94
throw new NullPointerException ("Missing param [" + ATTR_PARAM + "] in the setup" );
96
95
}
97
96
97
+ String filePath ;
98
98
if ((filePath = (String ) parameters .get (FILE_PARAM )) == null ) {
99
99
throw new NullPointerException ("Missing param [" + FILE_PARAM + "] in the setup" );
100
100
}
@@ -128,10 +128,9 @@ String getSessionAllowedAttrName() {
128
128
return sessionAllowed ;
129
129
}
130
130
131
- @ SuppressWarnings ("unchecked" )
132
131
@ Override
133
132
public void fillSession (HttpServletRequest req , User user ) {
134
- Boolean sessionAllowed ;
133
+ boolean sessionAllowed ;
135
134
LdapUser ldapUser ;
136
135
Map <String , Set <String >> records = null ;
137
136
Set <String > attributeValues ;
@@ -147,7 +146,7 @@ public void fillSession(HttpServletRequest req, User user) {
147
146
// (and if found, cache the result in the LDAP user object).
148
147
attributeValues = ldapUser .getAttribute (ldapAttr );
149
148
if (attributeValues != null ) {
150
- sessionAllowed = attributeValues .stream ().anyMatch (( t ) -> whitelist . contains ( t ) );
149
+ sessionAllowed = attributeValues .stream ().anyMatch (whitelist :: contains );
151
150
} else {
152
151
try {
153
152
String dn = ldapUser .getDn ();
@@ -175,7 +174,7 @@ public void fillSession(HttpServletRequest req, User user) {
175
174
}
176
175
177
176
ldapUser .setAttribute (ldapAttr , attributeValues );
178
- sessionAllowed = attributeValues .stream ().anyMatch (( t ) -> whitelist . contains ( t ) );
177
+ sessionAllowed = attributeValues .stream ().anyMatch (whitelist :: contains );
179
178
}
180
179
181
180
updateSession (req , sessionAllowed );
@@ -187,7 +186,7 @@ public void fillSession(HttpServletRequest req, User user) {
187
186
* @param req the request
188
187
* @param allowed the new value
189
188
*/
190
- protected void updateSession (HttpServletRequest req , boolean allowed ) {
189
+ private void updateSession (HttpServletRequest req , boolean allowed ) {
191
190
req .getSession ().setAttribute (sessionAllowed , allowed );
192
191
}
193
192
0 commit comments