Get a J2C subject based on the invocation subject.
Use first subject that is not null.
197441
public static Subject getJ2CInvocationSubject() {
        Subject j2cSubject = null;
        for (J2CIdentityService j2cIdentityService : j2cIdentityServices) {
            if (j2cIdentityService.isJ2CThreadIdentityEnabled()) {
                Subject subject = j2cIdentityService.getJ2CInvocationSubject();
                if (subject != null) {
                    j2cSubject = subject;
                    break;
                }
            }
        }
        return j2cSubject;
    }
561749
public Node getOriginalResource(final Node subject) {
        if (!subject.isURI()) {
            return subject;
        }

        final String subjectUri = subject.getURI();
        final int index = subjectUri.indexOf(FCR_VERSIONS);
        if (index > 0) {
            return NodeFactory.createURI(subjectUri.substring(0, index - 1));
        } else {
            return subject;
        }
    }
1249825
public static Subject getSubject(UserGroupInformation ugi) {
    if (ugi == null) {
      return null;
    }
    
    Set<Principal> principals =       // Number of principals = username + #groups 
      new HashSet<Principal>(ugi.getGroupNames().length+1);
    User userPrincipal = new User(ugi.getUserName()); 
    principals.add(userPrincipal);
    for (String group : ugi.getGroupNames()) {
      Group groupPrincipal = new Group(group);
      principals.add(groupPrincipal);
    }
    principals.add(ugi);
    Subject user = 
      new Subject(false, principals, new HashSet<Object>(), new HashSet<Object>());
    
    return user;
  }
419813
public Subject replaceInvocationSubject(Subject invocationSubject) {
        SubjectThreadContext subjectThreadContext = getSubjectThreadContext();
        Subject replacedInvocationSubject = subjectThreadContext.getInvocationSubject();
        subjectThreadContext.setInvocationSubject(invocationSubject);
        return replacedInvocationSubject;
    }
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;
    }
362037
def get_subject(self):
        """"""
        level = logging.getLevelName(self.flush_level)
        message = self.current_buffer[0].split("\n")[0]
        message = message.split(']')[-1]
        return '{0} : {1}{2}'.format(level, SOURCE, message)
1088981
@Override
	public String getCacheKeyForJwtSSOToken(Subject subject, String encodedjwt) {
		// TODO Auto-generated method stub
		if (encodedjwt != null) {
			return HashUtils.digest(encodedjwt);
		} else if (subject != null) {
			String jwtssotoken = getJwtSSOToken(subject);
			if (jwtssotoken != null) {
				return HashUtils.digest(jwtssotoken);
			}
		}

		return null;
	}
1270353
def subject(self):
        
        template_name = self.subject_template_name() if \
            callable(self.subject_template_name) \
            else self.subject_template_name
        subject = loader.render_to_string(
            template_name, self.get_context(), request=self.request
        )
        return ''.join(subject.splitlines())
97382
def get_subject(self):
        

        if not self._run_flag.running:
            raise Exception('RuuviTagReactive stopped')

        subject = Subject()
        self._subjects.append(subject)
        return subject
950956
def _set_subject(self, subject):
        
        # if not subject:
        #     self.subject =
        def test_uri(value):
            """ test to see if the value is a uri or bnode

            Returns: Uri or Bnode """
            # .__wrapped__
            if not isinstance(value, (Uri, BlankNode)):
                try:
                    if value.startswith("_:"):
                        return BlankNode(value)
                    else:
                        return Uri(value)
                except:
                    return BlankNode()
            else:
                return value

        if isinstance(subject, dict):
            self.subject = test_uri(subject['s'])
            if isinstance(subject['o'], list):
                for item in subject['o']:
                    self.add_property(subject['p'],
                                      item)
            else:
                self.add_property(subject['p'],
                                  subject['o'])
        else:
            self.subject = test_uri(subject)
