001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */package org.apache.cxf.ws.policy;
019:
020: import java.util.logging.Logger;
021:
022: import org.apache.cxf.common.logging.LogUtils;
023: import org.apache.cxf.endpoint.Endpoint;
024: import org.apache.cxf.message.Exchange;
025: import org.apache.cxf.message.Message;
026: import org.apache.cxf.message.MessageUtils;
027: import org.apache.cxf.phase.Phase;
028: import org.apache.cxf.service.model.BindingFaultInfo;
029: import org.apache.cxf.service.model.BindingOperationInfo;
030: import org.apache.cxf.service.model.EndpointInfo;
031:
032: /**
033: *
034: */
035: public class PolicyVerificationInFaultInterceptor extends
036: AbstractPolicyInterceptor {
037:
038: private static final Logger LOG = LogUtils
039: .getL7dLogger(PolicyVerificationInFaultInterceptor.class);
040:
041: public PolicyVerificationInFaultInterceptor() {
042: super (Phase.PRE_INVOKE);
043: }
044:
045: /**
046: * Determines the effective policy, and checks if one of its alternatives
047: * is supported.
048: *
049: * @param message
050: * @throws PolicyException if none of the alternatives is supported
051: */
052: protected void handle(Message message) {
053:
054: if (!MessageUtils.isRequestor(message)) {
055: LOG.fine("Not a requestor.");
056: return;
057: }
058:
059: Exchange exchange = message.getExchange();
060: assert null != exchange;
061:
062: BindingOperationInfo boi = exchange
063: .get(BindingOperationInfo.class);
064: if (null == boi) {
065: LOG.fine("No binding operation info.");
066: return;
067: }
068:
069: Endpoint e = exchange.get(Endpoint.class);
070: if (null == e) {
071: LOG.fine("No endpoint.");
072: return;
073: }
074: EndpointInfo ei = e.getEndpointInfo();
075:
076: PolicyEngine pe = bus.getExtension(PolicyEngine.class);
077: if (null == pe) {
078: return;
079: }
080:
081: AssertionInfoMap aim = message.get(AssertionInfoMap.class);
082: if (null == aim) {
083: return;
084: }
085:
086: Exception ex = message.getContent(Exception.class);
087: if (null == ex) {
088: ex = exchange.get(Exception.class);
089: }
090: assert null != ex;
091:
092: BindingFaultInfo bfi = getBindingFaultInfo(message, ex, boi);
093: if (null == bfi) {
094: LOG.fine("No binding fault info.");
095: return;
096: }
097:
098: getTransportAssertions(message);
099:
100: EffectivePolicy effectivePolicy = pe
101: .getEffectiveClientFaultPolicy(ei, bfi);
102: aim.checkEffectivePolicy(effectivePolicy.getPolicy());
103: LOG.fine("Verified policies for inbound message.");
104: }
105:
106: }
|