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.opensaml.common.impl.AbstractSAMLObject;
28  import org.opensaml.saml2.core.AuthenticatingAuthority;
29  import org.opensaml.saml2.core.AuthnContext;
30  import org.opensaml.saml2.core.AuthnContextClassRef;
31  import org.opensaml.saml2.core.AuthnContextDecl;
32  import org.opensaml.saml2.core.AuthnContextDeclRef;
33  import org.opensaml.xml.XMLObject;
34  import org.opensaml.xml.util.XMLObjectChildrenList;
35  
36  /**
37   * A concrete implemenation of {@link org.opensaml.saml2.core.AuthnContext}.
38   */
39  public class AuthnContextImpl extends AbstractSAMLObject implements AuthnContext {
40  
41      /** URI of the Context Class. */
42      private AuthnContextClassRef authnContextClassRef;
43  
44      /** Declaration of the Authentication Context. */
45      private AuthnContextDecl authnContextDecl;
46  
47      /** URI of the Declaration of the Authentication Context. */
48      private AuthnContextDeclRef authnContextDeclRef;
49  
50      /** List of the Authenticating Authorities. */
51      private final XMLObjectChildrenList<AuthenticatingAuthority> authenticatingAuthority;
52  
53      /**
54       * Constructor.
55       * 
56       * @param namespaceURI the namespace the element is in
57       * @param elementLocalName the local name of the XML element this Object represents
58       * @param namespacePrefix the prefix for the given namespace
59       */
60      protected AuthnContextImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
61          super(namespaceURI, elementLocalName, namespacePrefix);
62          authenticatingAuthority = new XMLObjectChildrenList<AuthenticatingAuthority>(this);
63      }
64  
65      /** {@inheritDoc} */
66      public AuthnContextClassRef getAuthnContextClassRef() {
67          return authnContextClassRef;
68      }
69  
70      /** {@inheritDoc} */
71      public void setAuthnContextClassRef(AuthnContextClassRef newAuthnContextClassRef) {
72          this.authnContextClassRef = prepareForAssignment(this.authnContextClassRef, newAuthnContextClassRef);
73      }
74  
75      /** {@inheritDoc} */
76      public AuthnContextDecl getAuthContextDecl() {
77          return authnContextDecl;
78      }
79  
80      /** {@inheritDoc} */
81      public void setAuthnContextDecl(AuthnContextDecl newAuthnContextDecl) {
82          this.authnContextDecl = prepareForAssignment(this.authnContextDecl, newAuthnContextDecl);
83      }
84  
85      /** {@inheritDoc} */
86      public AuthnContextDeclRef getAuthnContextDeclRef() {
87          return authnContextDeclRef;
88      }
89  
90      /** {@inheritDoc} */
91      public void setAuthnContextDeclRef(AuthnContextDeclRef newAuthnContextDeclRef) {
92          this.authnContextDeclRef = prepareForAssignment(this.authnContextDeclRef, newAuthnContextDeclRef);
93      }
94  
95      /** {@inheritDoc} */
96      public List<AuthenticatingAuthority> getAuthenticatingAuthorities() {
97          return authenticatingAuthority;
98      }
99  
100     /** {@inheritDoc} */
101     public List<XMLObject> getOrderedChildren() {
102         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
103 
104         children.add(authnContextClassRef);
105         children.add(authnContextDecl);
106         children.add(authnContextDeclRef);
107         children.addAll(authenticatingAuthority);
108 
109         return Collections.unmodifiableList(children);
110     }
111 }