use of org.apache.cxf.ws.security.trust.STSClient in project cxf by apache.
the class SecurityContextTokenCancelTest method requestSecurityToken.
private SecurityToken requestSecurityToken(Bus bus, String wsdlLocation, boolean enableEntropy) throws Exception {
STSClient stsClient = new STSClient(bus);
stsClient.setWsdlLocation(wsdlLocation);
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("ws-security.sts.token.properties", "serviceKeystore.properties");
stsClient.setProperties(properties);
stsClient.setSecureConv(true);
stsClient.setRequiresEntropy(enableEntropy);
stsClient.setKeySize(128);
stsClient.setAddressingNamespace("http://www.w3.org/2005/08/addressing");
return stsClient.requestSecurityToken(null);
}
use of org.apache.cxf.ws.security.trust.STSClient in project cxf by apache.
the class SecurityContextTokenCancelTest method cancelSecurityToken.
private boolean cancelSecurityToken(Bus bus, String wsdlLocation, String port, boolean enableEntropy, SecurityToken securityToken) throws Exception {
STSClient stsClient = new STSClient(bus);
stsClient.setWsdlLocation(wsdlLocation);
stsClient.setServiceName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService");
stsClient.setEndpointName(port);
Map<String, Object> properties = new HashMap<>();
properties.put(SecurityConstants.USERNAME, "alice");
properties.put(SecurityConstants.SIGNATURE_USERNAME, "myservicekey");
properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler");
properties.put(SecurityConstants.STS_TOKEN_PROPERTIES, "serviceKeystore.properties");
properties.put(SecurityConstants.SIGNATURE_PROPERTIES, "serviceKeystore.properties");
stsClient.setProperties(properties);
stsClient.setSecureConv(true);
stsClient.setRequiresEntropy(enableEntropy);
stsClient.setAddressingNamespace("http://www.w3.org/2005/08/addressing");
return stsClient.cancelSecurityToken(securityToken);
}
use of org.apache.cxf.ws.security.trust.STSClient in project cxf by apache.
the class TokenTestUtils method updateSTSPort.
public static void updateSTSPort(BindingProvider p, String port) {
STSClient stsClient = (STSClient) p.getRequestContext().get(SecurityConstants.STS_CLIENT);
if (stsClient == null) {
stsClient = (STSClient) p.getRequestContext().get("ws-" + SecurityConstants.STS_CLIENT);
}
if (stsClient != null) {
String location = stsClient.getWsdlLocation();
if (location != null && location.contains("8080")) {
stsClient.setWsdlLocation(location.replace("8080", port));
} else if (location != null && location.contains("8443")) {
stsClient.setWsdlLocation(location.replace("8443", port));
}
}
stsClient = (STSClient) p.getRequestContext().get(SecurityConstants.STS_CLIENT + ".sct");
if (stsClient == null) {
stsClient = (STSClient) p.getRequestContext().get("ws-" + SecurityConstants.STS_CLIENT + ".sct");
}
if (stsClient != null) {
String location = stsClient.getWsdlLocation();
if (location.contains("8080")) {
stsClient.setWsdlLocation(location.replace("8080", port));
} else if (location.contains("8443")) {
stsClient.setWsdlLocation(location.replace("8443", port));
}
}
}
use of org.apache.cxf.ws.security.trust.STSClient in project cxf by apache.
the class IssueUnitTest method requestSecurityToken.
// CHECKSTYLE:OFF
private SecurityToken requestSecurityToken(String tokenType, String keyType, Element supportingToken, Bus bus, String endpointAddress, String context, Map<String, Object> msgProperties, String realmUri, String wsdlPort) throws Exception {
STSClient stsClient = new STSClient(bus);
String port = STSPORT;
if (realmUri != null) {
stsClient.setWsdlLocation("https://localhost:" + port + "/SecurityTokenService/" + realmUri + "/Transport?wsdl");
} else {
stsClient.setWsdlLocation("https://localhost:" + port + "/SecurityTokenService/Transport?wsdl");
}
stsClient.setServiceName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService");
if (wsdlPort != null) {
stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}" + wsdlPort);
} else {
stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}Transport_Port");
}
Map<String, Object> properties = msgProperties;
if (properties == null) {
properties = new HashMap<>();
properties.put(SecurityConstants.USERNAME, "alice");
properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler");
}
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);
}
if (supportingToken != null) {
stsClient.setOnBehalfOf(supportingToken);
}
if (context != null) {
stsClient.setContext(context);
}
stsClient.setProperties(properties);
stsClient.setTokenType(tokenType);
stsClient.setKeyType(keyType);
return stsClient.requestSecurityToken(endpointAddress);
}
Aggregations