use of org.apache.cxf.ws.security.trust.STSClient in project cxf by apache.
the class IntermediaryPortTypeImpl method doubleIt.
public int doubleIt(int numberToDouble) {
Principal pr = wsc.getUserPrincipal();
Assert.assertNotNull("Principal must not be null", pr);
Assert.assertNotNull("Principal.getName() must not return null", pr.getName());
URL wsdl = IntermediaryPortTypeImpl.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2Port");
DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
try {
updateAddressPort(transportPort, IntermediaryTransformationTest.PORT2);
} catch (Exception ex) {
ex.printStackTrace();
}
if ("standalone".equals(System.getProperty("sts.deployment"))) {
Map<String, Object> context = ((BindingProvider) transportPort).getRequestContext();
STSClient stsClient = (STSClient) context.get(SecurityConstants.STS_CLIENT);
if (stsClient == null) {
stsClient = (STSClient) context.get("ws-" + SecurityConstants.STS_CLIENT);
}
if (stsClient != null) {
String location = stsClient.getWsdlLocation();
if (location.contains("8080")) {
stsClient.setWsdlLocation(location.replace("8080", IntermediaryTransformationTest.STSPORT2));
} else if (location.contains("8443")) {
stsClient.setWsdlLocation(location.replace("8443", IntermediaryTransformationTest.STSPORT));
}
}
}
return transportPort.doubleIt(numberToDouble);
}
use of org.apache.cxf.ws.security.trust.STSClient in project cxf by apache.
the class IssueUnitTest method requestSecurityTokenTTL.
private SecurityToken requestSecurityTokenTTL(String tokenType, String keyType, Bus bus, String endpointAddress) throws Exception {
STSClient stsClient = new STSClient(bus);
String port = STSPORT;
stsClient.setWsdlLocation("https://localhost:" + port + "/SecurityTokenService/Transport?wsdl");
stsClient.setServiceName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService");
stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}Transport_Port");
Map<String, Object> properties = new HashMap<>();
properties.put(SecurityConstants.USERNAME, "alice");
properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler");
properties.put(SecurityConstants.ENCRYPT_PROPERTIES, "clientKeystore.properties");
properties.put(SecurityConstants.ENCRYPT_USERNAME, "mystskey");
properties.put(SecurityConstants.IS_BSP_COMPLIANT, "false");
if (PUBLIC_KEY_KEYTYPE.equals(keyType)) {
properties.put(SecurityConstants.STS_TOKEN_USERNAME, "myclientkey");
properties.put(SecurityConstants.STS_TOKEN_PROPERTIES, "clientKeystore.properties");
stsClient.setUseCertificateForConfirmationKeyInfo(true);
}
stsClient.setEnableLifetime(true);
stsClient.setTtl(60 * 30);
stsClient.setProperties(properties);
stsClient.setTokenType(tokenType);
stsClient.setKeyType(keyType);
stsClient.setAddressingNamespace("http://www.w3.org/2005/08/addressing");
return stsClient.requestSecurityToken(endpointAddress);
}
use of org.apache.cxf.ws.security.trust.STSClient in project cxf by apache.
the class STSTokenOutInterceptorTest method initStsClientTransportBinding.
private STSClient initStsClientTransportBinding(Bus bus) {
bus.getInInterceptors().add(new LoggingOutInterceptor());
bus.getOutInterceptors().add(new LoggingInInterceptor());
bus.getOutFaultInterceptors().add(new LoggingInInterceptor());
STSClient stsClient = new STSClient(bus);
stsClient.setWsdlLocation("https://localhost:" + STSPORT + STS_TRANSPORT_WSDL_LOCATION_RELATIVE);
stsClient.setServiceName(STS_SERVICE_NAME);
stsClient.setEndpointName(STS_TRANSPORT_ENDPOINT_NAME);
stsClient.setTokenType(TOKEN_TYPE_SAML_2_0);
stsClient.setAllowRenewingAfterExpiry(true);
stsClient.setEnableLifetime(true);
Map<String, Object> props = new HashMap<>();
props.put(SecurityConstants.USERNAME, "alice");
props.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler");
stsClient.setProperties(props);
return stsClient;
}
use of org.apache.cxf.ws.security.trust.STSClient in project cxf by apache.
the class STSTokenOutInterceptorTest method testSTSClientAsymmetricBinding.
@Test
public void testSTSClientAsymmetricBinding() throws Exception {
Bus bus = BusFactory.getThreadDefaultBus();
STSClient stsClient = initStsClientAsymmeticBinding(bus);
STSTokenOutInterceptor interceptor = new STSTokenOutInterceptor(stsClient);
MessageImpl message = prepareMessage(bus, null, SERVICE_ENDPOINT_ASSYMETRIC);
interceptor.handleMessage(message);
SecurityToken token = (SecurityToken) message.getExchange().get(SecurityConstants.TOKEN);
validateSecurityToken(token);
}
use of org.apache.cxf.ws.security.trust.STSClient in project cxf by apache.
the class STSTokenRetrieverTest method initStsClientTransportBinding.
private STSClient initStsClientTransportBinding(Bus bus) {
bus.getInInterceptors().add(new LoggingOutInterceptor());
bus.getOutInterceptors().add(new LoggingInInterceptor());
bus.getOutFaultInterceptors().add(new LoggingInInterceptor());
STSClient stsClient = new STSClient(bus);
stsClient.setWsdlLocation("https://localhost:" + STSPORT + STS_TRANSPORT_WSDL_LOCATION_RELATIVE);
stsClient.setServiceName(STS_SERVICE_NAME);
stsClient.setEndpointName(STS_TRANSPORT_ENDPOINT_NAME);
stsClient.setTokenType(TOKEN_TYPE_SAML_2_0);
stsClient.setAllowRenewingAfterExpiry(true);
stsClient.setEnableLifetime(true);
Map<String, Object> props = new HashMap<>();
props.put(SecurityConstants.USERNAME, "alice");
props.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler");
stsClient.setProperties(props);
return stsClient;
}
Aggregations