// Subject is a convenience function to retrieve the corresponding value store in the token
// if there is a problem retrieving the value, the zero value is returned. If you need to differentiate between existing/non-existing values, use `Get` instead
514507
func (t Token) Subject() string {
	if v, ok := t.Get(SubjectKey); ok {
		return v.(string)
	}
	return ""
}
1267020
func (p SubjectPath) Subject(e *Entity) (string, error) {
	var next Object = e
	var prev *Entity
	var item string
	for _, item = range p {
		ent, ok := next.(*Entity)
		if !ok {
			return "", errors.Errorf("can't get '%v' out of non-entity %#v.", item, next)
		}
		prev = ent
		next = ent.Objects[Property(item)]
	}
	delete(prev.Objects, Property(item)) // remove the subject from the entity so that it isn't indexed
	switch next.(type) {
	case I, I8, I16, I32, I64, U, U8, U16, U32, U64:
		return fmt.Sprintf("%d", next), nil
	case F32, F64:
		return fmt.Sprintf("%f", next), nil
	case S:
		return string(next.(S)), nil
	default:
		return "", fmt.Errorf("can't make %v of type %T an IRI", next, next)
	}
}
1259369
func (m *TokenManager) Get(key string) (token Token) {
	stmt := Tokens.Select().Where(Tokens.C("key").Equals(key))
	m.conn.Query(stmt, &token)
	return
}
1313537
func (c *Client) getConfigSubject(subject string) (Config, error) {
	var err error
	var config = Config{}

	path := fmt.Sprintf("/config/%s", subject)
	resp, respErr := c.do(http.MethodGet, path, "", nil)
	if respErr != nil && respErr.(ResourceError).ErrorCode != 404 {
		return config, respErr
	}
	if resp != nil {
		err = c.readJSON(resp, &config)
	}

	return config, err
}
882122
func (_class AuthClass) GetSubjectIdentifier(sessionID SessionRef, subjectName string) (_retval string, _err error) {
	_method := "auth.get_subject_identifier"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_subjectNameArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "subject_name"), subjectName)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _subjectNameArg)
	if _err != nil {
		return
	}
	_retval, _err = convertStringToGo(_method + " -> ", _result.Value)
	return
}
3879
func (value Value) Object() *Object {
	switch object := value.value.(type) {
	case *_object:
		return _newObject(object, value)
	}
	return nil
}
172798
func Topic(pattern string, fn func(res *Response) error) handler {
	return &Handler{Method: TOPIC, Run: fn}
}
739909
func (c Claims) SetSubject(subject string) {
	jwt.Claims(c).SetSubject(subject)
}
1092113
func (p *Parser) object() (ast.Node, error) {
	defer un(trace(p, "ParseType"))
	tok := p.scan()

	switch tok.Type {
	case token.NUMBER, token.FLOAT, token.BOOL, token.STRING, token.HEREDOC:
		return p.literalType()
	case token.LBRACE:
		return p.objectType()
	case token.LBRACK:
		return p.listType()
	case token.COMMENT:
		// implement comment
	case token.EOF:
		return nil, errEofToken
	}

	return nil, &PosError{
		Pos: tok.Pos,
		Err: fmt.Errorf("Unknown token: %+v", tok),
	}
}
1205705
func (s *constStore) Get(parent, scope string) (string, error) {
	return s.token, nil
}
258493
func (c *EncodedConn) Subscribe(subject string, cb Handler) (*Subscription, error) {
	return c.subscribe(subject, _EMPTY_, cb)
}
511025
func (j *JWT) Response(values map[string]interface{}) (tokenString string, err error) {
	token := jwt.New(jwt.SigningMethodHS256)
	// Headers
	token.Header["alg"] = "HS256"
	token.Header["typ"] = "JWT"
	// Claims
	token.Claims = values
	token.Claims["exp"] = time.Now().Add(time.Hour * 72).Unix()
	tokenString, err = token.SignedString([]byte(j.Secret))
	return
}
93986
func (ts *TokenStore) Lookup(ctx context.Context, id string) (*logical.TokenEntry, error) {
	defer metrics.MeasureSince([]string{"token", "lookup"}, time.Now())
	if id == "" {
		return nil, fmt.Errorf("cannot lookup blank token")
	}

	// If it starts with "b." it's a batch token
	if len(id) > 2 && strings.HasPrefix(id, "b.") {
		return ts.lookupBatchToken(ctx, id)
	}

	lock := locksutil.LockForKey(ts.tokenLocks, id)
	lock.RLock()
	defer lock.RUnlock()

	return ts.lookupInternal(ctx, id, false, false)
}
227026
func (ts *TokenStore) store(ctx context.Context, entry *logical.TokenEntry) error {
	defer metrics.MeasureSince([]string{"token", "store"}, time.Now())
	return ts.storeCommon(ctx, entry, false)
}
265479
func (r *Record) Get(key string) (value interface{}, err error) {
	value, ok := r.Data[key]
	if !ok {
		value = ""
	}
	return
}
198170
func (s Subject) String() string {
	var comp []string
	if len(s.Country) > 0 {
		comp = append(comp, "C="+strings.Join(s.Country, ", C="))
	}
	if len(s.Organisation) > 0 {
		comp = append(comp, "O="+strings.Join(s.Organisation, ", O="))
	}
	if len(s.OrgUnit) > 0 {
		comp = append(comp, "OU="+strings.Join(s.OrgUnit, ", OU="))
	}
	if len(s.CommonName) > 0 {
		comp = append(comp, "CN="+s.CommonName)
	}
	return strings.Join(comp, ", ")
}
1039460
func (c *Client) GetToken() (string, error) {
	token, err := c.config.TokenSource.Token()
	if err != nil {
		return "", fmt.Errorf("Error getting bearer token: %v", err)
	}
	return "bearer " + token.AccessToken, nil
}