Gets the SSO token from the subject.

@param subject {@code null} is not supported.
@return
507742
public static SingleSignonToken getSSOToken(Subject subject) {
        SingleSignonToken ssoToken = null;
        Set<SingleSignonToken> ssoTokens = subject.getPrivateCredentials(SingleSignonToken.class);
        Iterator<SingleSignonToken> ssoTokensIterator = ssoTokens.iterator();
        if (ssoTokensIterator.hasNext()) {
            ssoToken = ssoTokensIterator.next();
        }
        return ssoToken;
    }
908950
def _get_subject(self):
        
        subject_context = SubjectContext(yosai=self, security_manager=self.security_manager)
        subject = self.security_manager.create_subject(subject_context=subject_context)
        global_subject_context.stack.append(subject)
        return subject
580715
private static SubjectCookie setInvocationSubject(Subject s) {
        final SubjectCookie cookie = new SubjectCookie();
        SubjectManagerService sms = smServiceRef.getService();
        if (sms != null) {
            if (s == null) {
                s = new Subject();
            }

            Subject currentInvocationSubject = sms.getInvocationSubject();
            sms.setInvocationSubject(s);

            cookie.subject = currentInvocationSubject;

            // If SYNC-TO-OS-THREAD support is enabled for the server and configured for this app,
            // then sync the Subject's identity to the thread.  The returned token is handed back
            // to the ThreadIdentityManager when we restore of the previous invocation subject
            // (under restoreInvocationSubject).
            try {
                cookie.token = ThreadIdentityManager.setAppThreadIdentity(s);
            } catch (ThreadIdentityException e) {
                throw new SecurityException(e);
            }
        }
        return cookie;
    }
990249
@Sensitive
    public Hashtable<String, ?> getSensitiveHashtableFromSubject(@Sensitive final Subject subject, @Sensitive final String[] properties) {
        return AccessController.doPrivileged(new PrivilegedAction<Hashtable<String, ?>>() {
            @Override
            public Hashtable<String, ?> run() {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Looking for custom properties in public cred list.");
                }
                Set<Object> list_public = subject.getPublicCredentials();
                Hashtable<String, ?> hashtableFromPublic = getSensitiveHashtable(list_public, properties);
                if (hashtableFromPublic != null) {
                    return hashtableFromPublic;
                }

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Looking for custom properties in private cred list.");
                }
                Set<Object> list_private = subject.getPrivateCredentials();
                Hashtable<String, ?> hashtableFromPrivate = getSensitiveHashtable(list_private, properties);
                if (hashtableFromPrivate != null) {
                    return hashtableFromPrivate;
                }

                return null;
            }
        });
    }
794208
public Subscription getSubscriptionFromRequest(HttpServletRequest request) {
		String tokenHeader = request.getHeader("Authorization");

		if (tokenHeader == null || tokenHeader.indexOf("Token ") != 0) {
			LOG.info("Empty authorizationheader, or header does not start with 'Token ': " + tokenHeader);
			return null;
		}

		String tokenValue = tokenHeader.substring(tokenHeader.indexOf(" ")).trim();
		LOG.info("Token value: " + tokenValue);

		if (tokenValue != null) {
			return subscriptionService.findSubscriptionByAuthorizationToken(tokenValue);
		}
		return null;
	}
990915
@NonNull
    public EmailIntentBuilder subject(@NonNull String subject) {
        checkNotNull(subject);
        checkNoLineBreaks(subject);
        this.subject = subject;
        return this;
    }
693643
@Sensitive
    public Hashtable<String, ?> getSensitiveHashtableFromSubject(@Sensitive final Subject subject) {
        if (System.getSecurityManager() == null) {
            return getHashtableFromSubject(subject);
        } else {
            return AccessController.doPrivileged(new GetHashtablePrivilegedAction(subject));
        }
    }
585103
private WSCredential getWSCredentialFromSubject(Subject subject) {
        if (subject != null) {
            java.util.Collection<Object> publicCreds = subject.getPublicCredentials();

            if (publicCreds != null && publicCreds.size() > 0) {
                java.util.Iterator<Object> publicCredIterator = publicCreds.iterator();

                while (publicCredIterator.hasNext()) {
                    Object cred = publicCredIterator.next();

                    if (cred instanceof WSCredential) {
                        return (WSCredential) cred;
                    }
                }
            }
        }
        return null;
    }
