View Javadoc

1   /*
2    * Licensed to the University Corporation for Advanced Internet Development, 
3    * Inc. (UCAID) under one or more contributor license agreements.  See the 
4    * NOTICE file distributed with this work for additional information regarding
5    * copyright ownership. The UCAID licenses this file to You under the Apache 
6    * License, Version 2.0 (the "License"); you may not use this file except in 
7    * compliance with the License.  You may obtain a copy of the License at
8    *
9    *    http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package edu.internet2.middleware.shibboleth.common.profile.provider;
19  
20  import java.util.Collection;
21  import java.util.Map;
22  
23  import org.opensaml.common.SAMLObject;
24  import org.opensaml.common.binding.BasicSAMLMessageContext;
25  import org.opensaml.common.binding.decoding.SAMLMessageDecoder;
26  import org.opensaml.common.binding.encoding.SAMLMessageEncoder;
27  
28  import edu.internet2.middleware.shibboleth.common.attribute.BaseAttribute;
29  import edu.internet2.middleware.shibboleth.common.relyingparty.ProfileConfiguration;
30  import edu.internet2.middleware.shibboleth.common.relyingparty.RelyingPartyConfiguration;
31  import edu.internet2.middleware.shibboleth.common.session.Session;
32  
33  /**
34   * Contextual object used to accumlate information as profile requests are being processed.
35   * 
36   * @param <InboundMessage> type of inbound SAML message
37   * @param <OutboundMessage> type of outbound SAML message
38   * @param <NameIdentifierType> type of name identifier used for subjects
39   * @param <ProfileConfigurationType> profile configuration type for current request
40   */
41  public class BaseSAMLProfileRequestContext<InboundMessage extends SAMLObject, OutboundMessage extends SAMLObject, NameIdentifierType extends SAMLObject, ProfileConfigurationType extends ProfileConfiguration>
42          extends BasicSAMLMessageContext<InboundMessage, OutboundMessage, NameIdentifierType> implements
43          SAMLProfileRequestContext<InboundMessage, OutboundMessage, NameIdentifierType, ProfileConfigurationType> {
44  
45      /** Decoder used to decode inbound message. */
46      private SAMLMessageDecoder messageDecoder;
47  
48      /** Encoder used to encode outbound message. */
49      private SAMLMessageEncoder messageEncoder;
50  
51      /** Attributes retrieved for the principal. */
52      private Map<String, BaseAttribute> principalAttributes;
53  
54      /** Authentication method used to authenticate the principal. */
55      private String principalAuthenticationMethod;
56  
57      /** Principal name of the subject of the request. */
58      private String principalName;
59  
60      /** Attribute encoded as the SAML name identifier. */
61      private BaseAttribute nameIdentifierAttribute;
62  
63      /** Configuration for the profile. */
64      private ProfileConfigurationType profileConfiguration;
65  
66      /** IDs of attribute released to relying party. */
67      private Collection<String> releasedAttributeIds;
68  
69      /** Configuration for the relying party. */
70      private RelyingPartyConfiguration relyingPartyConfiguration;
71  
72      /** IDs of attribute requested by relaying party. */
73      private Collection<String> requestedAttributeIds;
74  
75      /** Current user's session. */
76      private Session userSession;
77  
78      /** {@inheritDoc} */
79      public Map<String, BaseAttribute> getAttributes() {
80          return principalAttributes;
81      }
82  
83      /**
84       * Gets the message decoder used to decode the message from the inbound transport.
85       * 
86       * @return message decoder used to decode the message from the inbound transport
87       */
88      public SAMLMessageDecoder getMessageDecoder() {
89          return messageDecoder;
90      }
91  
92      /**
93       * Gets the message encoder used to encoder the message onto the outbound transport.
94       * 
95       * @return message encoder used to encoder the message onto the outbound transport
96       */
97      public SAMLMessageEncoder getMessageEncoder() {
98          return messageEncoder;
99      }
100 
101     /**
102      * Gets the attribute encoded as the SAML name identifier.
103      * 
104      * @return attribute encoded as the SAML name identifier
105      */
106     public BaseAttribute getNameIdentifierAttribute() {
107         return nameIdentifierAttribute;
108     }
109 
110     /** {@inheritDoc} */
111     public String getPrincipalAuthenticationMethod() {
112         return principalAuthenticationMethod;
113     }
114 
115     /** {@inheritDoc} */
116     public String getPrincipalName() {
117         return principalName;
118     }
119 
120     /**
121      * Gets the configuration for the profile for the relying party.
122      * 
123      * @return configuration for the profile for the relying party
124      */
125     public ProfileConfigurationType getProfileConfiguration() {
126         return profileConfiguration;
127     }
128 
129     /** {@inheritDoc} */
130     public Collection<String> getReleasedAttributes() {
131         return releasedAttributeIds;
132     }
133 
134     /** {@inheritDoc} */
135     public RelyingPartyConfiguration getRelyingPartyConfiguration() {
136         return relyingPartyConfiguration;
137     }
138 
139     /** {@inheritDoc} */
140     public Collection<String> getRequestedAttributesIds() {
141         return requestedAttributeIds;
142     }
143 
144     /** {@inheritDoc} */
145     public Session getUserSession() {
146         return userSession;
147     }
148 
149     /** {@inheritDoc} */
150     public void setAttributes(Map<String, BaseAttribute> attributes) {
151         principalAttributes = attributes;
152     }
153 
154     /**
155      * Sets the message decoder used to decode the message from the inbound transport.
156      * 
157      * @param decoder message decoder used to decode the message from the inbound transport
158      */
159     public void setMessageDecoder(SAMLMessageDecoder decoder) {
160         messageDecoder = decoder;
161     }
162 
163     /**
164      * Sets the message encoder used to encoder the message onto the outbound transport.
165      * 
166      * @param encoder message encoder used to encoder the message onto the outbound transport
167      */
168     public void setMessageEncoder(SAMLMessageEncoder encoder) {
169         messageEncoder = encoder;
170     }
171 
172     /**
173      * Sets the attribute encoded as the SAML name identifier.
174      * 
175      * @param attribute attribute encoded as the SAML name identifier
176      */
177     public void setNameIdentifierAttribute(BaseAttribute attribute) {
178         nameIdentifierAttribute = attribute;
179     }
180 
181     /** {@inheritDoc} */
182     public void setPrincipalAuthenticationMethod(String method) {
183         principalAuthenticationMethod = method;
184     }
185 
186     /** {@inheritDoc} */
187     public void setPrincipalName(String name) {
188         principalName = name;
189     }
190 
191     /** {@inheritDoc} */
192     public void setProfileConfiguration(ProfileConfigurationType configuration) {
193         profileConfiguration = configuration;
194     }
195 
196     /** {@inheritDoc} */
197     public void setReleasedAttributes(Collection<String> attributeIds) {
198         releasedAttributeIds = attributeIds;
199     }
200 
201     /** {@inheritDoc} */
202     public void setRelyingPartyConfiguration(RelyingPartyConfiguration configuration) {
203         relyingPartyConfiguration = configuration;
204     }
205 
206     /** {@inheritDoc} */
207     public void setRequestedAttributes(Collection<String> ids) {
208         requestedAttributeIds = ids;
209     }
210 
211     /** {@inheritDoc} */
212     public void setUserSession(Session session) {
213         userSession = session;
214     }
215 }