01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.ws.policy;
19:
20: import java.util.logging.Logger;
21:
22: import org.apache.cxf.common.logging.LogUtils;
23: import org.apache.cxf.message.Message;
24: import org.apache.cxf.message.MessageUtils;
25: import org.apache.cxf.phase.Phase;
26:
27: /**
28: *
29: */
30: public class PolicyVerificationOutInterceptor extends
31: AbstractPolicyInterceptor {
32:
33: private static final Logger LOG = LogUtils
34: .getL7dLogger(PolicyVerificationOutInterceptor.class);
35:
36: public PolicyVerificationOutInterceptor() {
37: super (Phase.POST_STREAM);
38: }
39:
40: /**
41: * Checks if all assertions in the chosen alternative have been asserted.
42: * Note that although the alternative was chosen in such a way that at least all
43: * interceptors necessary to assert the assertions are present, it is not possible
44: * to predict if these interceptors actually have asserted their assertions.
45: * @param message
46: * @throws PolicyException if none of the alternatives is supported
47: */
48: protected void handle(Message message) {
49:
50: if (MessageUtils.isPartialResponse(message)) {
51: LOG
52: .fine("Not verifying policies on outbound partial response.");
53: return;
54: }
55:
56: AssertionInfoMap aim = message.get(AssertionInfoMap.class);
57: if (null == aim) {
58: return;
59: }
60:
61: getTransportAssertions(message);
62:
63: EffectivePolicy policy = message.get(EffectivePolicy.class);
64: if (policy == null) {
65: return;
66: }
67:
68: aim.checkEffectivePolicy(policy.getPolicy());
69:
70: LOG.fine("Verified policies for outbound message.");
71: }
72:
73: }
|