796931
private Subject authenticateWithCertificateChain(SSLSession session) throws SSLPeerUnverifiedException, AuthenticationException, CredentialExpiredException, CredentialDestroyedException {
        Subject transportSubject = null;
        if (session != null) {
            Certificate[] certificateChain = session.getPeerCertificates();
            transportSubject = authenticator.authenticate((X509Certificate[]) certificateChain);
            /* Here we need to get the WSCredential from the subject. We will use the subject manager for the same. */
            SubjectHelper subjectHelper = new SubjectHelper();
            WSCredential wsCredential = subjectHelper.getWSCredential(transportSubject);
            /*
             * First we tell the WSCredential that the identity token is in the form of a certificate chain. This is
             * done by setting the property "wssecurity.identity_name" to "ClientCertificate"
             */
            wsCredential.set(Constants.IDENTITY_NAME, Constants.ClientCertificate);
            /*
             * Now we need to put the certificate chain into the WScredential object. By doing this, we
             * make sure that, the authenticated certificates are indeed part of the credential. This credential
             * can be used further down the CSIv2 flow. The certificate is set as a name value pair, with the name
             * "wssecurity.identity_value"
             */
            wsCredential.set(Constants.IDENTITY_VALUE, certificateChain);
        }
        return transportSubject;
    }
510406
private static Object getSubjectAltName(X509Certificate cert, int type) {
        Collection<List<?>> subjectAltNames;

        try {
            subjectAltNames = cert.getSubjectAlternativeNames();
        } catch (CertificateParsingException cpe) {
            if (debug != null && Debug.isOn("handshake")) {
                System.out.println(
                        "Attempt to obtain subjectAltNames extension failed!");
            }
            return null;
        }

        if (subjectAltNames != null) {
            for (List<?> subjectAltName : subjectAltNames) {
                int subjectAltNameType = (Integer)subjectAltName.get(0);
                if (subjectAltNameType == type) {
                    return subjectAltName.get(1);
                }
            }
        }

        return null;
    }
358647
public KeyIdentifier getSubjectKeyId() {
        SubjectKeyIdentifierExtension ski = getSubjectKeyIdentifierExtension();
        if (ski != null) {
            try {
                return (KeyIdentifier)ski.get(
                    SubjectKeyIdentifierExtension.KEY_ID);
            } catch (IOException ioe) {} // not possible
        }
        return null;
    }
319019
protected String getAuthUser(Map<String,String> headers) {
        return headers.get(Listener.AUTHENTICATED_USER_HEADER);
    }
1304195
public static GSSCredential getCredential(Subject subject) {
	if (subject == null) {
	    return null;
	}
	Set gssCreds = subject.getPrivateCredentials(GSSCredential.class);
	if (gssCreds == null) {
	    return null;
	}
	Iterator iter = gssCreds.iterator();
	return (iter.hasNext()) ?
	    (GSSCredential)iter.next() :
	    null;
    }
1231566
public String getUserName(Subject subject) {
		// Subject subject = null;
		try {
			// subject = WSSubject.getRunAsSubject();
			WSCredential wsCred = getWSCredential(subject);
			if (wsCred == null) {
				wsCred = getPrivateWSCredential(subject);
			}
			return wsCred != null ? wsCred.getSecurityName() : null;
		} catch (Exception e) {
			// ffdc
			return null;
		}
	}
296318
@Nonnull
  public static ICommonsList <IAuthToken> getAllTokensOfSubject (@Nonnull final IAuthSubject aSubject)
  {
    ValueEnforcer.notNull (aSubject, "Subject");

    return s_aRWLock.readLocked ( () -> CommonsArrayList.createFiltered (s_aMap.values (),
                                                                         aToken -> aToken.getIdentification ()
                                                                                         .hasAuthSubject (aSubject)));
  }
1021873
def with_subject(self, subject):
        
        return self.__class__(
            self._signer,
            service_account_email=self._service_account_email,
            scopes=self._scopes,
            token_uri=self._token_uri,
            subject=subject,
            project_id=self._project_id,
            additional_claims=self._additional_claims.copy())
728728
public function getClientKey($client_id, $subject)
    {
        if (isset($this->jwt[$client_id])) {
            $jwt = $this->jwt[$client_id];
            if ($jwt) {
                if ($jwt["subject"] == $subject) {
                    return $jwt["key"];
                }
            }
        }

        return null;
    }