示例#1
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);
        }
示例#2
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);
        }
示例#3
0
 public static bool AuthenticateRequest(Claim claim, string password, Message message)
 {
     return(PeerRequestSecurityToken.CreateHashTokenFrom(message).Validate(claim, password));
 }