View Javadoc

1   /*
2    * Copyright 2009 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.transport;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  import org.opensaml.xml.security.credential.Credential;
23  
24  /**
25   * Base abstract class for a {@link Transport} that provides local storage for all transport properties.
26   */
27  public abstract class BaseTransport implements Transport {
28      
29      /** Local credential. */
30      private Credential localCredential;
31      
32      /** Peer credential. */
33      private Credential peerCredential;
34      
35      /** Transport attributes. */
36      private Map<String, Object> attributes;
37      
38      /** Character encoding. */
39      private String characterEncoding;
40      
41      /** Authenticated flag. */
42      private boolean authenticated;
43      
44      /** Confidential flag. */
45      private boolean confidential;
46      
47      /** Integrity-protected flag. */
48      private boolean integrityProtected;
49      
50      /** Constructor. */
51      public BaseTransport() {
52          attributes = new HashMap<String, Object>();
53      }
54  
55      /** {@inheritDoc} */
56      public Object getAttribute(String name) {
57          return attributes.get(name);
58      }
59  
60      /** {@inheritDoc} */
61      public String getCharacterEncoding() {
62          return characterEncoding;
63      }
64  
65      /** {@inheritDoc} */
66      public Credential getLocalCredential() {
67          return localCredential;
68      }
69  
70      /** {@inheritDoc} */
71      public Credential getPeerCredential() {
72          return peerCredential;
73      }
74  
75      /** {@inheritDoc} */
76      public boolean isAuthenticated() {
77          return authenticated;
78      }
79  
80      /** {@inheritDoc} */
81      public boolean isConfidential() {
82          return confidential;
83      }
84  
85      /** {@inheritDoc} */
86      public boolean isIntegrityProtected() {
87          return integrityProtected;
88      }
89  
90      /** {@inheritDoc} */
91      public void setAuthenticated(boolean isAuthenticated) {
92          authenticated = isAuthenticated;
93      }
94  
95      /** {@inheritDoc} */
96      public void setConfidential(boolean isConfidential) {
97          confidential = isConfidential;
98      }
99  
100     /** {@inheritDoc} */
101     public void setIntegrityProtected(boolean isIntegrityProtected) {
102         integrityProtected = isIntegrityProtected;
103     }
104     
105     /**
106      * Set an attribute value.
107      * 
108      * @param name attribute name
109      * @param value attribute value
110      */
111     protected void setAttribute(String name, Object value) {
112         attributes.put(name, value);
113     }
114     
115     /**
116      * Set the character encoding.
117      * 
118      * @param encoding the character encoding
119      */
120     protected void setCharacterEncoding(String encoding) {
121         characterEncoding = encoding;
122     }
123     
124 }