예제 #1
0
        public void Run()
        {
            //WebServiceProxy.Service1 proxy = new WebServiceProxy.Service1();
            WebServiceProxy.Service1Wse proxy = new WebServiceProxy.Service1Wse();

            ISecurityTokenManager    stm    = SecurityTokenManager.GetSecurityTokenManagerByTokenType(WSTrust.TokenTypes.X509v3);
            X509SecurityTokenManager x509tm = stm as X509SecurityTokenManager;

            x509tm.DefaultSessionKeyAlgorithm = "TripleDES";

            //------Encryption
//			X509SecurityToken  token = getToken("server");
//			if (token == null)	throw new ApplicationException("Unable to obtain security token.");
//			EncryptedData ed = new EncryptedData(token);
//			proxy.RequestSoapContext.Security.Tokens.Add(token);
//			proxy.RequestSoapContext.Security.Elements.Add(ed);

            X509SecurityToken token = getToken("client");

            if (token == null)
            {
                throw new ApplicationException("Unable to obtain security token.");
            }
            proxy.RequestSoapContext.Security.Tokens.Add(token);
            proxy.RequestSoapContext.Security.Elements.Add(new MessageSignature(token));

            //------Username
//			string username      = Environment.UserName;
//			Console.Write("Passwort for '" + username + "': ");
//			string password = Console.ReadLine();
//			byte[] passwordBytes = System.Text.Encoding.UTF8.GetBytes(password);
//			//Array.Reverse(passwordBytes);
//
//			//string passwordEquivalent = Convert.ToBase64String( passwordBytes );
//			UsernameToken token = new UsernameToken( username, password, PasswordOption.SendHashed );
//			proxy.RequestSoapContext.Security.Tokens.Add(token);
//
//			//------Signature
//			proxy.RequestSoapContext.Security.Elements.Add( new MessageSignature( token ) );

            Console.WriteLine("Ausgabe: " + proxy.SayHello("test"));
        }
예제 #2
0
        public void Run()
        {
            //WebServiceProxy.Service1 proxy = new WebServiceProxy.Service1();
            WebServiceProxy.Service1Wse proxy = new WebServiceProxy.Service1Wse();

            ISecurityTokenManager stm = SecurityTokenManager.GetSecurityTokenManagerByTokenType(WSTrust.TokenTypes.X509v3);
            X509SecurityTokenManager x509tm = stm as X509SecurityTokenManager;
            x509tm.DefaultSessionKeyAlgorithm = "TripleDES";

            //------Encryption
            //			X509SecurityToken  token = getToken("server");
            //			if (token == null)	throw new ApplicationException("Unable to obtain security token.");
            //			EncryptedData ed = new EncryptedData(token);
            //			proxy.RequestSoapContext.Security.Tokens.Add(token);
            //			proxy.RequestSoapContext.Security.Elements.Add(ed);

            X509SecurityToken  token = getToken("client");
            if (token == null)	throw new ApplicationException("Unable to obtain security token.");
            proxy.RequestSoapContext.Security.Tokens.Add(token);
            proxy.RequestSoapContext.Security.Elements.Add(new MessageSignature(token));

            //------Username
            //			string username      = Environment.UserName;
            //			Console.Write("Passwort for '" + username + "': ");
            //			string password = Console.ReadLine();
            //			byte[] passwordBytes = System.Text.Encoding.UTF8.GetBytes(password);
            //			//Array.Reverse(passwordBytes);
            //
            //			//string passwordEquivalent = Convert.ToBase64String( passwordBytes );
            //			UsernameToken token = new UsernameToken( username, password, PasswordOption.SendHashed );
            //			proxy.RequestSoapContext.Security.Tokens.Add(token);
            //
            //			//------Signature
            //			proxy.RequestSoapContext.Security.Elements.Add( new MessageSignature( token ) );

            Console.WriteLine("Ausgabe: " + proxy.SayHello("test"));
        }