18
18
*/
19
19
20
20
/*
21
- * Copyright (c) 2017, 2020 , Oracle and/or its affiliates. All rights reserved.
21
+ * Copyright (c) 2017, 2021 , Oracle and/or its affiliates. All rights reserved.
22
22
*/
23
23
package opengrok .auth .plugin ;
24
24
@@ -56,13 +56,13 @@ public abstract class AbstractLdapPlugin implements IAuthorizationPlugin {
56
56
* This is used to ensure that every instance of this plug-in has its own
57
57
* unique name for its session parameters.
58
58
*/
59
- public static long nextId = 1 ;
59
+ protected static long nextId = 1 ;
60
60
61
61
protected static final String CONFIGURATION_PARAM = "configuration" ;
62
62
63
63
private static final String SESSION_PREFIX = "opengrok-abstract-ldap-plugin-" ;
64
- protected String SESSION_USERNAME = SESSION_PREFIX + "username" ;
65
- protected String SESSION_ESTABLISHED = SESSION_PREFIX + "session-established" ;
64
+ protected String sessionUsername = SESSION_PREFIX + "username" ;
65
+ protected String sessionEstablished = SESSION_PREFIX + "session-established" ;
66
66
67
67
/**
68
68
* Configuration for the LDAP servers.
@@ -80,9 +80,9 @@ public abstract class AbstractLdapPlugin implements IAuthorizationPlugin {
80
80
*/
81
81
private AbstractLdapProvider ldapProvider ;
82
82
83
- public AbstractLdapPlugin () {
84
- SESSION_USERNAME += "-" + nextId ;
85
- SESSION_ESTABLISHED += "-" + nextId ;
83
+ protected AbstractLdapPlugin () {
84
+ sessionUsername += "-" + nextId ;
85
+ sessionEstablished += "-" + nextId ;
86
86
nextId ++;
87
87
}
88
88
@@ -204,8 +204,8 @@ protected boolean isSameUser(String sessionUsername, String authUser) {
204
204
*/
205
205
protected boolean sessionExists (HttpServletRequest req ) {
206
206
return req != null && req .getSession () != null
207
- && req .getSession ().getAttribute (SESSION_ESTABLISHED ) != null
208
- && req .getSession ().getAttribute (SESSION_USERNAME ) != null ;
207
+ && req .getSession ().getAttribute (sessionEstablished ) != null
208
+ && req .getSession ().getAttribute (sessionUsername ) != null ;
209
209
}
210
210
211
211
/**
@@ -237,12 +237,11 @@ private void ensureSessionExists(HttpServletRequest req) {
237
237
238
238
if (sessionExists (req )
239
239
// we've already filled the groups and projects
240
- && (boolean ) req .getSession ().getAttribute (SESSION_ESTABLISHED )
240
+ && (boolean ) req .getSession ().getAttribute (sessionEstablished )
241
241
// the session belongs to the user from the request
242
- && isSameUser ((String ) req .getSession ().getAttribute (SESSION_USERNAME ), user .getUsername ())) {
243
- /**
244
- * The session is already filled so no need to
245
- * {@link #updateSession()}
242
+ && isSameUser ((String ) req .getSession ().getAttribute (sessionUsername ), user .getUsername ())) {
243
+ /*
244
+ * The session is already filled so no need to call updateSession().
246
245
*/
247
246
return ;
248
247
}
@@ -279,7 +278,7 @@ protected void updateSession(HttpServletRequest req,
279
278
* @param value the value
280
279
*/
281
280
protected void setSessionEstablished (HttpServletRequest req , Boolean value ) {
282
- req .getSession ().setAttribute (SESSION_ESTABLISHED , value );
281
+ req .getSession ().setAttribute (sessionEstablished , value );
283
282
}
284
283
285
284
/**
@@ -289,7 +288,7 @@ protected void setSessionEstablished(HttpServletRequest req, Boolean value) {
289
288
* @param value the value
290
289
*/
291
290
protected void setSessionUsername (HttpServletRequest req , String value ) {
292
- req .getSession ().setAttribute (SESSION_USERNAME , value );
291
+ req .getSession ().setAttribute (sessionUsername , value );
293
292
}
294
293
295
294
@ Override
0 commit comments