Skip to content

Commit f87ba31

Browse files
authored
Merge pull request #25354 from avpinchuk/admin-login
Improve HTTP admin login flow
2 parents 50b3981 + 0bcf09a commit f87ba31

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

nucleus/admin/util/src/main/java/com/sun/enterprise/admin/util/GenericAdminAuthenticator.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023 Contributors to the Eclipse Foundation
2+
* Copyright (c) 2023, 2025 Contributors to the Eclipse Foundation.
33
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
44
*
55
* This program and the accompanying materials are made available under the
@@ -225,21 +225,24 @@ private boolean ensureGroupMembership(String user, String realm) {
225225

226226
private Subject authenticate(final Request req, final String alternateHostname) throws IOException, LoginException {
227227
final AdminCallbackHandler cbh = new AdminCallbackHandler(habitat, req, alternateHostname, getDefaultAdminUser(), localPassword);
228-
Subject s;
229228
try {
230-
s = authService.login(cbh, null);
231229
/*
232230
* Enforce remote access restrictions, if any.
233231
*/
234232
rejectRemoteAdminIfDisabled(cbh);
235-
consumeTokenIfPresent(req);
233+
234+
Subject subject = consumeTokenIfPresent(req);
235+
if (subject == null) {
236+
subject = authService.login(cbh, null);
237+
}
238+
236239
if (ADMSEC_LOGGER.isLoggable(Level.FINE)) {
237240
ADMSEC_LOGGER.log(Level.FINE, "*** Login worked\n user={0}\n dn={1}\n tkn={2}\n admInd={3}\n host={4}\n",
238241
new Object[] { cbh.pw().getUserName(), cbh.clientPrincipal() == null ? "null" : cbh.clientPrincipal().getName(),
239242
cbh.tkn(), cbh.adminIndicator(), cbh.remoteHost() });
240243
}
241244

242-
return s;
245+
return subject;
243246
} catch (RemoteAdminAccessException ex) {
244247
/*
245248
* Rethrow RemoteAdminAccessException explicitly to avoid it being

0 commit comments

Comments
 (0)