def get_subject_identifier(self, subject_type, user_id, sector_identifier=None):
        # type: (str, str, str) -> str
        """
        Returns a subject identifier for the local user identifier.
        :param subject_type: 'pairwise' or 'public', see
            <a href="http://openid.net/specs/openid-connect-core-1_0.html#SubjectIDTypes">
            "OpenID Connect Core 1.0", Section 8</a>.
        :param user_id: local user identifier
        :param sector_identifier: the client's sector identifier,
            see <a href="http://openid.net/specs/openid-connect-core-1_0.html#Terminology">
            "OpenID Connect Core 1.0", Section 1.2</a>
        """

        if user_id not in self.subject_identifiers:
            self.subject_identifiers[user_id] = {}

        if subject_type == 'public':
            if 'public' not in self.subject_identifiers[user_id]:
                new_sub = self._subject_identifier_factory.create_public_identifier(user_id)
                self.subject_identifiers[user_id] = {'public': new_sub}

                logger.debug('created new public sub=% for user_id=%s',
                             self.subject_identifiers[user_id]['public'], user_id)
            sub = self.subject_identifiers[user_id]['public']
            logger.debug('returning public sub=%s', sub)
            return sub
        elif subject_type == 'pairwise':
            if not sector_identifier:
                raise ValueError('sector_identifier cannot be None or empty')

            subject_id = self._subject_identifier_factory.create_pairwise_identifier(user_id, sector_identifier)
            logger.debug('returning pairwise sub=%s for user_id=%s and sector_identifier=%s',
                         subject_id, user_id, sector_identifier)
            sub = self.subject_identifiers[user_id]
            pairwise_set = set(sub.get('pairwise', []))
            pairwise_set.add(subject_id)
            sub['pairwise'] = list(pairwise_set)
            self.subject_identifiers[user_id] = sub
            return subject_id

        raise ValueError('Unknown subject_type={}'.format(subject_type))
def get_subject_identifier ( self , subject_type , user_id , sector_identifier = None ) : if user_id not in self . subject_identifiers : self . subject_identifiers [ user_id ] = { } if subject_type == 'public' : if 'public' not in self . subject_identifiers [ user_id ] : new_sub = self . _subject_identifier_factory . create_public_identifier ( user_id ) self . subject_identifiers [ user_id ] = { 'public' : new_sub } logger . debug ( 'created new public sub=% for user_id=%s' , self . subject_identifiers [ user_id ] [ 'public' ] , user_id ) sub = self . subject_identifiers [ user_id ] [ 'public' ] logger . debug ( 'returning public sub=%s' , sub ) return sub elif subject_type == 'pairwise' : if not sector_identifier : raise ValueError ( 'sector_identifier cannot be None or empty' ) subject_id = self . _subject_identifier_factory . create_pairwise_identifier ( user_id , sector_identifier ) logger . debug ( 'returning pairwise sub=%s for user_id=%s and sector_identifier=%s' , subject_id , user_id , sector_identifier ) sub = self . subject_identifiers [ user_id ] pairwise_set = set ( sub . get ( 'pairwise' , [ ] ) ) pairwise_set . add ( subject_id ) sub [ 'pairwise' ] = list ( pairwise_set ) self . subject_identifiers [ user_id ] = sub return subject_id raise ValueError ( 'Unknown subject_type={}' . format ( subject_type ) )
Returns a subject identifier for the local user identifier.
        :param subject_type: 'pairwise' or 'public', see
            <a href="http://openid.net/specs/openid-connect-core-1_0.html#SubjectIDTypes">
            "OpenID Connect Core 1.0", Section 8</a>.
        :param user_id: local user identifier
        :param sector_identifier: the client's sector identifier,
            see <a href="http://openid.net/specs/openid-connect-core-1_0.html#Terminology">
            "OpenID Connect Core 1.0", Section 1.2</a>