// GetValueForSessionName gets a value string from an http.Header.
18736
func (s *HeaderStorer) GetValueForSessionName(r *http.Request, name string) (string, error) {
	// fetch header field from header.
	headerBase64Encoded := r.Header.Get(s.HeaderFieldName)
	if headerBase64Encoded == "" {
		return "", ErrValueNotFound
	}

	// fetch value for name from JSON map.
	headerMap, err := s.headerToMap(headerBase64Encoded)
	if err != nil {
		return "", err
	}
	value, exists := headerMap[name]
	if !exists {
		return "", ErrValueNotFound
	}
	return value, nil
}
1288636
func (s Session) GetProperty(key string, value interface{}) (interface{}, error) {
	// Capitalize the first letter
	key = strings.Title(key)

	sessionLog.Info("getProperty", "key", key, "value", value)

	// For a map it is easy
	if reflect.TypeOf(value).Kind() == reflect.Map {
		val := reflect.ValueOf(value)
		valueOf := val.MapIndex(reflect.ValueOf(key))
		if valueOf == reflect.Zero(reflect.ValueOf(value).Type()) {
			return nil, nil
		}
		//idx := val.MapIndex(reflect.ValueOf(key))
		if !valueOf.IsValid() {
			return nil, nil
		}

		return valueOf.Interface(), nil
	}

	objValue := s.reflectValue(value)
	field := objValue.FieldByName(key)
	if !field.IsValid() {
		return nil, SESSION_VALUE_NOT_FOUND
	}

	return field.Interface(), nil
}
1269614
func (c *Conn) GetSession(id string) (dbus.ObjectPath, error) {
	var out interface{}
	if err := c.object.Call(dbusInterface+".GetSession", 0, id).Store(&out); err != nil {
		return "", err
	}

	ret, ok := out.(dbus.ObjectPath)
	if !ok {
		return "", fmt.Errorf("failed to typecast session to ObjectPath")
	}

	return ret, nil
}
56086
func (r Account) GetAccountTraitValue(keyName *string) (resp string, err error) {
	params := []interface{}{
		keyName,
	}
	err = r.Session.DoRequest("SoftLayer_Account", "getAccountTraitValue", params, &r.Options, &resp)
	return
}
728215
func (s *RegisterUserInput) SetSessionName(v string) *RegisterUserInput {
	s.SessionName = &v
	return s
}
88605
func (s *HTTPServer) SessionsForNode(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
	args := structs.NodeSpecificRequest{}
	if done := s.parse(resp, req, &args.Datacenter, &args.QueryOptions); done {
		return nil, nil
	}

	// Pull out the node name
	args.Node = strings.TrimPrefix(req.URL.Path, "/v1/session/node/")
	if args.Node == "" {
		resp.WriteHeader(http.StatusBadRequest)
		fmt.Fprint(resp, "Missing node name")
		return nil, nil
	}

	var out structs.IndexedSessions
	defer setMeta(resp, &out.QueryMeta)
	if err := s.agent.RPC("Session.NodeSessions", &args, &out); err != nil {
		return nil, err
	}

	// Use empty list instead of nil
	if out.Sessions == nil {
		out.Sessions = make(structs.Sessions, 0)
	}
	return out.Sessions, nil
}
61570
func (r *Room) GetSessionData(ctx context.Context) (*SessionData, error) {
	s := pitaya.GetSessionFromCtx(ctx)
	return &SessionData{
		Data: s.GetData(),
	}, nil
}
208130
func (d *discardSessionServer) GetSession(namespace string, id ID) (*Session, error) {
	return &Session{}, nil
}
110850
func (c *Client) FindSession(ctx context.Context, key string) (*platform.Session, error) {
	op := getOp(platform.OpFindSession)
	var sess *platform.Session
	err := c.db.View(func(tx *bolt.Tx) error {
		s, err := c.findSession(ctx, tx, key)
		if err != nil {
			return err
		}

		sess = s
		return nil
	})

	if err != nil {
		return nil, &platform.Error{
			Err: err,
			Op:  op,
		}
	}

	if err := sess.Expired(); err != nil {
		// todo(leodido) > do we want to return session also if expired?
		return sess, &platform.Error{
			Err: err,
			Op:  op,
		}
	}
	return sess, nil
}
614193
func (m *Module) getSessionFromRequest(req *http.Request) (*UserSession, error) {
	cookie, err := req.Cookie(m.CookieName)
	if err == http.ErrNoCookie {
		return nil, nil
	} else if err != nil {
		m.Logger.Error(errors.Wrap(err))
		return nil, nil
	}

	obj, err := jose.ParseEncrypted(cookie.Value)
	if err != nil {
		m.Logger.Error(errors.Wrap(err))
		return nil, nil
	}

	b, err := obj.Decrypt(m.decryptionKey)
	session := &UserSession{}
	if err = json.Unmarshal(b, session); err != nil {
		m.Logger.Error(errors.Wrap(err))
		return nil, nil
	}
	if m.RevocationStore.IsRevoked(session.SessionID) {
		return nil, nil
	}

	return session, nil
}
1089788
func (c *Client) GetWebSessionInfo(user string, sid string) (services.WebSession, error) {
	out, err := c.Get(
		c.Endpoint("users", user, "web", "sessions", sid), url.Values{})
	if err != nil {
		return nil, trace.Wrap(err)
	}
	return services.GetWebSessionMarshaler().UnmarshalWebSession(out.Bytes())
}
1314216
func (kv *consulKV) getActiveSession(key string) (string, error) {
	pair, _, err := kv.client.Get(key, nil)
	if err != nil {
		return "", err
	}
	if pair != nil && pair.Session != "" {
		return pair.Session, nil
	}
	return "", nil
}
1301496
func (t *TowerDB) GetSessionInfo(id *SessionID) (*SessionInfo, error) {
	var session *SessionInfo
	err := t.db.View(func(tx *bbolt.Tx) error {
		sessions := tx.Bucket(sessionsBkt)
		if sessions == nil {
			return ErrUninitializedDB
		}

		var err error
		session, err = getSession(sessions, id[:])
		return err
	})
	if err != nil {
		return nil, err
	}

	return session, nil
}
1152776
func getSession(sessions *bbolt.Bucket, id []byte) (*SessionInfo, error) {
	sessionBytes := sessions.Get(id)
	if sessionBytes == nil {
		return nil, ErrSessionNotFound
	}

	var session SessionInfo
	err := session.Decode(bytes.NewReader(sessionBytes))
	if err != nil {
		return nil, err
	}

	return &session, nil
}
1111720
func GetSession(req *restful.Request) *Session {
	m := req.Attribute(AttrSessionKey)
	if m == nil {
		panic("GetSession attribute is nil")
	}
	session, ok := m.(*Session)
	if !ok {
		panic(fmt.Sprintf("GetSession attribute isn't a session type, but %#v", m))
	}
	return session
}
31295
func GetLocationByName(sess *session.Session, name string, args ...interface{}) (datatypes.Location, error) {
	var mask string
	if len(args) > 0 {
		mask = args[0].(string)
	}

	locs, err := services.GetLocationService(sess).
		Mask(mask).
		Filter(filter.New(filter.Path("name").Eq(name)).Build()).
		GetDatacenters()

	if err != nil {
		return datatypes.Location{}, err
	}

	// An empty filtered result set does not raise an error
	if len(locs) == 0 {
		return datatypes.Location{}, fmt.Errorf("No locations found with name of %s", name)
	}

	return locs[0], nil
}
534132
func (mem *memNamedMapping) GetValue(name string) (value interface{}, exists bool) {
	mem.access.RLock()
	defer mem.access.RUnlock()

	item, found := mem.nameToIdx[name]
	if found {
		return item.value, found
	}
	return
}