View Javadoc

1   /*
2    * Copyright [2005] [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  /**
18   * 
19   */
20  
21  package org.opensaml.saml2.core.impl;
22  
23  import java.util.ArrayList;
24  import java.util.Collections;
25  import java.util.List;
26  
27  import org.joda.time.DateTime;
28  import org.opensaml.common.impl.AbstractSAMLObject;
29  import org.opensaml.saml2.core.AuthnContext;
30  import org.opensaml.saml2.core.AuthnStatement;
31  import org.opensaml.saml2.core.SubjectLocality;
32  import org.opensaml.xml.XMLObject;
33  
34  /**
35   * A concrete implementation of {@link org.opensaml.saml2.core.AuthnStatement}.
36   */
37  public class AuthnStatementImpl extends AbstractSAMLObject implements AuthnStatement {
38  
39      /** Subject Locality of the Authentication Statement. */
40      private SubjectLocality subjectLocality;
41  
42      /** Authentication Context of the Authentication Statement. */
43      private AuthnContext authnContext;
44  
45      /** Time of the authentication. */
46      private DateTime authnInstant;
47  
48      /** Index of the session. */
49      private String sessionIndex;
50  
51      /** Time at which the session ends. */
52      private DateTime sessionNotOnOrAfter;
53  
54      /**
55       * Constructor.
56       * 
57       * @param namespaceURI the namespace the element is in
58       * @param elementLocalName the local name of the XML element this Object represents
59       * @param namespacePrefix the prefix for the given namespace
60       */
61      protected AuthnStatementImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
62          super(namespaceURI, elementLocalName, namespacePrefix);
63      }
64  
65      /** {@inheritDoc} */
66      public SubjectLocality getSubjectLocality() {
67          return subjectLocality;
68      }
69  
70      /** {@inheritDoc} */
71      public void setSubjectLocality(SubjectLocality newSubjectLocality) {
72          this.subjectLocality = prepareForAssignment(this.subjectLocality, newSubjectLocality);
73      }
74  
75      /** {@inheritDoc} */
76      public AuthnContext getAuthnContext() {
77          return authnContext;
78      }
79  
80      /** {@inheritDoc} */
81      public void setAuthnContext(AuthnContext newAuthnContext) {
82          this.authnContext = prepareForAssignment(this.authnContext, newAuthnContext);
83      }
84  
85      /** {@inheritDoc} */
86      public DateTime getAuthnInstant() {
87          return authnInstant;
88      }
89  
90      /** {@inheritDoc} */
91      public void setAuthnInstant(DateTime newAuthnInstant) {
92          this.authnInstant = prepareForAssignment(this.authnInstant, newAuthnInstant);
93      }
94  
95      /** {@inheritDoc} */
96      public String getSessionIndex() {
97          return sessionIndex;
98      }
99  
100     /** {@inheritDoc} */
101     public void setSessionIndex(String newSessionIndex) {
102         this.sessionIndex = prepareForAssignment(this.sessionIndex, newSessionIndex);
103     }
104 
105     /** {@inheritDoc} */
106     public DateTime getSessionNotOnOrAfter() {
107         return sessionNotOnOrAfter;
108     }
109 
110     /** {@inheritDoc} */
111     public void setSessionNotOnOrAfter(DateTime newSessionNotOnOrAfter) {
112         this.sessionNotOnOrAfter = prepareForAssignment(this.sessionNotOnOrAfter, newSessionNotOnOrAfter);
113     }
114 
115     /** {@inheritDoc} */
116     public List<XMLObject> getOrderedChildren() {
117         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
118 
119         children.add(subjectLocality);
120         children.add(authnContext);
121 
122         return Collections.unmodifiableList(children);
123     }
124 }