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 JAVAServiceSSLConversation() { ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; SecurityToken bootstrapSecurityToken = BootstrapSecurityTokenGenerator.MakeBootstrapSecurityToken(); Uri audience = new Uri("https://oiosaml.trifork.com:8082/poc-provider/GenevaProviderService"); RequestSecurityToken rst = WSTrustClientFactory.MakeOnBehalfOfSTSRequestSecurityToken(bootstrapSecurityToken, clientCertifikat, audience, requestClaims); var token = STSConnection.GetIssuedToken(rst); IEchoService echoService = WebserviceproviderChannelFactory.CreateChannelWithIssuedToken <IEchoService>(token, clientCertifikat, serviceCertifikat, new EndpointAddress(new Uri("https://oiosaml.trifork.com:8082/poc-provider/GenevaProviderService"))); var req = new echo(); req.structureToEcho = new Structure(); req.structureToEcho.value = "kvlsjvsldk"; req.Framework = new LibertyFrameworkHeader(); var reply = echoService.Echo(req); Assert.IsNotNull(reply.Framework); Assert.IsNotNull(reply.structureToEcho.value); }
public NLPActionResult Echo(echo echo) { var reply = string.Format("{0} said \"{1}\"", message.Username, "TODO"); message.Reply(reply); return(NLPActionResult.None); }
public echoResponse Echo(echo echoRequest) { ValidateLibertyFrameworkHeader(echoRequest.Framework); Structure businessResponse = ProcessBusinessLogic(echoRequest.structureToEcho); echoResponse echoReply = BuildResponseMessage(businessResponse); InsertWsAddressingMessageIdOnResponse(); return(echoReply); }
public static string ExecuteWS(string signingCertificateNameClient, string address, SecurityToken issuedToken) { X509Certificate2 certificate2Client = CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, signingCertificateNameClient); ChannelFactory <IEchoService> factory = null; try { 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, "CN=STS");// SigningCertificateNameGenevaService); factory.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign; var service = ChannelFactoryOperations.CreateChannelWithIssuedToken <IEchoService>(factory, issuedToken); Structure str = new Structure(); str.value = "Testing .NET client"; var echoRequest = new echo(); echoRequest.Framework = new LibertyFrameworkHeader(); echoRequest.structureToEcho = str; echoResponse result = null; result = service.Echo(echoRequest); return(result.structureToEcho.value); } catch (Exception e) { if (factory != null && factory.State == CommunicationState.Opened) { factory.Close(); } throw; } finally { if (factory.State == CommunicationState.Opened) { factory.Close(); } } }
public void MissingLibertyHeader() { SecurityToken bootstrapSecurityToken = BootstrapSecurityTokenGenerator.MakeBootstrapSecurityToken(); Uri audience = new Uri("http://localhost/Echo/service.svc/Echo"); RequestSecurityToken rst = WSTrustClientFactory.MakeOnBehalfOfSTSRequestSecurityToken(bootstrapSecurityToken, clientCertifikat, audience, requestClaims); var token = STSConnection.GetIssuedToken(rst); IEchoService echoService = WebserviceproviderChannelFactory.CreateChannelWithIssuedToken <IEchoService>(token, clientCertifikat, serviceCertifikat, new EndpointAddress(new Uri("http://lh-z3jyrnwtj9d7/EchoWebserviceProvider/service.svc/Echo"), new DnsEndpointIdentity(DnsIdentityForServiceCertificates))); var req = new echo(); req.structureToEcho = new Structure(); req.Framework = null; //Failure echoService.Echo(req); }
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); } }
public void DotNetServiceSSLConversation() { ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; SecurityToken bootstrapSecurityToken = BootstrapSecurityTokenGenerator.MakeBootstrapSecurityToken(); Uri audience = new Uri("http://localhost/Echo/service.svc/Echo"); RequestSecurityToken rst = WSTrustClientFactory.MakeOnBehalfOfSTSRequestSecurityToken(bootstrapSecurityToken, clientCertifikat, audience, requestClaims); var token = STSConnection.GetIssuedToken(rst); IEchoService echoService = WebserviceproviderChannelFactory.CreateChannelWithIssuedToken <IEchoService>(token, clientCertifikat, serviceCertifikat, new EndpointAddress(new Uri("https://lh-z3jyrnwtj9d7/EchoWebserviceProvider/service.svc/Echo"))); var req = new echo(); req.structureToEcho = new Structure(); req.Framework = new LibertyFrameworkHeader(); var reply = echoService.Echo(req); Assert.IsNotNull(reply.Framework); }