Skip to content

Commit 8dbee6e

Browse files
vladakahornace
authored andcommitted
reduce visibility of some methods/fields
also fix some style issues
1 parent 7483fa4 commit 8dbee6e

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

plugins/src/main/java/opengrok/auth/plugin/AbstractLdapPlugin.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
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.
2222
*/
2323
package opengrok.auth.plugin;
2424

@@ -56,13 +56,13 @@ public abstract class AbstractLdapPlugin implements IAuthorizationPlugin {
5656
* This is used to ensure that every instance of this plug-in has its own
5757
* unique name for its session parameters.
5858
*/
59-
public static long nextId = 1;
59+
protected static long nextId = 1;
6060

6161
protected static final String CONFIGURATION_PARAM = "configuration";
6262

6363
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";
6666

6767
/**
6868
* Configuration for the LDAP servers.
@@ -80,9 +80,9 @@ public abstract class AbstractLdapPlugin implements IAuthorizationPlugin {
8080
*/
8181
private AbstractLdapProvider ldapProvider;
8282

83-
public AbstractLdapPlugin() {
84-
SESSION_USERNAME += "-" + nextId;
85-
SESSION_ESTABLISHED += "-" + nextId;
83+
protected AbstractLdapPlugin() {
84+
sessionUsername += "-" + nextId;
85+
sessionEstablished += "-" + nextId;
8686
nextId++;
8787
}
8888

@@ -204,8 +204,8 @@ protected boolean isSameUser(String sessionUsername, String authUser) {
204204
*/
205205
protected boolean sessionExists(HttpServletRequest req) {
206206
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;
209209
}
210210

211211
/**
@@ -237,12 +237,11 @@ private void ensureSessionExists(HttpServletRequest req) {
237237

238238
if (sessionExists(req)
239239
// we've already filled the groups and projects
240-
&& (boolean) req.getSession().getAttribute(SESSION_ESTABLISHED)
240+
&& (boolean) req.getSession().getAttribute(sessionEstablished)
241241
// 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().
246245
*/
247246
return;
248247
}
@@ -279,7 +278,7 @@ protected void updateSession(HttpServletRequest req,
279278
* @param value the value
280279
*/
281280
protected void setSessionEstablished(HttpServletRequest req, Boolean value) {
282-
req.getSession().setAttribute(SESSION_ESTABLISHED, value);
281+
req.getSession().setAttribute(sessionEstablished, value);
283282
}
284283

285284
/**
@@ -289,7 +288,7 @@ protected void setSessionEstablished(HttpServletRequest req, Boolean value) {
289288
* @param value the value
290289
*/
291290
protected void setSessionUsername(HttpServletRequest req, String value) {
292-
req.getSession().setAttribute(SESSION_USERNAME, value);
291+
req.getSession().setAttribute(sessionUsername, value);
293292
}
294293

295294
@Override

0 commit comments

Comments
 (0)