use of org.apache.cxf.bus.spring.SpringBusFactory in project camel by apache.
the class WSAddressingTest method testWSAddressing.
@Test
public void testWSAddressing() throws Exception {
JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(getClientAddress());
clientBean.setServiceClass(Greeter.class);
SpringBusFactory bf = new SpringBusFactory();
URL cxfConfig = null;
if (getCxfClientConfig() != null) {
cxfConfig = ClassLoaderUtils.getResource(getCxfClientConfig(), this.getClass());
}
proxyFactory.setBus(bf.createBus(cxfConfig));
Greeter client = (Greeter) proxyFactory.create();
String result = client.greetMe("world!");
assertEquals("Get a wrong response", "Hello world!", result);
}
use of org.apache.cxf.bus.spring.SpringBusFactory in project camel by apache.
the class Server method prepare.
public void prepare() throws Exception {
// Set a system property used to configure the server. The examples all run on port 9091;
// however, the unit tests must run on a dynamic port. As such, we make the port configurable
// in the Spring context.
System.setProperty("port", "9001");
// setup the Camel context for the Camel transport
// START SNIPPET: e1
SpringBusFactory bf = new SpringBusFactory();
BusFactory.setDefaultBus(null);
Bus bus = bf.createBus("/org/apache/camel/example/camel/transport/CamelDestination.xml");
BusFactory.setDefaultBus(bus);
// END SNIPPET: e1
}
use of org.apache.cxf.bus.spring.SpringBusFactory in project ddf by codice.
the class StsIssueTest method testBearerPkiTokenSaml2.
/**
* Test the User PKI Token
*/
public void testBearerPkiTokenSaml2(StsPortTypes portType) throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = StsIssueTest.class.getResource("/cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
SpringBusFactory.setDefaultBus(bus);
SpringBusFactory.setThreadDefaultBus(bus);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.newDocument();
// Build the Claims object
W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
writer.writeStartElement(WST, CLAIMS, STSUtils.WST_NS_05_12);
writer.writeNamespace(WST, STSUtils.WST_NS_05_12);
writer.writeNamespace(IC, IDENTITY_URI);
writer.writeAttribute(DIALECT, IDENTITY_URI);
// Add the Role claim
writer.writeStartElement(IC, CLAIM_TYPE, IDENTITY_URI);
writer.writeAttribute("URI", "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role");
writer.writeEndElement();
Element claims = writer.getDocument().getDocumentElement();
// Alerternatively we can use a certificate to request a SAML
X509Security oboToken = new X509Security(doc);
Crypto crypto = CryptoFactory.getInstance("clientKeystore.properties");
CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
cryptoType.setAlias("client");
X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
if (null != certs) {
oboToken.setX509Certificate(certs[0]);
// Get a token
SecurityToken token = requestSecurityToken(SAML2_TOKEN_TYPE, BEARER_KEYTYPE, oboToken.getElement(), bus, StsAddresses.valueOf(portType.toString()).toString(), WsdlLocations.valueOf(portType.toString()).toString(), EndPoints.valueOf(portType.toString()).toString(), claims);
if (token != null) {
validateSecurityToken(token);
}
}
bus.shutdown(true);
}
use of org.apache.cxf.bus.spring.SpringBusFactory in project camel by apache.
the class WSSecurityRouteTest method testUsernameToken.
@Test
public void testUsernameToken() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = WSSecurityRouteTest.class.getResource("../client/wssec.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
GreeterService gs = new GreeterService();
Greeter greeter = gs.getGreeterUsernameTokenPort();
((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + CXFTestSupport.getPort2() + "/WSSecurityRouteTest/GreeterUsernameTokenPort");
assertEquals("Get a wrong response", "Hello Security", greeter.greetMe("Security"));
}
use of org.apache.cxf.bus.spring.SpringBusFactory in project camel by apache.
the class WSSecurityRouteTest method testSecurityPolicy.
@Test
public void testSecurityPolicy() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = WSSecurityRouteTest.class.getResource("../client/wssec.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
GreeterService gs = new GreeterService();
Greeter greeter = gs.getGreeterSecurityPolicyPort();
((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + CXFTestSupport.getPort2() + "/WSSecurityRouteTest/GreeterSecurityPolicyPort");
assertEquals("Get a wrong response", "Hello Security", greeter.greetMe("Security"));
}
Aggregations