public void TestGenevaWebserviceProvider_WithSSL() { X509Certificate2 sslCertJavaWSP = CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, JavaWSPSSLCertificate); X509Certificate2 certificate2Client = CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, SigningCertificateNameClient); // Uri uri = new Uri("http://localhost:6020/Echo"); Uri uri = new Uri("https://csky-pc/test/Service1.svc"); EndpointAddress address = new EndpointAddress(uri); SecurityToken issuedToken = TestJavaSTSConnection.GetIssuedToken(); using (ChannelFactory <IEchoService> factory = new ChannelFactory <IEchoService>(new ServiceproviderBinding(true), address)) { factory.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign; factory.ConfigureChannelFactory(); factory.Credentials.ClientCertificate.Certificate = certificate2Client; factory.Credentials.ServiceCertificate.DefaultCertificate = CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, "CN=STS");// SigningCertificateNameGenevaService); factory.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign; var service = ChannelFactoryOperations.CreateChannelWithIssuedToken <IEchoService>(factory, issuedToken); Structure str = new Structure(); str.value = "Badabam"; var echoRequest = new echo(); echoRequest.Framework = new LibertyFrameworkHeader(); echoRequest.structureToEcho = str; var result = service.Echo(echoRequest); Assert.AreEqual("Badabam", result.structureToEcho.value); } }
public void WrongProfileForLibertyHeader() { X509Certificate2 certificate2Client = CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, SigningCertificateNameClient); Uri uri = new Uri("http://csky-pc/test/Service1.svc"); EndpointAddress address = new EndpointAddress(uri); SecurityToken issuedToken = TestJavaSTSConnection.GetIssuedToken(); using (ChannelFactory <IEchoService> factory = new ChannelFactory <IEchoService>(new ServiceproviderBinding(false), address)) { factory.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign; factory.ConfigureChannelFactory(); factory.Credentials.ClientCertificate.Certificate = certificate2Client; factory.Credentials.ServiceCertificate.DefaultCertificate = CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, SigningCertificateNameGenevaService); factory.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign; var service = ChannelFactoryOperations.CreateChannelWithIssuedToken <IEchoService>(factory, issuedToken); Structure str = new Structure(); str.value = "Badabam"; var echoRequest = new echo(); echoRequest.Framework = new LibertyFrameworkHeader(); echoRequest.Framework.Profile = "FailurToComply"; echoRequest.structureToEcho = str; var result = service.Echo(echoRequest); } }
public void TestJavaWebserviceProviderWithSSL() { X509Certificate2 sslCertJavaWSP = CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, JavaWSPSSLCertificate); X509Certificate2 certificate2Client = CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, SigningCertificateNameClient); Uri uri = new Uri("https://172.16.232.1:8181/poc-provider/ProviderService"); EndpointIdentity identity = EndpointIdentity.CreateX509CertificateIdentity(sslCertJavaWSP); EndpointAddress address = new EndpointAddress(uri, identity); SecurityToken issuedToken = TestJavaSTSConnection.GetIssuedToken(new Uri("https://172.16.232.1:8181/poc-provider/ProviderService")); ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };//Removes Validationcheck of SSL certificate, should not be here for Production. using (ChannelFactory <IEchoService> factory = new ChannelFactory <IEchoService>(new ServiceproviderBinding(true), address)) { factory.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign; factory.ConfigureChannelFactory(); factory.Credentials.ClientCertificate.Certificate = certificate2Client; factory.Credentials.ServiceCertificate.DefaultCertificate = CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, SigningCertificateNameJavaService); factory.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign; var service = ChannelFactoryOperations.CreateChannelWithIssuedToken <IEchoService>(factory, issuedToken); Structure str = new Structure(); str.value = "Badabam"; var echoRequest = new echo(); echoRequest.Framework = new LibertyFrameworkHeader(); echoRequest.structureToEcho = str; var result = service.Echo(echoRequest); Assert.AreEqual("Badabam", result.structureToEcho.value); } }