Skip to content

Commit e008682

Browse files
Vladimir Kotalahornace
authored andcommitted
reshuffle variables
1 parent e310f75 commit e008682

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,9 @@ String getSessionAllowedAttrName() {
126126

127127
@Override
128128
public void fillSession(HttpServletRequest req, User user) {
129-
boolean sessionAllowed;
130-
LdapUser ldapUser;
131-
Map<String, Set<String>> records = null;
132-
Set<String> attributeValues;
133-
134129
updateSession(req, false);
135130

131+
LdapUser ldapUser;
136132
if ((ldapUser = (LdapUser) req.getSession().
137133
getAttribute(LdapUserPlugin.getSessionAttrName(ldapUserInstance))) == null) {
138134
LOGGER.log(Level.WARNING, "cannot get {0} attribute from {1}",
@@ -142,8 +138,9 @@ public void fillSession(HttpServletRequest req, User user) {
142138

143139
// Check attributes cached in LDAP user object first, then query LDAP server
144140
// (and if found, cache the result in the LDAP user object).
145-
attributeValues = ldapUser.getAttribute(ldapAttr);
141+
Set<String> attributeValues = ldapUser.getAttribute(ldapAttr);
146142
if (attributeValues == null) {
143+
Map<String, Set<String>> records = null;
147144
AbstractLdapProvider ldapProvider = getLdapProvider();
148145
try {
149146
String dn = ldapUser.getDn();
@@ -175,7 +172,7 @@ public void fillSession(HttpServletRequest req, User user) {
175172
ldapUser.setAttribute(ldapAttr, attributeValues);
176173
}
177174

178-
sessionAllowed = attributeValues.stream().anyMatch(whitelist::contains);
175+
boolean sessionAllowed = attributeValues.stream().anyMatch(whitelist::contains);
179176
LOGGER.log(Level.FINEST, "LDAP user {0} {1} against {2}",
180177
new Object[]{ldapUser, sessionAllowed ? "allowed" : "denied", filePath});
181178
updateSession(req, sessionAllowed);

0 commit comments

Comments
 (0)