use of org.apache.cxf.ws.security.sts.provider.model.secext.KeyIdentifierType in project cxf by apache.
the class AbstractOperation method createRequestedReference.
/**
* Create a RequestedReferenceType object using a TokenReference object
*/
protected static RequestedReferenceType createRequestedReference(TokenReference tokenReference, boolean attached) {
RequestedReferenceType requestedReferenceType = QNameConstants.WS_TRUST_FACTORY.createRequestedReferenceType();
SecurityTokenReferenceType securityTokenReferenceType = QNameConstants.WSSE_FACTORY.createSecurityTokenReferenceType();
// TokenType
String tokenType = tokenReference.getWsse11TokenType();
if (tokenType != null) {
securityTokenReferenceType.getOtherAttributes().put(TOKEN_TYPE, tokenType);
}
if (tokenReference.isUseKeyIdentifier()) {
String identifier = XMLUtils.getIDFromReference(tokenReference.getIdentifier());
KeyIdentifierType keyIdentifierType = QNameConstants.WSSE_FACTORY.createKeyIdentifierType();
keyIdentifierType.setValue(identifier);
String valueType = tokenReference.getWsseValueType();
if (valueType != null) {
keyIdentifierType.setValueType(valueType);
}
JAXBElement<KeyIdentifierType> keyIdentifier = QNameConstants.WSSE_FACTORY.createKeyIdentifier(keyIdentifierType);
securityTokenReferenceType.getAny().add(keyIdentifier);
} else if (tokenReference.isUseDirectReference()) {
String identifier = tokenReference.getIdentifier();
if (attached && identifier.charAt(0) != '#') {
identifier = "#" + identifier;
} else if (!attached && identifier.charAt(0) == '#') {
identifier = identifier.substring(1);
}
ReferenceType referenceType = QNameConstants.WSSE_FACTORY.createReferenceType();
referenceType.setURI(identifier);
String valueType = tokenReference.getWsseValueType();
if (valueType != null) {
referenceType.setValueType(valueType);
}
JAXBElement<ReferenceType> reference = QNameConstants.WSSE_FACTORY.createReference(referenceType);
securityTokenReferenceType.getAny().add(reference);
}
requestedReferenceType.setSecurityTokenReference(securityTokenReferenceType);
return requestedReferenceType;
}
Aggregations