Source:
<code>public final synchronized Subject getSystemSubject() { auditSystemSubjectAccess(); final java.lang.SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(Security.GET_SYSTEM_SUBJECT_PERMISSION); } if (!javaSubjectHasAdminRole()) { SecurityLogger.audit("Unable to retrieve system subject."); return null; } if (!tokenAboutToExpire(cachedSystemSubject)) { return cachedSystemSubject; } KeyStore keyStore = AccessController.doPrivileged((PrivilegedAction<KeyStore>) this::getSystemKeyStore); String alias = null; Certificate cert = null; try { if (keyStore != null) { if (keyStore.size() == 1) { alias = keyStore.aliases().nextElement(); } else if (keyStore.size() > 1) { alias = getCertificateAlias(); } cert = keyStore.getCertificate(alias); } } catch (KeyStoreException e) { LOGGER.warn("Unable to get certificate for alias [{}]", alias, e); return null; } if (cert == null) { LOGGER.warn("Unable to get certificate for alias [{}]", alias); return null; } AuthenticationTokenFactory tokenFactory = createBasicTokenFactory(); AuthenticationToken token = tokenFactory.fromCertificates(new X509Certificate[] {(X509Certificate) cert}, "127.0.0.1"); if (token != null) { <START> ((BaseAuthenticationToken) token).setAllowGuest(true); <END> SecurityManager securityManager = getSecurityManager(); if (securityManager != null) { try { cachedSystemSubject = securityManager.getSubject(token); } catch (SecurityServiceException sse) { LOGGER.warn("Unable to request subject for system user.", sse); } } } return cachedSystemSubject; }</code><technical_language>Is for this token instance is assignable BaseAuthenticationToken this point? class checked first</technical_language>

Target:
public final synchronized Subject getSystemSubject() { auditSystemSubjectAccess(); final java.lang.SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(Security.GET_SYSTEM_SUBJECT_PERMISSION); } if (!javaSubjectHasAdminRole()) { SecurityLogger.audit("Unable to retrieve system subject."); return null; } if (!tokenAboutToExpire(cachedSystemSubject)) { return cachedSystemSubject; } KeyStore keyStore = AccessController.doPrivileged((PrivilegedAction<KeyStore>) this::getSystemKeyStore); String alias = null; Certificate cert = null; try { if (keyStore != null) { if (keyStore.size() == 1) { alias = keyStore.aliases().nextElement(); } else if (keyStore.size() > 1) { alias = getCertificateAlias(); } cert = keyStore.getCertificate(alias); } } catch (KeyStoreException e) { LOGGER.warn("Unable to get certificate for alias [{}]", alias, e); return null; } if (cert == null) { LOGGER.warn("Unable to get certificate for alias [{}]", alias); return null; } AuthenticationTokenFactory tokenFactory = createBasicTokenFactory(); AuthenticationToken token = tokenFactory.fromCertificates(new X509Certificate[] {(X509Certificate) cert}, "127.0.0.1"); if (token != null) { if (token instanceof BaseAuthenticationToken) { ((BaseAuthenticationToken) token).setAllowGuest(true); } SecurityManager securityManager = getSecurityManager(); if (securityManager != null) { try { cachedSystemSubject = securityManager.getSubject(token); } catch (SecurityServiceException sse) { LOGGER.warn("Unable to request subject for system user.", sse); } } } return cachedSystemSubject; }