|
18 | 18 | */
|
19 | 19 |
|
20 | 20 | /*
|
21 |
| - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. |
| 21 | + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. |
22 | 22 | */
|
23 | 23 | package opengrok.auth.plugin;
|
24 | 24 |
|
25 | 25 | import java.io.IOException;
|
26 | 26 | import java.nio.file.Files;
|
27 | 27 | import java.nio.file.Paths;
|
28 | 28 | import java.util.Map;
|
| 29 | +import java.util.Objects; |
29 | 30 | import java.util.Set;
|
30 | 31 | import java.util.TreeSet;
|
31 | 32 | import java.util.logging.Level;
|
|
43 | 44 |
|
44 | 45 | /**
|
45 | 46 | * Authorization plug-in to check user's LDAP attribute against whitelist.
|
46 |
| - * |
| 47 | + * <p> |
47 | 48 | * This plugin heavily relies on the presence of the {@code LdapUserPlugin} in the stack above it,
|
48 | 49 | * since it is using the Distinguished Name of the {@code LdapUser} to perform the LDAP lookup.
|
49 |
| - * |
| 50 | + * </p> |
50 | 51 | * @author Krystof Tulinger
|
51 | 52 | */
|
52 | 53 | public class LdapAttrPlugin extends AbstractLdapPlugin {
|
@@ -190,11 +191,11 @@ private void updateSession(HttpServletRequest req, boolean allowed) {
|
190 | 191 |
|
191 | 192 | @Override
|
192 | 193 | public boolean checkEntity(HttpServletRequest request, Project project) {
|
193 |
| - return ((Boolean) request.getSession().getAttribute(sessionAllowed)); |
| 194 | + return ((Boolean) Objects.requireNonNullElse(request.getSession().getAttribute(sessionAllowed), false)); |
194 | 195 | }
|
195 | 196 |
|
196 | 197 | @Override
|
197 | 198 | public boolean checkEntity(HttpServletRequest request, Group group) {
|
198 |
| - return ((Boolean) request.getSession().getAttribute(sessionAllowed)); |
| 199 | + return ((Boolean) Objects.requireNonNullElse(request.getSession().getAttribute(sessionAllowed), false)); |
199 | 200 | }
|
200 | 201 | }
|
0 commit comments