use of org.apache.cxf.bus.spring.SpringBusFactory in project camel by apache.
the class CxfEndpointUtils method createBus.
/**
* Create a CXF bus with either BusFactory or SpringBusFactory if Camel Context
* is SpringCamelContext. In the latter case, this method updates the bus
* configuration with the applicationContext which SpringCamelContext holds
*
* @param context - the Camel Context
*/
public static Bus createBus(CamelContext context) {
BusFactory busFactory = BusFactory.newInstance();
if (context instanceof SpringCamelContext) {
SpringCamelContext springCamelContext = (SpringCamelContext) context;
ApplicationContext applicationContext = springCamelContext.getApplicationContext();
busFactory = new SpringBusFactory(applicationContext);
}
return busFactory.createBus();
}
use of org.apache.cxf.bus.spring.SpringBusFactory in project camel by apache.
the class CamelDestinationTest method testCamelDestinationConfiguration.
@Test
public void testCamelDestinationConfiguration() throws Exception {
QName testEndpointQName = new QName("http://camel.apache.org/camel-test", "port");
// set up the bus with configure file
SpringBusFactory bf = new SpringBusFactory();
BusFactory.setDefaultBus(null);
Bus bus = bf.createBus("/org/apache/camel/component/cxf/transport/CamelDestination.xml");
BusFactory.setDefaultBus(bus);
endpointInfo.setAddress("camel://direct:EndpointA");
endpointInfo.setName(testEndpointQName);
CamelDestination destination = new CamelDestination(null, bus, null, endpointInfo);
assertEquals("{http://camel.apache.org/camel-test}port.camel-destination", destination.getBeanName());
CamelContext context = destination.getCamelContext();
assertNotNull("The camel context which get from camel destination is not null", context);
assertEquals("Get the wrong camel context", context.getName(), "dest_context");
assertEquals("The camel context should has two routers", context.getRoutes().size(), 2);
bus.shutdown(false);
}
use of org.apache.cxf.bus.spring.SpringBusFactory in project ddf by codice.
the class StsIssueTest method testBearerWebSsoTokenSaml2.
/**
* Test the Web SSO Token
*/
public void testBearerWebSsoTokenSaml2(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();
// Create a Username Token
UsernameToken oboToken = new UsernameToken(false, doc, WSConstants.PASSWORD_TEXT);
// Workout the details of how to fill out the username token
// ID - the Key that tells the validator its an SSO token
// Name - the SSO ticket
oboToken.setID(CAS_ID);
oboToken.setName("ST-098ASDF13245WERT");
// 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.writeAttribute(URI, "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/uid");
writer.writeEndElement();
Element claims = writer.getDocument().getDocumentElement();
// 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 ddf by codice.
the class StsIssueTest method testBearerUsernameTokenSaml2.
/**
* Test the Username Token
*/
public void testBearerUsernameTokenSaml2(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();
// Create a Username Token
UsernameToken oboToken = new UsernameToken(false, doc, WSConstants.PASSWORD_TEXT);
oboToken.setName("pangerer");
oboToken.setPassword("password");
// 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.writeAttribute(URI, "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/uid");
writer.writeEndElement();
Element claims = writer.getDocument().getDocumentElement();
// 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);
}
Aggregations