Exemplo n.º 1
0
        public static Audience AddAudience(string name)
        {
            //Generating random string of 32 characters as an identifier for the audience (client id).
            var clientId = Guid.NewGuid().ToString("N");

            //Generating 256 bit random key using the “RNGCryptoServiceProvider” class then base 64 URL encode it,
            //this key will be shared between the Authorization server and the Resource server only.
            var key = new byte[32];

            RNGCryptoServiceProvider.Create().GetBytes(key);
            var base64Secret = TextEncodings.Base64Url.Encode(key);

            //Add the newly generated audience to the in-memory “AudiencesList”.
            var newAudience = new Audience {
                ClientId = clientId, Base64Secret = base64Secret, Name = name
            };

            audienceList.TryAdd(clientId, newAudience);
            return(newAudience);
        }
Exemplo n.º 2
0
        public static Audience AddAudience(string name)
        {
            //生成32个字符的随机字符串作为受众的标识符(客户端ID)。
            //使用所述“RNGCryptoServiceProvider|RandomNumberGenerator”类的256位随机密钥然后用Base64的URL编码它,该键将授权服务器和资源服务器之间共享只。
            //将新生成的观众添加到内存“AudiencesList”中。
            //“FindAudience”方法负责根据客户端ID查找受众。
            //该类的构造函数包含用于演示目的的固定受众。
            var clientId = Guid.NewGuid().ToString("N");

            var key = new byte[32];

            RandomNumberGenerator.Create().GetBytes(key);
            var base64Secret = TextEncodings.Base64Url.Encode(key);

            Audience newAudience = new Audience {
                ClientId = clientId, Base64Secret = base64Secret, Name = name
            };

            AudiencesList.TryAdd(clientId, newAudience);
            return(newAudience);
        }