use of com.sun.xml.ws.policy.subject.WsdlBindingSubject in project metro-jax-ws by eclipse-ee4j.
the class PolicyWSDLGeneratorExtension method addBindingOperationFaultExtension.
@Override
public void addBindingOperationFaultExtension(final TypedXmlWriter writer, final JavaMethod method, final CheckedException exception) {
LOGGER.entering(writer, method, exception);
if (subjects != null) {
for (PolicySubject subject : subjects) {
// iterate over all subjects in policy map
if (this.policyMap.isFaultMessageSubject(subject)) {
final Object concreteSubject = subject.getSubject();
if (concreteSubject != null) {
final String exceptionName = exception == null ? null : exception.getMessageName();
if (exceptionName == null) {
// no name provided to check
writePolicyOrReferenceIt(subject, writer);
}
if (WSDLBoundFaultContainer.class.isInstance(concreteSubject)) {
// is it our class?
WSDLBoundFaultContainer faultContainer = (WSDLBoundFaultContainer) concreteSubject;
WSDLBoundFault fault = faultContainer.getBoundFault();
WSDLBoundOperation operation = faultContainer.getBoundOperation();
if (exceptionName.equals(fault.getName()) && operation.getName().getLocalPart().equals(method.getOperationName())) {
writePolicyOrReferenceIt(subject, writer);
}
} else if (WsdlBindingSubject.class.isInstance(concreteSubject)) {
WsdlBindingSubject wsdlSubject = (WsdlBindingSubject) concreteSubject;
if ((wsdlSubject.getMessageType() == WsdlBindingSubject.WsdlMessageType.FAULT) && exception.getOwner().getTargetNamespace().equals(wsdlSubject.getName().getNamespaceURI()) && exceptionName.equals(wsdlSubject.getName().getLocalPart())) {
writePolicyOrReferenceIt(subject, writer);
}
}
}
}
}
}
LOGGER.exiting();
}
use of com.sun.xml.ws.policy.subject.WsdlBindingSubject in project metro-jax-ws by eclipse-ee4j.
the class PolicyMapUtil method insertPolicies.
/**
* Inserts all PolicySubjects of type WsdlBindingSubject into the given policy map.
*
* @param policyMap The policy map
* @param policySubjects The policy subjects. The actual subject must have the
* type WsdlBindingSubject, otherwise it will not be processed.
* @param serviceName The name of the current WSDL service
* @param portName The name of the current WSDL port
* @throws PolicyException Thrown if the effective policy of a policy subject
* could not be computed
*/
public static void insertPolicies(final PolicyMap policyMap, final Collection<PolicySubject> policySubjects, QName serviceName, QName portName) throws PolicyException {
LOGGER.entering(policyMap, policySubjects, serviceName, portName);
final HashMap<WsdlBindingSubject, Collection<Policy>> subjectToPolicies = new HashMap<>();
for (PolicySubject subject : policySubjects) {
final Object actualSubject = subject.getSubject();
if (actualSubject instanceof WsdlBindingSubject) {
final WsdlBindingSubject wsdlSubject = (WsdlBindingSubject) actualSubject;
final Collection<Policy> subjectPolicies = new LinkedList<>();
subjectPolicies.add(subject.getEffectivePolicy(MERGER));
final Collection<Policy> existingPolicies = subjectToPolicies.put(wsdlSubject, subjectPolicies);
if (existingPolicies != null) {
subjectPolicies.addAll(existingPolicies);
}
}
}
final PolicyMapKeyConverter converter = new PolicyMapKeyConverter(serviceName, portName);
for (Entry<WsdlBindingSubject, Collection<Policy>> entry : subjectToPolicies.entrySet()) {
WsdlBindingSubject wsdlSubject = entry.getKey();
Collection<Policy> policySet = entry.getValue();
final PolicySubject newSubject = new PolicySubject(wsdlSubject, policySet);
PolicyMapKey mapKey = converter.getPolicyMapKey(wsdlSubject);
if (wsdlSubject.isBindingSubject()) {
policyMap.putSubject(ScopeType.ENDPOINT, mapKey, newSubject);
} else if (wsdlSubject.isBindingOperationSubject()) {
policyMap.putSubject(ScopeType.OPERATION, mapKey, newSubject);
} else if (wsdlSubject.isBindingMessageSubject()) {
switch(wsdlSubject.getMessageType()) {
case INPUT:
policyMap.putSubject(ScopeType.INPUT_MESSAGE, mapKey, newSubject);
break;
case OUTPUT:
policyMap.putSubject(ScopeType.OUTPUT_MESSAGE, mapKey, newSubject);
break;
case FAULT:
policyMap.putSubject(ScopeType.FAULT_MESSAGE, mapKey, newSubject);
break;
default:
break;
}
}
}
LOGGER.exiting();
}
use of com.sun.xml.ws.policy.subject.WsdlBindingSubject in project metro-jax-ws by eclipse-ee4j.
the class PolicyWSDLGeneratorExtension method selectAndProcessBindingSubject.
private void selectAndProcessBindingSubject(final TypedXmlWriter xmlWriter, final Class clazz, final ScopeType scopeType, final QName bindingName) {
LOGGER.entering(xmlWriter, clazz, scopeType, bindingName);
if ((subjects != null) && (bindingName != null)) {
for (PolicySubject subject : subjects) {
if (subject.getSubject() instanceof WsdlBindingSubject) {
final WsdlBindingSubject wsdlSubject = (WsdlBindingSubject) subject.getSubject();
if (bindingName.equals(wsdlSubject.getName())) {
writePolicyOrReferenceIt(subject, xmlWriter);
}
}
}
}
selectAndProcessSubject(xmlWriter, clazz, scopeType, bindingName);
LOGGER.exiting();
}
use of com.sun.xml.ws.policy.subject.WsdlBindingSubject in project metro-jax-ws by eclipse-ee4j.
the class AddressingPolicyMapConfigurator method addWsamAddressing.
private void addWsamAddressing(Collection<PolicySubject> subjects, PolicyMap policyMap, SEIModel model, AddressingFeature addressingFeature) throws PolicyException {
final QName bindingName = model.getBoundPortTypeName();
final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName);
final Policy addressingPolicy = createWsamAddressingPolicy(bindingName, addressingFeature);
final PolicySubject addressingPolicySubject = new PolicySubject(wsdlSubject, addressingPolicy);
subjects.add(addressingPolicySubject);
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Added addressing policy with ID \"" + addressingPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
}
}
use of com.sun.xml.ws.policy.subject.WsdlBindingSubject in project metro-jax-ws by eclipse-ee4j.
the class MtomPolicyMapConfigurator method update.
/**
* Generates an MTOM policy if MTOM is enabled.
*
* <ol>
* <li>If MTOM is enabled
* <ol>
* <li>If MTOM policy does not already exist, generate
* <li>Otherwise do nothing
* </ol>
* <li>Otherwise, do nothing (that implies that we do not remove any MTOM policies if MTOM is disabled)
* </ol>
*/
public Collection<PolicySubject> update(PolicyMap policyMap, SEIModel model, WSBinding wsBinding) throws PolicyException {
LOGGER.entering(policyMap, model, wsBinding);
Collection<PolicySubject> subjects = new ArrayList<>();
if (policyMap != null) {
final MTOMFeature mtomFeature = wsBinding.getFeature(MTOMFeature.class);
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("mtomFeature = " + mtomFeature);
}
if ((mtomFeature != null) && mtomFeature.isEnabled()) {
final QName bindingName = model.getBoundPortTypeName();
final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName);
final Policy mtomPolicy = createMtomPolicy(bindingName);
final PolicySubject mtomPolicySubject = new PolicySubject(wsdlSubject, mtomPolicy);
subjects.add(mtomPolicySubject);
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.fine("Added MTOM policy with ID \"" + mtomPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
}
}
}
// endif policy map not null
LOGGER.exiting(subjects);
return subjects;
}
Aggregations