View Javadoc

1   /*
2    * Copyright [2007] [University Corporation for Advanced Internet Development, Inc.]
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.opensaml.ws.message;
18  
19  import org.opensaml.ws.security.SecurityPolicyResolver;
20  import org.opensaml.ws.transport.InTransport;
21  import org.opensaml.ws.transport.OutTransport;
22  import org.opensaml.xml.XMLObject;
23  import org.opensaml.xml.util.DatatypeHelper;
24  
25  /**
26   * Base class for message context implementations.
27   */
28  public class BaseMessageContext implements MessageContext {
29      
30      /** Unique id of the communication profile in use. */
31      private String communicationProfile;
32  
33      /** The inbound message. */
34      private XMLObject inboundMessage;
35  
36      /** Issuer of the inbound message. */
37      private String inboundMessageIssuer;
38  
39      /** Inbound message transport. */
40      private InTransport inboundTransport;
41  
42      /** Outbound message. */
43      private XMLObject outboundMessage;
44  
45      /** Issuer of the outbound message. */
46      private String outboundMessageIssuer;
47  
48      /** Outbound message transport. */
49      private OutTransport outboundTransport;
50      
51      /** Resolver used to determine active security policy. */
52      private SecurityPolicyResolver securityPolicyResolver;
53      
54      /** {@inheritDoc} */
55      public String getCommunicationProfileId() {
56          return communicationProfile;
57      }
58      
59      /** {@inheritDoc} */
60      public XMLObject getInboundMessage() {
61          return inboundMessage;
62      }
63      
64      /** {@inheritDoc} */
65      public String getInboundMessageIssuer() {
66          return inboundMessageIssuer;
67      }
68      
69      /** {@inheritDoc} */
70      public InTransport getInboundMessageTransport() {
71          return inboundTransport;
72      }
73      
74      /** {@inheritDoc} */
75      public XMLObject getOutboundMessage() {
76          return outboundMessage;
77      }
78      
79      /** {@inheritDoc} */
80      public String getOutboundMessageIssuer() {
81          return outboundMessageIssuer;
82      }
83  
84      /** {@inheritDoc} */
85      public OutTransport getOutboundMessageTransport() {
86          return outboundTransport;
87      }
88  
89      /** {@inheritDoc} */
90      public SecurityPolicyResolver getSecurityPolicyResolver() {
91          return securityPolicyResolver;
92      }
93  
94      /** {@inheritDoc} */
95      public void setCommunicationProfileId(String id) {
96          communicationProfile = DatatypeHelper.safeTrimOrNullString(id);
97      }
98  
99      /** {@inheritDoc} */
100     public void setInboundMessage(XMLObject message) {
101         inboundMessage = message;
102     }
103 
104     /** {@inheritDoc} */
105     public void setInboundMessageIssuer(String issuer) {
106         inboundMessageIssuer = issuer;
107     }
108 
109     /** {@inheritDoc} */
110     public void setInboundMessageTransport(InTransport transport) {
111         inboundTransport = transport;
112     }
113 
114     /** {@inheritDoc} */
115     public void setOutboundMessage(XMLObject message) {
116         outboundMessage = message;
117     }
118 
119     /** {@inheritDoc} */
120     public void setOutboundMessageIssuer(String issuer) {
121         outboundMessageIssuer = issuer;
122     }
123 
124     /** {@inheritDoc} */
125     public void setOutboundMessageTransport(OutTransport transport) {
126         outboundTransport = transport;
127     }
128 
129     /** {@inheritDoc} */
130     public void setSecurityPolicyResolver(SecurityPolicyResolver resolver) {
131         securityPolicyResolver = resolver;
132     }
133     
134     /** {@inheritDoc} */
135     public boolean isIssuerAuthenticated() {
136             return getInboundMessageTransport().isAuthenticated();
137     }
138 }