コード例 #1
0
        public void ProcessRstr(IPeerNeighbor neighbor, Message message, Claim claim)
        {
            PeerHashToken token = PeerRequestSecurityTokenResponse.CreateHashTokenFrom(message);

            if (!token.IsValid)
            {
                this.OnFailed(neighbor);
            }
            else if (!this.securityManager.GetExpectedTokenForClaim(claim).Equals(token))
            {
                this.OnFailed(neighbor);
            }
            else
            {
                this.OnAuthenticated();
            }
        }
コード例 #2
0
        public Message ProcessRst(Message message, Claim claim)
        {
            IPeerNeighbor neighbor = host;
            PeerRequestSecurityTokenResponse response = null;
            Message reply = null;

            lock (ThisLock)
            {
                if (this.state != PeerAuthState.Created || neighbor == null || neighbor.IsInitiator || neighbor.State != PeerNeighborState.Opened)
                {
                    OnFailed(neighbor);
                    return(null);
                }
            }

            try
            {
                PeerHashToken receivedToken = PeerRequestSecurityToken.CreateHashTokenFrom(message);
                PeerHashToken expectedToken = securityManager.GetExpectedTokenForClaim(claim);

                if (!expectedToken.Equals(receivedToken))
                {
                    OnFailed(neighbor);
                }
                else
                {
                    this.state = PeerAuthState.Authenticated;
                    PeerHashToken selfToken = securityManager.GetSelfToken();
                    response = new PeerRequestSecurityTokenResponse(selfToken);
                    reply    = Message.CreateMessage(MessageVersion.Soap12WSAddressing10, TrustFeb2005Strings.RequestSecurityTokenResponse, response);
                    OnAuthenticated();
                }
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                OnFailed(neighbor);
            }
            return(reply);
        }
コード例 #3
0
        public Message ProcessRst(Message message, Claim claim)
        {
            IPeerNeighbor host = this.host;
            PeerRequestSecurityTokenResponse response = null;
            Message message2 = null;

            lock (this.ThisLock)
            {
                if (((this.state != PeerAuthState.Created) || (host == null)) || (host.IsInitiator || (host.State != PeerNeighborState.Opened)))
                {
                    this.OnFailed(host);
                    return(null);
                }
            }
            try
            {
                PeerHashToken token = PeerRequestSecurityToken.CreateHashTokenFrom(message);
                if (!this.securityManager.GetExpectedTokenForClaim(claim).Equals(token))
                {
                    this.OnFailed(host);
                    return(message2);
                }
                this.state = PeerAuthState.Authenticated;
                response   = new PeerRequestSecurityTokenResponse(this.securityManager.GetSelfToken());
                message2   = Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "RequestSecurityTokenResponse", (BodyWriter)response);
                this.OnAuthenticated();
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
                this.OnFailed(host);
            }
            return(message2);
        }
コード例 #4
0
 public static bool AuthenticateResponse(Claim claim, string password, Message message)
 {
     return(PeerRequestSecurityTokenResponse.CreateHashTokenFrom(message).Validate(claim, password));
 }