예제 #1
0
 public SignatureProcessor(X509Certificate2 certificate, ProtocolSettings discoveryInfo)
 {
     this.Certificate = certificate;
     this.discoveryInfo = discoveryInfo;
     this.SHA1SignatureName = ProtocolStrings.SignatureAlgorithmSHA1Uri;
     this.references = new List<ReferenceEntry>();
 }
예제 #2
0
        ReceivedCompactSignatureHeader(
            Message message,
            int headerIndex,
            ProtocolSettings discoveryInfo)
            : base(message, discoveryInfo)
        {
            this.headerIndex = headerIndex;

            // Buffer the message, so we can read the headers and the body and verify the compact signature
            this.messageXml = new XmlDocument();
            this.messageXml.LoadXml(this.Message.ToString());
            this.envelopePrefix = this.messageXml.DocumentElement.Prefix;

            nsMgr = new XmlNamespaceManager(this.messageXml.NameTable);
            nsMgr.AddNamespace("s", this.messageXml.DocumentElement.NamespaceURI);

            // Move to s:Envelope
            nav = this.messageXml.CreateNavigator();
            nav.MoveToFirstChild();

            // Only immediate children of the security header,
            // top-level SOAP header blocks (/s:Envelope/s:Header/*),
            // and the full SOAP Body (/s:Envelope/s:Body) can be referenced in the compact signature.
            this.blockIds = new MessageCachedIndexes();
            this.CacheAllHeaderIds();
            this.CacheBodyId();
        }
예제 #3
0
 public SignatureProcessor(X509Certificate2 certificate, ProtocolSettings discoveryInfo)
 {
     this.Certificate       = certificate;
     this.discoveryInfo     = discoveryInfo;
     this.SHA1SignatureName = ProtocolStrings.SignatureAlgorithmSHA1Uri;
     this.references        = new List <ReferenceEntry>();
 }
        public CompactSignatureHeader(Message message, ProtocolSettings discoveryInfo)
        {
            Utility.IfNullThrowNullArgumentException(message, "message");
            Utility.IfNullThrowNullArgumentException(discoveryInfo, "discoveryInfo");

            this.Message = message;
            this.DiscoveryInfo = discoveryInfo;
        }
        public CompactSignatureHeader(Message message, ProtocolSettings discoveryInfo)
        {
            Utility.IfNullThrowNullArgumentException(message, "message");
            Utility.IfNullThrowNullArgumentException(discoveryInfo, "discoveryInfo");

            this.Message       = message;
            this.DiscoveryInfo = discoveryInfo;
        }
예제 #6
0
        public SignedMessage(
            Message innerMessage,
            X509Certificate2 certificate,
            ProtocolSettings discoveryInfo)
        {
            Utility.IfNullThrowNullArgumentException(innerMessage, "innerMessage");
            this.innerMessage = innerMessage;
            this.envelopeUri  = (innerMessage.Version.Envelope == EnvelopeVersion.Soap11) ?
                                ProtocolStrings.SoapNamespace11Uri : ProtocolStrings.SoapNamespace12Uri;
            this.envelopePrefix = ProtocolStrings.SoapPrefix;

            this.discoveryInfo       = discoveryInfo;
            this.securityIdGenerator = new SecurityIdGenerator();
            this.securityHeader      = new SendCompactSignatureHeader(this, certificate, discoveryInfo);
            this.state = BodyState.Created;
        }
예제 #7
0
        public SignedMessage(
            Message innerMessage,
            X509Certificate2 certificate,
            ProtocolSettings discoveryInfo)
        {
            Utility.IfNullThrowNullArgumentException(innerMessage, "innerMessage");
            this.innerMessage = innerMessage;
            this.envelopeUri = (innerMessage.Version.Envelope == EnvelopeVersion.Soap11) ?
                ProtocolStrings.SoapNamespace11Uri : ProtocolStrings.SoapNamespace12Uri;
            this.envelopePrefix = ProtocolStrings.SoapPrefix;

            this.discoveryInfo = discoveryInfo;
            this.securityIdGenerator = new SecurityIdGenerator();
            this.securityHeader = new SendCompactSignatureHeader(this, certificate, discoveryInfo);
            this.state = BodyState.Created;
        }
예제 #8
0
        public static void VerifyMessage(
            Message innerMessage,
            ProtocolSettings discoveryInfo,
            ReceivedCertificatesStoreSettings receivedCertificatesStoreSettings)
        {
            int headerIndex = innerMessage.Headers.FindHeader(ProtocolStrings.SecurityHeaderName, discoveryInfo.DiscoveryNamespace);

            if (headerIndex < 0)
            {
                // A security header is not present, so we can't verify the validity of the message.
                throw new CompactSignatureSecurityException("The received message doesn't contain a Security header");
            }

            ReceivedCompactSignatureHeader compactSignature = new ReceivedCompactSignatureHeader(innerMessage, headerIndex, discoveryInfo);

            compactSignature.Process(receivedCertificatesStoreSettings);
        }
 public SendCompactSignatureHeader(Message message, X509Certificate2 certificate, ProtocolSettings discoveryInfo)
     : base(message, discoveryInfo)
 {
     this.certificate = certificate;
 }
예제 #10
0
 public SendCompactSignatureHeader(Message message, X509Certificate2 certificate, ProtocolSettings discoveryInfo)
     : base(message, discoveryInfo)
 {
     this.certificate = certificate;
 }