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.xmlobject.impl;
19  
20  import java.util.List;
21  import java.util.regex.Pattern;
22  
23  import org.opensaml.xml.XMLObject;
24  import org.opensaml.xml.schema.XSBooleanValue;
25  import org.opensaml.xml.validation.AbstractValidatingXMLObject;
26  
27  import edu.internet2.middleware.shibboleth.common.xmlobject.ShibbolethMetadataScope;
28  
29  /**
30   * Implementation of {@link ShibbolethMetadataScope}.
31   */
32  public class ShibbolethMetadataScopeImpl extends AbstractValidatingXMLObject implements ShibbolethMetadataScope {
33  
34      /** The regexp attribute value. */
35      private XSBooleanValue regexp;
36  
37      /** The string content value. */
38      private String scopeValue;
39  
40      /** Pattern used to match scopes against criteria. */
41      private Pattern matchPattern;
42  
43      /**
44       * Constructor.
45       * 
46       * @param namespaceURI the namespace the element is in
47       * @param elementLocalName the local name of the XML element this Object represents
48       * @param namespacePrefix the prefix for the given namespace
49       */
50      protected ShibbolethMetadataScopeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
51          super(namespaceURI, elementLocalName, namespacePrefix);
52          regexp = null;
53      }
54  
55      /** {@inheritDoc} */
56      public Boolean getRegexp() {
57          if (regexp == null) {
58              return Boolean.FALSE;
59          }
60          return regexp.getValue();
61      }
62  
63      /** {@inheritDoc} */
64      public void setRegexp(Boolean newRegexp) {
65          if (newRegexp != null) {
66              regexp = prepareForAssignment(regexp, new XSBooleanValue(newRegexp, false));
67          } else {
68              regexp = prepareForAssignment(regexp, null);
69          }
70      }
71  
72      /** {@inheritDoc} */
73      public XSBooleanValue getRegexpXSBoolean() {
74          return regexp;
75      }
76  
77      /** {@inheritDoc} */
78      public void setRegexp(XSBooleanValue newRegexp) {
79          regexp = prepareForAssignment(regexp, newRegexp);
80      }
81  
82      /** {@inheritDoc} */
83      public String getValue() {
84          return scopeValue;
85      }
86  
87      /** {@inheritDoc} */
88      public void setValue(String newScopeValue) {
89          scopeValue = prepareForAssignment(scopeValue, newScopeValue);
90          matchPattern = Pattern.compile(scopeValue);
91      }
92  
93      /** {@inheritDoc} */
94      public Pattern getMatchPattern() {
95          return matchPattern;
96      }
97  
98      /** {@inheritDoc} */
99      public List<XMLObject> getOrderedChildren() {
100         return null;
101     }
102 }