|
1 | 1 | /* |
2 | | - * Copyright (c) 2023 Contributors to the Eclipse Foundation |
| 2 | + * Copyright (c) 2023, 2025 Contributors to the Eclipse Foundation. |
3 | 3 | * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. |
4 | 4 | * |
5 | 5 | * This program and the accompanying materials are made available under the |
@@ -225,21 +225,24 @@ private boolean ensureGroupMembership(String user, String realm) { |
225 | 225 |
|
226 | 226 | private Subject authenticate(final Request req, final String alternateHostname) throws IOException, LoginException { |
227 | 227 | final AdminCallbackHandler cbh = new AdminCallbackHandler(habitat, req, alternateHostname, getDefaultAdminUser(), localPassword); |
228 | | - Subject s; |
229 | 228 | try { |
230 | | - s = authService.login(cbh, null); |
231 | 229 | /* |
232 | 230 | * Enforce remote access restrictions, if any. |
233 | 231 | */ |
234 | 232 | rejectRemoteAdminIfDisabled(cbh); |
235 | | - consumeTokenIfPresent(req); |
| 233 | + |
| 234 | + Subject subject = consumeTokenIfPresent(req); |
| 235 | + if (subject == null) { |
| 236 | + subject = authService.login(cbh, null); |
| 237 | + } |
| 238 | + |
236 | 239 | if (ADMSEC_LOGGER.isLoggable(Level.FINE)) { |
237 | 240 | ADMSEC_LOGGER.log(Level.FINE, "*** Login worked\n user={0}\n dn={1}\n tkn={2}\n admInd={3}\n host={4}\n", |
238 | 241 | new Object[] { cbh.pw().getUserName(), cbh.clientPrincipal() == null ? "null" : cbh.clientPrincipal().getName(), |
239 | 242 | cbh.tkn(), cbh.adminIndicator(), cbh.remoteHost() }); |
240 | 243 | } |
241 | 244 |
|
242 | | - return s; |
| 245 | + return subject; |
243 | 246 | } catch (RemoteAdminAccessException ex) { |
244 | 247 | /* |
245 | 248 | * Rethrow RemoteAdminAccessException explicitly to avoid it being |
|
0 commit comments