/// <summary> /// Creates a serializer/deserializer for this type. /// </summary> /// <param name="authorizationServer">The authorization server that will be serializing/deserializing this authorization code. Must not be null.</param> /// <returns>A DataBag formatter.</returns> internal static IDataBagFormatter<AuthorizationCode> CreateFormatter(IAuthorizationServerHost authorizationServer) { Requires.NotNull(authorizationServer, "authorizationServer"); var cryptoStore = authorizationServer.CryptoKeyStore; ErrorUtilities.VerifyHost(cryptoStore != null, OAuthStrings.ResultShouldNotBeNull, authorizationServer.GetType(), "CryptoKeyStore"); return new UriStyleMessageFormatter<AuthorizationCode>( cryptoStore, AuthorizationCodeKeyBucket, signed: true, encrypted: true, compressed: false, maximumAge: MaximumMessageAge, decodeOnceOnly: authorizationServer.NonceStore); }
/// <summary> /// Gets information about the client with a given identifier. /// </summary> /// <param name="authorizationServer">The authorization server.</param> /// <param name="clientIdentifier">The client identifier.</param> /// <returns>The client information. Never null.</returns> internal static IClientDescription GetClientOrThrow(this IAuthorizationServerHost authorizationServer, string clientIdentifier) { Requires.NotNullOrEmpty(clientIdentifier, "clientIdentifier"); try { var result = authorizationServer.GetClient(clientIdentifier); ErrorUtilities.VerifyHost(result != null, OAuthStrings.ResultShouldNotBeNull, authorizationServer.GetType().FullName, "GetClient(string)"); return(result); } catch (KeyNotFoundException ex) { throw ErrorUtilities.Wrap(ex, AuthServerStrings.ClientOrTokenSecretNotFound); } catch (ArgumentException ex) { throw ErrorUtilities.Wrap(ex, AuthServerStrings.ClientOrTokenSecretNotFound); } }
/// <summary> /// Creates a serializer/deserializer for this type. /// </summary> /// <param name="authorizationServer">The authorization server that will be serializing/deserializing this authorization code. Must not be null.</param> /// <returns>A DataBag formatter.</returns> internal static IDataBagFormatter <AuthorizationCode> CreateFormatter(IAuthorizationServerHost authorizationServer) { Requires.NotNull(authorizationServer, "authorizationServer"); var cryptoStore = authorizationServer.CryptoKeyStore; ErrorUtilities.VerifyHost(cryptoStore != null, OAuthStrings.ResultShouldNotBeNull, authorizationServer.GetType(), "CryptoKeyStore"); return(new UriStyleMessageFormatter <AuthorizationCode>( cryptoStore, AuthorizationCodeKeyBucket, signed: true, encrypted: true, compressed: false, maximumAge: MaximumMessageAge, decodeOnceOnly: authorizationServer.NonceStore)); }