657549
@Override
    public Principal getCallerPrincipal() {

        String securityName = null;
        Principal principal = null;
        Subject callerSubject = getCallerSubject();

        if (callerSubject == null) {
            return null;
        }

        SubjectHelper subjectHelper = new SubjectHelper();
        if (subjectHelper.isUnauthenticated(callerSubject)) {
            return null;
        }

        // Here is the order to get the callerPrincipal
        // 1) jsonWebToken in subject
        // 2) From JASPIC property
        // 3) From WSCredential.getSecurityName
        // 4) From WSPrincipal
        // 5) First Principal in Subject

        // 1) From jsonWebToken in subject
        Principal jsonWebToken = MpJwtHelper.getJsonWebTokenPricipal(callerSubject);
        if (jsonWebToken != null) {
            return jsonWebToken;
        }

        WSCredential wscredential = getWSCredential(callerSubject);

        // 2) From JASPIC property
        if (wscredential != null) {
            try {
                principal = (Principal) wscredential.get("com.ibm.wsspi.security.cred.jaspi.principal");
                if (principal != null)
                    return principal;
            } catch (Exception e) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Internal error getting JASPIC Principal from credential", e);
                }
            }

            // 3) From WSCredential.getSecurityName
            try {
                securityName = wscredential.getSecurityName();
            } catch (Exception e) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Error getting securityName from WSCredential", e);
                }
            }

            WSPrincipal wsPrincipal = null;
            if (securityName != null) {
                Set<WSPrincipal> principals = callerSubject.getPrincipals(WSPrincipal.class);
                if (!principals.isEmpty()) {
                    wsPrincipal = principals.iterator().next();
                    wsPrincipal = new WSPrincipal(securityName, wsPrincipal.getAccessId(), wsPrincipal.getAuthenticationMethod());
                }

                if (wsPrincipal != null) {
                    return wsPrincipal;
                }
            }

            // 4) From WSPrincipal
            Set<Principal> principals = callerSubject.getPrincipals();
            if (principals.size() > 0) {
                for (Iterator<Principal> iterator = principals.iterator(); iterator.hasNext();) {
                    principal = iterator.next();
                    if (principal instanceof WSPrincipal)
                        return principal;
                }
            }

            // There is no WSPrincipal so just return first one
            // 5) First Principal in Subject
            return principals.iterator().next();
        }

        return null;
    }
231614
def get_objects(self, subject, predicate):
        
        for statement in self.spo_search(subject=subject, predicate=predicate):
            yield str(statement[2])
994050
def get_subjects_for_object(object=None,
                            subject_category=None,
                            subject_taxon=None,
                            relation=None,
                            **kwargs):
    
    searchresult = search_associations(object=object,
                                       fetch_subjects=True,
                                       rows=0,
                                       subject_category=subject_category,
                                       subject_taxon=subject_taxon,
                                       relation=relation,
                                       **kwargs
    )
    subjs = searchresult['subjects']
    return subjs
693643
@Sensitive
    public Hashtable<String, ?> getSensitiveHashtableFromSubject(@Sensitive final Subject subject) {
        if (System.getSecurityManager() == null) {
            return getHashtableFromSubject(subject);
        } else {
            return AccessController.doPrivileged(new GetHashtablePrivilegedAction(subject));
        }
    }
518183
def get_subject(self, msg):
        """"""

        text, encoding = decode_header(msg['subject'])[-1]

        try:
            text = text.decode(encoding)

        # If it's already decoded, ignore error
        except AttributeError:
            pass

        return text
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;
    }
545255
private String resolveSubjectToDatastream(String subject) throws ServerException{
        String pidURI = PID.toURI(m_obj.getPid());
        if (subject.startsWith(pidURI)) {
            if (subject.length() == pidURI.length()) {
                return "RELS-EXT";
            }
            if (subject.charAt(pidURI.length()) == '/') {
                return "RELS-INT";
            }
        }
        throw new GeneralException("Cannot determine which relationship datastream to update for subject " + subject + ".  Relationship subjects must be the URI of the object or the URI of a datastream within the object.");
    }