Пример #1
0
        public bool Authenticate(ServiceSecurityContext context, byte[] message)
        {
            Claim claim = null;

            if (context == null)
            {
                return(authenticationMode == PeerAuthenticationMode.None);
            }
            if (authenticationMode == PeerAuthenticationMode.Password)
            {
                if (!(context != null))
                {
                    throw Fx.AssertAndThrow("No SecurityContext attached in security mode!");
                }
                claim = FindClaim(context);
                return(PeerSecurityHelpers.Authenticate(claim, this.credManager.Password, message));
            }
            else
            {
                if (message != null)
                {
                    PeerExceptionHelper.ThrowInvalidOperation_UnexpectedSecurityTokensDuringHandshake();
                }
                return(true);
            }
        }
Пример #2
0
 public PeerHashToken(X509Certificate2 certificate, string password)
 {
     this.id             = SecurityUniqueId.Create().Value;
     this.effectiveTime  = DateTime.UtcNow;
     this.expirationTime = DateTime.UtcNow.AddHours(10.0);
     this.authenticator  = PeerSecurityHelpers.ComputeHash(certificate, password);
     this.CheckValidity();
 }
Пример #3
0
 public bool Validate(Claim claim, string password)
 {
     if (this.authenticator == null)
     {
         throw Fx.AssertAndThrow("Incorrect initialization");
     }
     return(PeerSecurityHelpers.Authenticate(claim, password, this.authenticator));
 }
Пример #4
0
 public byte[] GetAuthenticator()
 {
     if (authenticationMode != PeerAuthenticationMode.Password)
     {
         return(null);
     }
     if (authenticatorHash == null)
     {
         lock (ThisLock)
         {
             if (authenticatorHash == null)
             {
                 authenticatorHash = PeerSecurityHelpers.ComputeHash(credManager.Certificate, credManager.Password);
             }
         }
     }
     return(authenticatorHash);
 }
Пример #5
0
 public PeerHashToken(Claim claim, string password)
 {
     this.authenticator = PeerSecurityHelpers.ComputeHash(claim, password);
     CheckValidity();
 }
Пример #6
0
 public PeerHashToken(X509Certificate2 certificate, string password)
 {
     this.authenticator = PeerSecurityHelpers.ComputeHash(certificate, password);
     CheckValidity();
 }