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 edu.internet2.middleware.shibboleth.common.profile.provider;
18  
19  import java.util.Collection;
20  import java.util.Map;
21  
22  import org.opensaml.common.SAMLObject;
23  import org.opensaml.common.binding.BasicSAMLMessageContext;
24  import org.opensaml.common.binding.decoding.SAMLMessageDecoder;
25  import org.opensaml.common.binding.encoding.SAMLMessageEncoder;
26  
27  import edu.internet2.middleware.shibboleth.common.attribute.BaseAttribute;
28  import edu.internet2.middleware.shibboleth.common.relyingparty.ProfileConfiguration;
29  import edu.internet2.middleware.shibboleth.common.relyingparty.RelyingPartyConfiguration;
30  import edu.internet2.middleware.shibboleth.common.session.Session;
31  
32  /**
33   * Contextual object used to accumlate information as profile requests are being processed.
34   * 
35   * @param <InboundMessage> type of inbound SAML message
36   * @param <OutboundMessage> type of outbound SAML message
37   * @param <NameIdentifierType> type of name identifier used for subjects
38   * @param <ProfileConfigurationType> profile configuration type for current request
39   */
40  public class BaseSAMLProfileRequestContext<InboundMessage extends SAMLObject, OutboundMessage extends SAMLObject, NameIdentifierType extends SAMLObject, ProfileConfigurationType extends ProfileConfiguration>
41          extends BasicSAMLMessageContext<InboundMessage, OutboundMessage, NameIdentifierType> implements
42          SAMLProfileRequestContext<InboundMessage, OutboundMessage, NameIdentifierType, ProfileConfigurationType> {
43      
44      /** Decoder used to decode inbound message. */
45      private SAMLMessageDecoder messageDecoder;
46      
47      /** Encoder used to encode outbound message. */
48      private SAMLMessageEncoder messageEncoder;
49      
50      /** Attributes retrieved for the principal. */
51      private Map<String, BaseAttribute> principalAttributes;
52  
53      /** Authentication method used to authenticate the principal. */
54      private String principalAuthenticationMethod;
55  
56      /** Principal name of the subject of the request. */
57      private String principalName;
58  
59      /** Configuration for the profile. */
60      private ProfileConfigurationType profileConfiguration;
61  
62      /** IDs of attribute released to relying party. */
63      private Collection<String> releasedAttributeIds;
64  
65      /** Configuration for the relying party. */
66      private RelyingPartyConfiguration relyingPartyConfiguration;
67  
68      /** IDs of attribute requested by relaying party. */
69      private Collection<String> requestedAttributeIds;
70  
71      /** Current user's session. */
72      private Session userSession;
73  
74      /** {@inheritDoc} */
75      public Map<String, BaseAttribute> getAttributes() {
76          return principalAttributes;
77      }
78  
79      /**
80       * Gets the message decoder used to decode the message from the inbound transport.
81       * 
82       * @return message decoder used to decode the message from the inbound transport
83       */
84      public SAMLMessageDecoder getMessageDecoder() {
85          return messageDecoder;
86      }
87  
88      /**
89       * Gets the message encoder used to encoder the message onto the outbound transport.
90       * 
91       * @return message encoder used to encoder the message onto the outbound transport
92       */
93      public SAMLMessageEncoder getMessageEncoder() {
94          return messageEncoder;
95      }
96  
97      /** {@inheritDoc} */
98      public String getPrincipalAuthenticationMethod() {
99          return principalAuthenticationMethod;
100     }
101 
102     /** {@inheritDoc} */
103     public String getPrincipalName() {
104         return principalName;
105     }
106 
107     /**
108      * Gets the configuration for the profile for the relying party.
109      * 
110      * @return configuration for the profile for the relying party
111      */
112     public ProfileConfigurationType getProfileConfiguration() {
113         return profileConfiguration;
114     }
115 
116     /** {@inheritDoc} */
117     public Collection<String> getReleasedAttributes() {
118         return releasedAttributeIds;
119     }
120 
121     /** {@inheritDoc} */
122     public RelyingPartyConfiguration getRelyingPartyConfiguration() {
123         return relyingPartyConfiguration;
124     }
125 
126     /** {@inheritDoc} */
127     public Collection<String> getRequestedAttributesIds() {
128         return requestedAttributeIds;
129     }
130 
131     /** {@inheritDoc} */
132     public Session getUserSession() {
133         return userSession;
134     }
135 
136     /** {@inheritDoc} */
137     public void setAttributes(Map<String, BaseAttribute> attributes) {
138         principalAttributes = attributes;
139     }
140 
141     /**
142      * Sets the message decoder used to decode the message from the inbound transport.
143      * 
144      * @param decoder message decoder used to decode the message from the inbound transport
145      */
146     public void setMessageDecoder(SAMLMessageDecoder decoder) {
147         messageDecoder = decoder;
148     }
149 
150     /**
151      * Sets the message encoder used to encoder the message onto the outbound transport.
152      * 
153      * @param encoder message encoder used to encoder the message onto the outbound transport
154      */
155     public void setMessageEncoder(SAMLMessageEncoder encoder) {
156         messageEncoder = encoder;
157     }
158 
159     /** {@inheritDoc} */
160     public void setPrincipalAuthenticationMethod(String method) {
161         principalAuthenticationMethod = method;
162     }
163 
164     /** {@inheritDoc} */
165     public void setPrincipalName(String name) {
166         principalName = name;
167     }
168 
169     /** {@inheritDoc} */
170     public void setProfileConfiguration(ProfileConfigurationType configuration) {
171         profileConfiguration = configuration;
172     }
173 
174     /** {@inheritDoc} */
175     public void setReleasedAttributes(Collection<String> attributeIds) {
176         releasedAttributeIds = attributeIds;
177     }
178 
179     /** {@inheritDoc} */
180     public void setRelyingPartyConfiguration(RelyingPartyConfiguration configuration) {
181         relyingPartyConfiguration = configuration;
182     }
183 
184     /** {@inheritDoc} */
185     public void setRequestedAttributes(Collection<String> ids) {
186         requestedAttributeIds = ids;
187     }
188 
189     /** {@inheritDoc} */
190     public void setUserSession(Session session) {
191         userSession = session;
192     }
193 }