Source:
<code>public QueryRequest process(Source source, QueryRequest input) throws StopProcessingException { OAuthFederatedSource oauthSource = getSource(source); if (oauthSource == null) { return input; } Object securityAssertion = input.getProperties().get(SECURITY_SUBJECT); if (!(securityAssertion instanceof Subject)) { <START> LOGGER.warn("The user's subject is not available."); <END> throw new StopProcessingException("The user's subject is not available."); } Subject subject = (Subject) securityAssertion; Session session = subject.getSession(); if (session == null) { LOGGER.warn("The user's session is not available."); throw new StopProcessingException("The user's session is not available."); } String sessionId = session.getHost(); if (sessionId == null) { LOGGER.warn("The user's session ID is not available."); throw new StopProcessingException("The user's session ID is not available."); } OIDCProviderMetadata metadata; try { metadata = OIDCProviderMetadata.parse( resourceRetriever .retrieveResource(new URL(oauthSource.getOauthDiscoveryUrl())) .getContent()); } catch (OAuthServiceException | IOException | ParseException e) { LOGGER.error( "Unable to retrieve OAuth provider's metadata for the source.", oauthSource.getId()); throw new StopProcessingException("Unable to retrieve OAuth provider's metadata."); } TokenEntry tokenEntry = tokenStorage.read(sessionId, oauthSource.getId()); if (tokenEntry == null) { findExistingTokens(oauthSource, sessionId, metadata); throw createNoAuthException( oauthSource, sessionId, metadata, "the user's tokens were not found."); } if (!oauthSource.getOauthDiscoveryUrl().equals(tokenEntry.getDiscoveryUrl())) { tokenStorage.delete(sessionId, oauthSource.getId()); findExistingTokens(oauthSource, sessionId, metadata); throw createNoAuthException( oauthSource, sessionId, metadata, "the oauth provider information has been changed and is different from the one stored."); } verifyAccessToken(oauthSource, sessionId, tokenEntry, metadata); return input; }</code><technical_language>Nitpick: This wording a bit weird me. user's subject sound user owns subject. I thought subject represented user, owned user</technical_language>

Target:
public QueryRequest process(Source source, QueryRequest input) throws StopProcessingException { OAuthFederatedSource oauthSource = getSource(source); if (oauthSource == null) { return input; } Object securityAssertion = input.getProperties().get(SECURITY_SUBJECT); if (!(securityAssertion instanceof Subject)) { LOGGER.warn("The user's subject is not available."); throw new StopProcessingException("The user's subject is not available."); } Subject subject = (Subject) securityAssertion; Session session = subject.getSession(false); if (session == null) { LOGGER.warn("The user's session is not available."); throw new StopProcessingException("The user's session is not available."); } String sessionId = (String) session.getId(); if (sessionId == null) { LOGGER.warn("The user's session ID is not available."); throw new StopProcessingException("The user's session ID is not available."); } OIDCProviderMetadata metadata; try { metadata = OIDCProviderMetadata.parse( resourceRetriever .retrieveResource(new URL(oauthSource.getOauthDiscoveryUrl())) .getContent()); } catch (OAuthServiceException | IOException | ParseException e) { LOGGER.error( "Unable to retrieve OAuth provider's metadata for the source.", oauthSource.getId()); throw new StopProcessingException("Unable to retrieve OAuth provider's metadata."); } TokenEntry tokenEntry = tokenStorage.read(sessionId, oauthSource.getId()); if (tokenEntry == null) { findExistingTokens(oauthSource, sessionId, metadata); throw createNoAuthException( oauthSource, sessionId, metadata, "the user's tokens were not found."); } if (!oauthSource.getOauthDiscoveryUrl().equals(tokenEntry.getDiscoveryUrl())) { tokenStorage.delete(sessionId, oauthSource.getId()); findExistingTokens(oauthSource, sessionId, metadata); throw createNoAuthException( oauthSource, sessionId, metadata, "the oauth provider information has been changed and is different from the one stored."); } verifyAccessToken(oauthSource, sessionId, tokenEntry, metadata); return input; }