github.com/bestchains/fabric-ca@v2.0.0-alpha+incompatible/lib/spi/affiliation.go (about)

     1  /*
     2  Copyright IBM Corp. 2016 All Rights Reserved.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8                   http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package spi
    18  
    19  // affiliationImpl defines a group name and its parent
    20  type affiliationImpl struct {
    21  	Name   string `db:"name"`
    22  	Prekey string `db:"prekey"`
    23  	Level  int    `db:"level"`
    24  }
    25  
    26  // Affiliation is the API for a user's affiliation
    27  type Affiliation interface {
    28  	GetName() string
    29  	GetPrekey() string
    30  	GetLevel() int
    31  }
    32  
    33  // NewAffiliation returns an affiliationImpl object
    34  func NewAffiliation(name, prekey string, level int) Affiliation {
    35  	return &affiliationImpl{
    36  		Name:   name,
    37  		Prekey: prekey,
    38  		Level:  level,
    39  	}
    40  }
    41  
    42  // GetName returns the name of the affiliation
    43  func (g *affiliationImpl) GetName() string {
    44  	return g.Name
    45  }
    46  
    47  // GetPrekey returns the prekey of the affiliation
    48  func (g *affiliationImpl) GetPrekey() string {
    49  	return g.Prekey
    50  }
    51  
    52  // GetLevel returns the level of the affiliation
    53  func (g *affiliationImpl) GetLevel() int {
    54  	return g.Level
    55  }