257a268b1a06b7b85ea816bcf65e36c9c6b8a63b
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / idp / profile / saml2 / SSOProfileHandler.java
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.idp.profile.saml2;
18
19 import java.io.IOException;
20 import java.util.ArrayList;
21
22 import javax.servlet.RequestDispatcher;
23 import javax.servlet.ServletException;
24 import javax.servlet.http.HttpServletRequest;
25
26 import org.opensaml.common.SAMLObjectBuilder;
27 import org.opensaml.common.binding.decoding.SAMLMessageDecoder;
28 import org.opensaml.common.xml.SAMLConstants;
29 import org.opensaml.saml2.binding.AuthnResponseEndpointSelector;
30 import org.opensaml.saml2.core.AttributeStatement;
31 import org.opensaml.saml2.core.AuthnContext;
32 import org.opensaml.saml2.core.AuthnContextClassRef;
33 import org.opensaml.saml2.core.AuthnContextDeclRef;
34 import org.opensaml.saml2.core.AuthnRequest;
35 import org.opensaml.saml2.core.AuthnStatement;
36 import org.opensaml.saml2.core.RequestedAuthnContext;
37 import org.opensaml.saml2.core.Response;
38 import org.opensaml.saml2.core.Statement;
39 import org.opensaml.saml2.core.StatusCode;
40 import org.opensaml.saml2.core.Subject;
41 import org.opensaml.saml2.core.SubjectLocality;
42 import org.opensaml.saml2.metadata.AssertionConsumerService;
43 import org.opensaml.saml2.metadata.Endpoint;
44 import org.opensaml.saml2.metadata.EntityDescriptor;
45 import org.opensaml.saml2.metadata.IDPSSODescriptor;
46 import org.opensaml.saml2.metadata.SPSSODescriptor;
47 import org.opensaml.ws.message.decoder.MessageDecodingException;
48 import org.opensaml.ws.transport.http.HTTPInTransport;
49 import org.opensaml.ws.transport.http.HTTPOutTransport;
50 import org.opensaml.ws.transport.http.HttpServletRequestAdapter;
51 import org.opensaml.ws.transport.http.HttpServletResponseAdapter;
52 import org.opensaml.xml.io.MarshallingException;
53 import org.opensaml.xml.io.UnmarshallingException;
54 import org.opensaml.xml.security.SecurityException;
55 import org.opensaml.xml.util.DatatypeHelper;
56 import org.slf4j.Logger;
57 import org.slf4j.LoggerFactory;
58
59 import edu.internet2.middleware.shibboleth.common.profile.ProfileException;
60 import edu.internet2.middleware.shibboleth.common.profile.provider.BaseSAMLProfileRequestContext;
61 import edu.internet2.middleware.shibboleth.common.relyingparty.ProfileConfiguration;
62 import edu.internet2.middleware.shibboleth.common.relyingparty.RelyingPartyConfiguration;
63 import edu.internet2.middleware.shibboleth.common.relyingparty.provider.saml2.SSOConfiguration;
64 import edu.internet2.middleware.shibboleth.common.util.HttpHelper;
65 import edu.internet2.middleware.shibboleth.idp.authn.LoginContext;
66 import edu.internet2.middleware.shibboleth.idp.authn.PassiveAuthenticationException;
67 import edu.internet2.middleware.shibboleth.idp.authn.Saml2LoginContext;
68 import edu.internet2.middleware.shibboleth.idp.session.Session;
69
70 /** SAML 2.0 SSO request profile handler. */
71 public class SSOProfileHandler extends AbstractSAML2ProfileHandler {
72
73     /** Class logger. */
74     private final Logger log = LoggerFactory.getLogger(SSOProfileHandler.class);
75
76     /** Builder of AuthnStatement objects. */
77     private SAMLObjectBuilder<AuthnStatement> authnStatementBuilder;
78
79     /** Builder of AuthnContext objects. */
80     private SAMLObjectBuilder<AuthnContext> authnContextBuilder;
81
82     /** Builder of AuthnContextClassRef objects. */
83     private SAMLObjectBuilder<AuthnContextClassRef> authnContextClassRefBuilder;
84
85     /** Builder of AuthnContextDeclRef objects. */
86     private SAMLObjectBuilder<AuthnContextDeclRef> authnContextDeclRefBuilder;
87
88     /** Builder of SubjectLocality objects. */
89     private SAMLObjectBuilder<SubjectLocality> subjectLocalityBuilder;
90
91     /** URL of the authentication manager servlet. */
92     private String authenticationManagerPath;
93
94     /**
95      * Constructor.
96      * 
97      * @param authnManagerPath path to the authentication manager servlet
98      */
99     @SuppressWarnings("unchecked")
100     public SSOProfileHandler(String authnManagerPath) {
101         super();
102
103         authenticationManagerPath = authnManagerPath;
104
105         authnStatementBuilder = (SAMLObjectBuilder<AuthnStatement>) getBuilderFactory().getBuilder(
106                 AuthnStatement.DEFAULT_ELEMENT_NAME);
107         authnContextBuilder = (SAMLObjectBuilder<AuthnContext>) getBuilderFactory().getBuilder(
108                 AuthnContext.DEFAULT_ELEMENT_NAME);
109         authnContextClassRefBuilder = (SAMLObjectBuilder<AuthnContextClassRef>) getBuilderFactory().getBuilder(
110                 AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
111         authnContextDeclRefBuilder = (SAMLObjectBuilder<AuthnContextDeclRef>) getBuilderFactory().getBuilder(
112                 AuthnContextDeclRef.DEFAULT_ELEMENT_NAME);
113         subjectLocalityBuilder = (SAMLObjectBuilder<SubjectLocality>) getBuilderFactory().getBuilder(
114                 SubjectLocality.DEFAULT_ELEMENT_NAME);
115     }
116
117     /** {@inheritDoc} */
118     public String getProfileId() {
119         return SSOConfiguration.PROFILE_ID;
120     }
121
122     /** {@inheritDoc} */
123     public void processRequest(HTTPInTransport inTransport, HTTPOutTransport outTransport) throws ProfileException {
124         HttpServletRequest servletRequest = ((HttpServletRequestAdapter) inTransport).getWrappedRequest();
125
126         LoginContext loginContext = (LoginContext) servletRequest.getAttribute(LoginContext.LOGIN_CONTEXT_KEY);
127         if (loginContext == null) {
128             log.debug("Incoming request does not contain a login context, processing as first leg of request");
129             performAuthentication(inTransport, outTransport);
130         } else {
131             log.debug("Incoming request contains a login context, processing as second leg of request");
132             completeAuthenticationRequest(inTransport, outTransport);
133         }
134     }
135
136     /**
137      * Creates a {@link Saml2LoginContext} an sends the request off to the AuthenticationManager to begin the process of
138      * authenticating the user.
139      * 
140      * @param inTransport inbound request transport
141      * @param outTransport outbound response transport
142      * 
143      * @throws ProfileException thrown if there is a problem creating the login context and transferring control to the
144      *             authentication manager
145      */
146     protected void performAuthentication(HTTPInTransport inTransport, HTTPOutTransport outTransport)
147             throws ProfileException {
148         HttpServletRequest servletRequest = ((HttpServletRequestAdapter) inTransport).getWrappedRequest();
149
150         try {
151             SSORequestContext requestContext = decodeRequest(inTransport, outTransport);
152
153             String relyingPartyId = requestContext.getInboundMessageIssuer();
154             RelyingPartyConfiguration rpConfig = getRelyingPartyConfiguration(relyingPartyId);
155             ProfileConfiguration ssoConfig = rpConfig.getProfileConfiguration(SSOConfiguration.PROFILE_ID);
156             if (ssoConfig == null) {
157                 log.error("SAML 2 SSO profile is not configured for relying party "
158                         + requestContext.getInboundMessageIssuer());
159                 throw new ProfileException("SAML 2 SSO profile is not configured for relying party "
160                         + requestContext.getInboundMessageIssuer());
161             }
162
163             log.debug("Creating login context and transferring control to authentication engine");
164             Saml2LoginContext loginContext = new Saml2LoginContext(relyingPartyId, requestContext.getRelayState(),
165                     requestContext.getInboundSAMLMessage());
166             loginContext.setAuthenticationEngineURL(authenticationManagerPath);
167             loginContext.setProfileHandlerURL(HttpHelper.getRequestUriWithoutContext(servletRequest));
168             if (loginContext.getRequestedAuthenticationMethods().size() == 0) {
169                 loginContext.getRequestedAuthenticationMethods().add(rpConfig.getDefaultAuthenticationMethod());
170             }
171
172             servletRequest.setAttribute(Saml2LoginContext.LOGIN_CONTEXT_KEY, loginContext);
173             RequestDispatcher dispatcher = servletRequest.getRequestDispatcher(authenticationManagerPath);
174             dispatcher.forward(servletRequest, ((HttpServletResponseAdapter) outTransport).getWrappedResponse());
175         } catch (MarshallingException e) {
176             log.error("Unable to marshall authentication request context");
177             throw new ProfileException("Unable to marshall authentication request context", e);
178         } catch (IOException ex) {
179             log.error("Error forwarding SAML 2 AuthnRequest to AuthenticationManager", ex);
180             throw new ProfileException("Error forwarding SAML 2 AuthnRequest to AuthenticationManager", ex);
181         } catch (ServletException ex) {
182             log.error("Error forwarding SAML 2 AuthnRequest to AuthenticationManager", ex);
183             throw new ProfileException("Error forwarding SAML 2 AuthnRequest to AuthenticationManager", ex);
184         }
185     }
186
187     /**
188      * Creates a response to the {@link AuthnRequest} and sends the user, with response in tow, back to the relying
189      * party after they've been authenticated.
190      * 
191      * @param inTransport inbound message transport
192      * @param outTransport outbound message transport
193      * 
194      * @throws ProfileException thrown if the response can not be created and sent back to the relying party
195      */
196     protected void completeAuthenticationRequest(HTTPInTransport inTransport, HTTPOutTransport outTransport)
197             throws ProfileException {
198         HttpServletRequest servletRequest = ((HttpServletRequestAdapter) inTransport).getWrappedRequest();
199
200         Saml2LoginContext loginContext = (Saml2LoginContext) servletRequest
201                 .getAttribute(LoginContext.LOGIN_CONTEXT_KEY);
202         SSORequestContext requestContext = buildRequestContext(loginContext, inTransport, outTransport);
203
204         checkSamlVersion(requestContext);
205
206         Response samlResponse;
207         try {
208             if (loginContext.getAuthenticationFailure() != null) {
209                 log.error("User authentication failed with the following error: {}", loginContext
210                         .getAuthenticationFailure().toString());
211
212                 if (loginContext.getAuthenticationFailure() instanceof PassiveAuthenticationException) {
213                     requestContext.setFailureStatus(buildStatus(StatusCode.RESPONDER_URI, StatusCode.NO_PASSIVE_URI,
214                             null));
215                 } else {
216                     requestContext.setFailureStatus(buildStatus(StatusCode.RESPONDER_URI, StatusCode.AUTHN_FAILED_URI,
217                             null));
218                 }
219                 throw new ProfileException("Authentication failure", loginContext.getAuthenticationFailure());
220             }
221
222             if (requestContext.getSubjectNameIdentifier() != null) {
223                 log
224                         .debug("Authentication request contained a subject with a name identifier, resolving principal from NameID");
225                 resolvePrincipal(requestContext);
226                 String requestedPrincipalName = requestContext.getPrincipalName();
227                 if (!DatatypeHelper.safeEquals(loginContext.getPrincipalName(), requestedPrincipalName)) {
228                     log
229                             .error(
230                                     "Authentication request identified principal {} but authentication mechanism identified principal {}",
231                                     requestedPrincipalName, loginContext.getPrincipalName());
232                     requestContext.setFailureStatus(buildStatus(StatusCode.RESPONDER_URI, StatusCode.AUTHN_FAILED_URI,
233                             null));
234                     throw new ProfileException("User failed authentication");
235                 }
236             }
237
238             resolveAttributes(requestContext);
239
240             ArrayList<Statement> statements = new ArrayList<Statement>();
241             statements.add(buildAuthnStatement(requestContext));
242             if (requestContext.getProfileConfiguration().includeAttributeStatement()) {
243                 AttributeStatement attributeStatement = buildAttributeStatement(requestContext);
244                 if (attributeStatement != null) {
245                     requestContext.setRequestedAttributes(requestContext.getAttributes().keySet());
246                     statements.add(attributeStatement);
247                 }
248             }
249
250             samlResponse = buildResponse(requestContext, "urn:oasis:names:tc:SAML:2.0:cm:bearer", statements);
251         } catch (ProfileException e) {
252             samlResponse = buildErrorResponse(requestContext);
253         }
254
255         requestContext.setOutboundSAMLMessage(samlResponse);
256         requestContext.setOutboundSAMLMessageId(samlResponse.getID());
257         requestContext.setOutboundSAMLMessageIssueInstant(samlResponse.getIssueInstant());
258         encodeResponse(requestContext);
259         writeAuditLogEntry(requestContext);
260     }
261
262     /**
263      * Decodes an incoming request and stores the information in a created request context.
264      * 
265      * @param inTransport inbound transport
266      * @param outTransport outbound transport
267      * 
268      * @return request context with decoded information
269      * 
270      * @throws ProfileException thrown if the incoming message failed decoding
271      */
272     protected SSORequestContext decodeRequest(HTTPInTransport inTransport, HTTPOutTransport outTransport)
273             throws ProfileException {
274         log.debug("Decoding message with decoder binding {}", getInboundBinding());
275         SSORequestContext requestContext = new SSORequestContext();
276         requestContext.setMetadataProvider(getMetadataProvider());
277         requestContext.setSecurityPolicyResolver(getSecurityPolicyResolver());
278
279         requestContext.setCommunicationProfileId(SSOConfiguration.PROFILE_ID);
280         requestContext.setInboundMessageTransport(inTransport);
281         requestContext.setInboundSAMLProtocol(SAMLConstants.SAML20P_NS);
282         requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
283
284         requestContext.setOutboundMessageTransport(outTransport);
285         requestContext.setOutboundSAMLProtocol(SAMLConstants.SAML20P_NS);
286
287         try {
288             SAMLMessageDecoder decoder = getMessageDecoders().get(getInboundBinding());
289             requestContext.setMessageDecoder(decoder);
290             decoder.decode(requestContext);
291             log.debug("Decoded request");
292
293             if (!(requestContext.getInboundMessage() instanceof AuthnRequest)) {
294                 log.error("Incomming message was not a AuthnRequest, it was a {}", requestContext.getInboundMessage()
295                         .getClass().getName());
296                 requestContext.setFailureStatus(buildStatus(StatusCode.REQUESTER_URI, null,
297                         "Invalid SAML AuthnRequest message."));
298                 throw new ProfileException("Invalid SAML AuthnRequest message.");
299             }
300
301             return requestContext;
302         } catch (MessageDecodingException e) {
303             log.error("Error decoding authentication request message", e);
304             throw new ProfileException("Error decoding authentication request message", e);
305         } catch (SecurityException e) {
306             log.error("Message did not meet security requirements", e);
307             throw new ProfileException("Message did not meet security requirements", e);
308         }
309     }
310
311     /**
312      * Creates an authentication request context from the current environmental information.
313      * 
314      * @param loginContext current login context
315      * @param in inbound transport
316      * @param out outbount transport
317      * 
318      * @return created authentication request context
319      * 
320      * @throws ProfileException thrown if there is a problem creating the context
321      */
322     protected SSORequestContext buildRequestContext(Saml2LoginContext loginContext, HTTPInTransport in,
323             HTTPOutTransport out) throws ProfileException {
324         SSORequestContext requestContext = new SSORequestContext();
325
326         requestContext.setMessageDecoder(getMessageDecoders().get(getInboundBinding()));
327
328         requestContext.setLoginContext(loginContext);
329
330         requestContext.setInboundMessageTransport(in);
331         requestContext.setInboundSAMLProtocol(SAMLConstants.SAML20P_NS);
332
333         requestContext.setOutboundMessageTransport(out);
334         requestContext.setOutboundSAMLProtocol(SAMLConstants.SAML20P_NS);
335
336         requestContext.setMetadataProvider(getMetadataProvider());
337
338         String relyingPartyId = loginContext.getRelyingPartyId();
339         requestContext.setInboundMessageIssuer(relyingPartyId);
340
341         populateSAMLMessageInformation(requestContext);
342         populateRequestContext(requestContext);
343         populateProfileInformation(requestContext);
344
345         return requestContext;
346     }
347
348     /** {@inheritDoc} */
349     protected void populateRelyingPartyInformation(BaseSAMLProfileRequestContext requestContext)
350             throws ProfileException {
351         super.populateRelyingPartyInformation(requestContext);
352
353         EntityDescriptor relyingPartyMetadata = requestContext.getPeerEntityMetadata();
354         if (relyingPartyMetadata != null) {
355             requestContext.setPeerEntityRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
356             requestContext.setPeerEntityRoleMetadata(relyingPartyMetadata.getSPSSODescriptor(SAMLConstants.SAML20P_NS));
357         }
358     }
359
360     /** {@inheritDoc} */
361     protected void populateAssertingPartyInformation(BaseSAMLProfileRequestContext requestContext)
362             throws ProfileException {
363         super.populateAssertingPartyInformation(requestContext);
364
365         EntityDescriptor localEntityDescriptor = requestContext.getLocalEntityMetadata();
366         if (localEntityDescriptor != null) {
367             requestContext.setLocalEntityRole(IDPSSODescriptor.DEFAULT_ELEMENT_NAME);
368             requestContext.setLocalEntityRoleMetadata(localEntityDescriptor
369                     .getIDPSSODescriptor(SAMLConstants.SAML20P_NS));
370         }
371     }
372
373     /**
374      * Populates the request context with information from the inbound SAML message.
375      * 
376      * This method requires the the following request context properties to be populated: login context
377      * 
378      * This methods populates the following request context properties: inbound saml message, relay state, inbound saml
379      * message ID, subject name identifier
380      * 
381      * @param requestContext current request context
382      * 
383      * @throws ProfileException thrown if the inbound SAML message or subject identifier is null
384      */
385     protected void populateSAMLMessageInformation(BaseSAMLProfileRequestContext requestContext) throws ProfileException {
386         SSORequestContext ssoRequestContext = (SSORequestContext) requestContext;
387         try {
388             Saml2LoginContext loginContext = ssoRequestContext.getLoginContext();
389             requestContext.setRelayState(loginContext.getRelayState());
390
391             AuthnRequest authnRequest = loginContext.getAuthenticationRequest();
392             requestContext.setInboundMessage(authnRequest);
393             requestContext.setInboundSAMLMessage(loginContext.getAuthenticationRequest());
394             requestContext.setInboundSAMLMessageId(loginContext.getAuthenticationRequest().getID());
395
396             Subject authnSubject = authnRequest.getSubject();
397             if (authnSubject != null) {
398                 requestContext.setSubjectNameIdentifier(authnSubject.getNameID());
399             }
400         } catch (UnmarshallingException e) {
401             log.error("Unable to unmarshall authentication request context");
402             ssoRequestContext.setFailureStatus(buildStatus(StatusCode.RESPONDER_URI, null,
403                     "Error recovering request state"));
404             throw new ProfileException("Error recovering request state", e);
405         }
406     }
407
408     /**
409      * Creates an authentication statement for the current request.
410      * 
411      * @param requestContext current request context
412      * 
413      * @return constructed authentication statement
414      */
415     protected AuthnStatement buildAuthnStatement(SSORequestContext requestContext) {
416         Saml2LoginContext loginContext = requestContext.getLoginContext();
417
418         AuthnContext authnContext = buildAuthnContext(requestContext);
419
420         AuthnStatement statement = authnStatementBuilder.buildObject();
421         statement.setAuthnContext(authnContext);
422         statement.setAuthnInstant(loginContext.getAuthenticationInstant());
423
424         Session session = getUserSession(requestContext.getInboundMessageTransport());
425         if (session != null) {
426             statement.setSessionIndex(session.getSessionID());
427         }
428
429         if (loginContext.getAuthenticationDuration() > 0) {
430             statement.setSessionNotOnOrAfter(loginContext.getAuthenticationInstant().plus(
431                     loginContext.getAuthenticationDuration()));
432         }
433
434         statement.setSubjectLocality(buildSubjectLocality(requestContext));
435
436         return statement;
437     }
438
439     /**
440      * Creates an {@link AuthnContext} for a succesful authentication request.
441      * 
442      * @param requestContext current request
443      * 
444      * @return the built authn context
445      */
446     protected AuthnContext buildAuthnContext(SSORequestContext requestContext) {
447         AuthnContext authnContext = authnContextBuilder.buildObject();
448
449         Saml2LoginContext loginContext = requestContext.getLoginContext();
450         AuthnRequest authnRequest = requestContext.getInboundSAMLMessage();
451         RequestedAuthnContext requestedAuthnContext = authnRequest.getRequestedAuthnContext();
452         if (requestedAuthnContext != null) {
453             if (requestedAuthnContext.getAuthnContextClassRefs() != null) {
454                 for (AuthnContextClassRef classRef : requestedAuthnContext.getAuthnContextClassRefs()) {
455                     if (classRef.getAuthnContextClassRef().equals(loginContext.getAuthenticationMethod())) {
456                         AuthnContextClassRef ref = authnContextClassRefBuilder.buildObject();
457                         ref.setAuthnContextClassRef(loginContext.getAuthenticationMethod());
458                         authnContext.setAuthnContextClassRef(ref);
459                     }
460                 }
461             } else if (requestedAuthnContext.getAuthnContextDeclRefs() != null) {
462                 for (AuthnContextDeclRef declRef : requestedAuthnContext.getAuthnContextDeclRefs()) {
463                     if (declRef.getAuthnContextDeclRef().equals(loginContext.getAuthenticationMethod())) {
464                         AuthnContextDeclRef ref = authnContextDeclRefBuilder.buildObject();
465                         ref.setAuthnContextDeclRef(loginContext.getAuthenticationMethod());
466                         authnContext.setAuthnContextDeclRef(ref);
467                     }
468                 }
469             }
470         } else {
471             AuthnContextDeclRef ref = authnContextDeclRefBuilder.buildObject();
472             ref.setAuthnContextDeclRef(loginContext.getAuthenticationMethod());
473             authnContext.setAuthnContextDeclRef(ref);
474         }
475
476         return authnContext;
477     }
478
479     /**
480      * Constructs the subject locality for the authentication statement.
481      * 
482      * @param requestContext curent request context
483      * 
484      * @return subject locality for the authentication statement
485      */
486     protected SubjectLocality buildSubjectLocality(SSORequestContext requestContext) {
487         HTTPInTransport transport = (HTTPInTransport) requestContext.getInboundMessageTransport();
488         SubjectLocality subjectLocality = subjectLocalityBuilder.buildObject();
489         subjectLocality.setAddress(transport.getPeerAddress());
490
491         return subjectLocality;
492     }
493
494     /**
495      * Selects the appropriate endpoint for the relying party and stores it in the request context.
496      * 
497      * @param requestContext current request context
498      * 
499      * @return Endpoint selected from the information provided in the request context
500      */
501     protected Endpoint selectEndpoint(BaseSAMLProfileRequestContext requestContext) {
502         AuthnResponseEndpointSelector endpointSelector = new AuthnResponseEndpointSelector();
503         endpointSelector.setEndpointType(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
504         endpointSelector.setMetadataProvider(getMetadataProvider());
505         endpointSelector.setEntityMetadata(requestContext.getPeerEntityMetadata());
506         endpointSelector.setEntityRoleMetadata(requestContext.getPeerEntityRoleMetadata());
507         endpointSelector.setSamlRequest(requestContext.getInboundSAMLMessage());
508         endpointSelector.getSupportedIssuerBindings().addAll(getSupportedOutboundBindings());
509         return endpointSelector.selectEndpoint();
510     }
511
512     /** Represents the internal state of a SAML 2.0 SSO Request while it's being processed by the IdP. */
513     protected class SSORequestContext extends BaseSAML2ProfileRequestContext<AuthnRequest, Response, SSOConfiguration> {
514
515         /** Current login context. */
516         private Saml2LoginContext loginContext;
517
518         /**
519          * Gets the current login context.
520          * 
521          * @return current login context
522          */
523         public Saml2LoginContext getLoginContext() {
524             return loginContext;
525         }
526
527         /**
528          * Sets the current login context.
529          * 
530          * @param context current login context
531          */
532         public void setLoginContext(Saml2LoginContext context) {
533             loginContext = context;
534         }
535     }
536 }