Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Advanced/DeploymentService/DeploymentServerCertificateValidator.cs @ 3831

Last change on this file since 3831 was 3771, checked in by gkronber, 14 years ago

Prepared deployment service proxy classes for migration of deployment server to a production environment. #989

File size: 1.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Security.Cryptography.X509Certificates;
6using System.IdentityModel.Selectors;
7using System.IdentityModel.Tokens;
8
9namespace HeuristicLab.PluginInfrastructure.Advanced.DeploymentService {
10  internal class DeploymentServerCertificateValidator : X509CertificateValidator {
11    private X509Certificate2 allowedCertificate;
12    public DeploymentServerCertificateValidator(X509Certificate2 allowedCertificate) {
13      if (allowedCertificate == null) {
14        throw new ArgumentNullException("allowedCertificate");
15      }
16
17      this.allowedCertificate = allowedCertificate;
18    }
19    public override void Validate(X509Certificate2 certificate) {
20      // Check that there is a certificate.
21      if (certificate == null) {
22        throw new ArgumentNullException("certificate");
23      }
24
25      // Check that the certificate issuer matches the configured issuer
26      if (!allowedCertificate.Equals(certificate)) {
27        throw new SecurityTokenValidationException("Server certificate doesn't match.");
28      }
29    }
30  }
31}
Note: See TracBrowser for help on using the repository browser.