Click here to Skip to main content
15,885,366 members
Articles / Web Development / ASP.NET

Central Key Management

Rate me:
Please Sign up or sign in to vote.
4.63/5 (18 votes)
8 Mar 200610 min read 63.8K   1.2K   49  
A central key manager for multiple web server clients in a web farm.
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.42
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

// 
// This source code was auto-generated by Microsoft.VSDesigner, Version 2.0.50727.42.
// 
#pragma warning disable 1591

namespace TestClient.KeyManager {
    using System.Diagnostics;
    using System.Web.Services;
    using System.ComponentModel;
    using System.Web.Services.Protocols;
    using System;
    using System.Xml.Serialization;
    
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.42")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="ServiceSoap", Namespace="http://www.oswsolutions.com/")]
    public partial class Service : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        private System.Threading.SendOrPostCallback GetSessionKeyOperationCompleted;
        
        private System.Threading.SendOrPostCallback CreateSessionKeyOperationCompleted;
        
        private bool useDefaultCredentialsSetExplicitly;
        
        /// <remarks/>
        public Service() {
            this.Url = global::TestClient.Properties.Settings.Default.TestClient_KeyManager_Service;
            if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
                this.UseDefaultCredentials = true;
                this.useDefaultCredentialsSetExplicitly = false;
            }
            else {
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        
        public new string Url {
            get {
                return base.Url;
            }
            set {
                if ((((this.IsLocalFileSystemWebService(base.Url) == true) 
                            && (this.useDefaultCredentialsSetExplicitly == false)) 
                            && (this.IsLocalFileSystemWebService(value) == false))) {
                    base.UseDefaultCredentials = false;
                }
                base.Url = value;
            }
        }
        
        public new bool UseDefaultCredentials {
            get {
                return base.UseDefaultCredentials;
            }
            set {
                base.UseDefaultCredentials = value;
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        
        /// <remarks/>
        public event GetSessionKeyCompletedEventHandler GetSessionKeyCompleted;
        
        /// <remarks/>
        public event CreateSessionKeyCompletedEventHandler CreateSessionKeyCompleted;
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.oswsolutions.com/GetSessionKey", RequestNamespace="http://www.oswsolutions.com/", ResponseNamespace="http://www.oswsolutions.com/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public SessionKeyInfo GetSessionKey(int keyId, [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")] byte[] rawCertificateData) {
            object[] results = this.Invoke("GetSessionKey", new object[] {
                        keyId,
                        rawCertificateData});
            return ((SessionKeyInfo)(results[0]));
        }
        
        /// <remarks/>
        public void GetSessionKeyAsync(int keyId, byte[] rawCertificateData) {
            this.GetSessionKeyAsync(keyId, rawCertificateData, null);
        }
        
        /// <remarks/>
        public void GetSessionKeyAsync(int keyId, byte[] rawCertificateData, object userState) {
            if ((this.GetSessionKeyOperationCompleted == null)) {
                this.GetSessionKeyOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetSessionKeyOperationCompleted);
            }
            this.InvokeAsync("GetSessionKey", new object[] {
                        keyId,
                        rawCertificateData}, this.GetSessionKeyOperationCompleted, userState);
        }
        
        private void OnGetSessionKeyOperationCompleted(object arg) {
            if ((this.GetSessionKeyCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.GetSessionKeyCompleted(this, new GetSessionKeyCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.oswsolutions.com/CreateSessionKey", RequestNamespace="http://www.oswsolutions.com/", ResponseNamespace="http://www.oswsolutions.com/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public SessionKeyInfo CreateSessionKey([System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")] byte[] rawCertificateData) {
            object[] results = this.Invoke("CreateSessionKey", new object[] {
                        rawCertificateData});
            return ((SessionKeyInfo)(results[0]));
        }
        
        /// <remarks/>
        public void CreateSessionKeyAsync(byte[] rawCertificateData) {
            this.CreateSessionKeyAsync(rawCertificateData, null);
        }
        
        /// <remarks/>
        public void CreateSessionKeyAsync(byte[] rawCertificateData, object userState) {
            if ((this.CreateSessionKeyOperationCompleted == null)) {
                this.CreateSessionKeyOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateSessionKeyOperationCompleted);
            }
            this.InvokeAsync("CreateSessionKey", new object[] {
                        rawCertificateData}, this.CreateSessionKeyOperationCompleted, userState);
        }
        
        private void OnCreateSessionKeyOperationCompleted(object arg) {
            if ((this.CreateSessionKeyCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.CreateSessionKeyCompleted(this, new CreateSessionKeyCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        
        /// <remarks/>
        public new void CancelAsync(object userState) {
            base.CancelAsync(userState);
        }
        
        private bool IsLocalFileSystemWebService(string url) {
            if (((url == null) 
                        || (url == string.Empty))) {
                return false;
            }
            System.Uri wsUri = new System.Uri(url);
            if (((wsUri.Port >= 1024) 
                        && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
                return true;
            }
            return false;
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.42")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.oswsolutions.com/")]
    public partial class SessionKeyInfo {
        
        private System.Xml.XmlElement wrappedKeyField;
        
        private int keyIdField;
        
        /// <remarks/>
        public System.Xml.XmlElement WrappedKey {
            get {
                return this.wrappedKeyField;
            }
            set {
                this.wrappedKeyField = value;
            }
        }
        
        /// <remarks/>
        public int KeyId {
            get {
                return this.keyIdField;
            }
            set {
                this.keyIdField = value;
            }
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.42")]
    public delegate void GetSessionKeyCompletedEventHandler(object sender, GetSessionKeyCompletedEventArgs e);
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.42")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public partial class GetSessionKeyCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal GetSessionKeyCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public SessionKeyInfo Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((SessionKeyInfo)(this.results[0]));
            }
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.42")]
    public delegate void CreateSessionKeyCompletedEventHandler(object sender, CreateSessionKeyCompletedEventArgs e);
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.42")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public partial class CreateSessionKeyCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal CreateSessionKeyCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public SessionKeyInfo Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((SessionKeyInfo)(this.results[0]));
            }
        }
    }
}

#pragma warning restore 1591

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions