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      /** Attribute encoded as the SAML name identifier. */
60      private BaseAttribute nameIdentifierAttribute;
61  
62      /** Configuration for the profile. */
63      private ProfileConfigurationType profileConfiguration;
64  
65      /** IDs of attribute released to relying party. */
66      private Collection<String> releasedAttributeIds;
67  
68      /** Configuration for the relying party. */
69      private RelyingPartyConfiguration relyingPartyConfiguration;
70  
71      /** IDs of attribute requested by relaying party. */
72      private Collection<String> requestedAttributeIds;
73  
74      /** Current user's session. */
75      private Session userSession;
76  
77      /** {@inheritDoc} */
78      public Map<String, BaseAttribute> getAttributes() {
79          return principalAttributes;
80      }
81  
82      /**
83       * Gets the message decoder used to decode the message from the inbound transport.
84       * 
85       * @return message decoder used to decode the message from the inbound transport
86       */
87      public SAMLMessageDecoder getMessageDecoder() {
88          return messageDecoder;
89      }
90  
91      /**
92       * Gets the message encoder used to encoder the message onto the outbound transport.
93       * 
94       * @return message encoder used to encoder the message onto the outbound transport
95       */
96      public SAMLMessageEncoder getMessageEncoder() {
97          return messageEncoder;
98      }
99  
100     /**
101      * Gets the attribute encoded as the SAML name identifier.
102      * 
103      * @return attribute encoded as the SAML name identifier
104      */
105     public BaseAttribute getNameIdentifierAttribute() {
106         return nameIdentifierAttribute;
107     }
108 
109     /** {@inheritDoc} */
110     public String getPrincipalAuthenticationMethod() {
111         return principalAuthenticationMethod;
112     }
113 
114     /** {@inheritDoc} */
115     public String getPrincipalName() {
116         return principalName;
117     }
118 
119     /**
120      * Gets the configuration for the profile for the relying party.
121      * 
122      * @return configuration for the profile for the relying party
123      */
124     public ProfileConfigurationType getProfileConfiguration() {
125         return profileConfiguration;
126     }
127 
128     /** {@inheritDoc} */
129     public Collection<String> getReleasedAttributes() {
130         return releasedAttributeIds;
131     }
132 
133     /** {@inheritDoc} */
134     public RelyingPartyConfiguration getRelyingPartyConfiguration() {
135         return relyingPartyConfiguration;
136     }
137 
138     /** {@inheritDoc} */
139     public Collection<String> getRequestedAttributesIds() {
140         return requestedAttributeIds;
141     }
142 
143     /** {@inheritDoc} */
144     public Session getUserSession() {
145         return userSession;
146     }
147 
148     /** {@inheritDoc} */
149     public void setAttributes(Map<String, BaseAttribute> attributes) {
150         principalAttributes = attributes;
151     }
152 
153     /**
154      * Sets the message decoder used to decode the message from the inbound transport.
155      * 
156      * @param decoder message decoder used to decode the message from the inbound transport
157      */
158     public void setMessageDecoder(SAMLMessageDecoder decoder) {
159         messageDecoder = decoder;
160     }
161 
162     /**
163      * Sets the message encoder used to encoder the message onto the outbound transport.
164      * 
165      * @param encoder message encoder used to encoder the message onto the outbound transport
166      */
167     public void setMessageEncoder(SAMLMessageEncoder encoder) {
168         messageEncoder = encoder;
169     }
170 
171     /**
172      * Sets the attribute encoded as the SAML name identifier.
173      * 
174      * @param attribute attribute encoded as the SAML name identifier
175      */
176     public void setNameIdentifierAttribute(BaseAttribute attribute) {
177         nameIdentifierAttribute = attribute;
178     }
179 
180     /** {@inheritDoc} */
181     public void setPrincipalAuthenticationMethod(String method) {
182         principalAuthenticationMethod = method;
183     }
184 
185     /** {@inheritDoc} */
186     public void setPrincipalName(String name) {
187         principalName = name;
188     }
189 
190     /** {@inheritDoc} */
191     public void setProfileConfiguration(ProfileConfigurationType configuration) {
192         profileConfiguration = configuration;
193     }
194 
195     /** {@inheritDoc} */
196     public void setReleasedAttributes(Collection<String> attributeIds) {
197         releasedAttributeIds = attributeIds;
198     }
199 
200     /** {@inheritDoc} */
201     public void setRelyingPartyConfiguration(RelyingPartyConfiguration configuration) {
202         relyingPartyConfiguration = configuration;
203     }
204 
205     /** {@inheritDoc} */
206     public void setRequestedAttributes(Collection<String> ids) {
207         requestedAttributeIds = ids;
208     }
209 
210     /** {@inheritDoc} */
211     public void setUserSession(Session session) {
212         userSession = session;
213     }
214 }