Exemplo n.º 1
0
        public static void FetchAuthMetadata(AuthServer authServer, bool trustSslCert, bool updateIdRealm, Task.TaskWarningLoggingDelegate writeWarning, Task.TaskErrorLoggingDelegate writeError)
        {
            if (authServer == null)
            {
                throw new ArgumentNullException("authServer");
            }
            if (writeWarning == null)
            {
                throw new ArgumentNullException("writeWarning");
            }
            if (writeError == null)
            {
                throw new ArgumentNullException("writeError");
            }
            AuthMetadata authMetadata = OAuthTaskHelper.FetchAuthMetadata(authServer.AuthMetadataUrl, trustSslCert, true, writeWarning, writeError);

            AuthMetadataParser.SetEndpointsIfWSFed(authMetadata, authServer.Type, authServer.AuthMetadataUrl);
            if (updateIdRealm)
            {
                authServer.IssuerIdentifier = authMetadata.ServiceName;
                authServer.Realm            = authMetadata.Realm;
            }
            else if (!OAuthCommon.IsIdMatch(authServer.IssuerIdentifier, authMetadata.ServiceName) || !OAuthCommon.IsRealmMatchIncludingEmpty(authServer.Realm, authMetadata.Realm))
            {
                writeError(new TaskException(Strings.ErrorPidRealmDifferentFromMetadata(authMetadata.ServiceName, authMetadata.Realm, authServer.IssuerIdentifier, authServer.Realm)), ErrorCategory.InvalidData, null);
            }
            authServer.CertificateBytes      = OAuthTaskHelper.InternalCertificateFromBase64String(authMetadata.CertificateStrings, writeError);
            authServer.TokenIssuingEndpoint  = authMetadata.IssuingEndpoint;
            authServer.AuthorizationEndpoint = authMetadata.AuthorizationEndpoint;
        }
Exemplo n.º 2
0
        public static void FetchAuthMetadata(PartnerApplication partnerApplication, bool trustSslCert, bool updatePidOrRealmOrIssuer, Task.TaskWarningLoggingDelegate writeWarning, Task.TaskErrorLoggingDelegate writeError)
        {
            if (partnerApplication == null)
            {
                throw new ArgumentNullException("partnerApplication");
            }
            if (writeWarning == null)
            {
                throw new ArgumentNullException("writeWarning");
            }
            if (writeError == null)
            {
                throw new ArgumentNullException("writeError");
            }
            AuthMetadata authMetadata = OAuthTaskHelper.FetchAuthMetadata(partnerApplication.AuthMetadataUrl, trustSslCert, false, writeWarning, writeError);

            if (updatePidOrRealmOrIssuer)
            {
                partnerApplication.ApplicationIdentifier = authMetadata.ServiceName;
                partnerApplication.IssuerIdentifier      = authMetadata.Issuer;
                partnerApplication.Realm = authMetadata.Realm;
            }
            else if (!OAuthCommon.IsIdMatch(partnerApplication.ApplicationIdentifier, authMetadata.ServiceName) || !OAuthCommon.IsRealmMatchIncludingEmpty(partnerApplication.Realm, authMetadata.Realm) || !string.Equals(partnerApplication.IssuerIdentifier, authMetadata.Issuer))
            {
                writeError(new TaskException(Strings.ErrorPidRealmIssuerDifferentFromMetadata(authMetadata.ServiceName, authMetadata.Realm, authMetadata.Issuer, partnerApplication.ApplicationIdentifier, partnerApplication.Realm, partnerApplication.IssuerIdentifier)), ErrorCategory.InvalidData, null);
            }
            partnerApplication.CertificateBytes = OAuthTaskHelper.InternalCertificateFromBase64String(authMetadata.CertificateStrings, writeError);
        }
Exemplo n.º 3
0
 public static MultiValuedProperty <byte[]> CertificateFromBase64String(MultiValuedProperty <string> rawStrings, Task.TaskErrorLoggingDelegate writeError)
 {
     if (writeError == null)
     {
         throw new ArgumentNullException("writeError");
     }
     if (rawStrings == null)
     {
         return(null);
     }
     string[] rawStringArray = null;
     try
     {
         rawStringArray = rawStrings.ToArray();
     }
     catch (InvalidOperationException innerException)
     {
         writeError(new TaskException(Strings.ErrorNotSupportedModifyMultivaluedProperties, innerException), ErrorCategory.InvalidArgument, null);
     }
     return(OAuthTaskHelper.InternalCertificateFromBase64String(rawStringArray, writeError));
 }