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  package org.opensaml.saml1.core.impl;
18  
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import org.joda.time.DateTime;
24  import org.opensaml.saml1.core.AuthenticationStatement;
25  import org.opensaml.saml1.core.AuthorityBinding;
26  import org.opensaml.saml1.core.SubjectLocality;
27  import org.opensaml.xml.XMLObject;
28  import org.opensaml.xml.util.XMLObjectChildrenList;
29  
30  /**
31   * A Concrete implementation of the {@link org.opensaml.saml1.core.AuthenticationStatement} Interface
32   */
33  public class AuthenticationStatementImpl extends SubjectStatementImpl implements AuthenticationStatement {
34  
35      /** Contains the AuthenticationMethod attribute contents */
36      private String authenticationMethod;
37  
38      /** Contains the AuthenticationMethod attribute contents */
39      private DateTime authenticationInstant;
40  
41      /** Contains the SubjectLocality subelement */
42      private SubjectLocality subjectLocality;
43  
44      /** Contains the AuthorityBinding subelements */
45      private final XMLObjectChildrenList<AuthorityBinding> authorityBindings;
46  
47      /**
48       * Constructor.
49       * 
50       * @param namespaceURI the namespace the element is in
51       * @param elementLocalName the local name of the XML element this Object represents
52       * @param namespacePrefix the prefix for the given namespace
53       */
54      protected AuthenticationStatementImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
55          super(namespaceURI, elementLocalName, namespacePrefix);
56          authorityBindings = new XMLObjectChildrenList<AuthorityBinding>(this);
57      }
58  
59      /** {@inheritDoc} */
60      public String getAuthenticationMethod() {
61          return authenticationMethod;
62      }
63  
64      /** {@inheritDoc} */
65      public void setAuthenticationMethod(String authenticationMethod) {
66          this.authenticationMethod = prepareForAssignment(this.authenticationMethod, authenticationMethod);
67      }
68  
69      /** {@inheritDoc} */
70      public DateTime getAuthenticationInstant() {
71          return authenticationInstant;
72      }
73  
74      /** {@inheritDoc} */
75      public void setAuthenticationInstant(DateTime authenticationInstant) {
76          this.authenticationInstant = prepareForAssignment(this.authenticationInstant, authenticationInstant);
77      }
78  
79      //
80      // Elements
81      //
82  
83      /** {@inheritDoc} */
84      public SubjectLocality getSubjectLocality() {
85          return subjectLocality;
86      }
87  
88      /** {@inheritDoc} */
89      public void setSubjectLocality(SubjectLocality subjectLocality) throws IllegalArgumentException {
90          this.subjectLocality = prepareForAssignment(this.subjectLocality, subjectLocality);
91      }
92  
93      /** {@inheritDoc} */
94      public List<AuthorityBinding> getAuthorityBindings() {
95          return authorityBindings;
96      }
97  
98      /** {@inheritDoc} */
99      public List<XMLObject> getOrderedChildren() {
100         List<XMLObject> list = new ArrayList<XMLObject>(authorityBindings.size() + 2);
101 
102         if (super.getOrderedChildren() != null) {
103             list.addAll(super.getOrderedChildren());
104         }
105 
106         if (subjectLocality != null) {
107             list.add(subjectLocality);
108         }
109 
110         list.addAll(authorityBindings);
111 
112         if (list.size() == 0) {
113             return null;
114         }
115 
116         return Collections.unmodifiableList(list);
117     }
118 }