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.config.attribute.resolver.principalConnector;
19  
20  import edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector.StoredIDDataConnector;
21  import edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.principalConnector.StoredIDPrincipalConnector;
22  import edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.principalConnector.TransientPrincipalConnector;
23  
24  /**
25   * Spring factory bean for {@link TransientPrincipalConnector}s.
26   */
27  public class StoredIDPrincipalConnectorFactoryBean extends BasePrincipalConnectorFactoryBean {
28  
29      /** Data connector that produced the ID. */
30      private StoredIDDataConnector idProducer;
31  
32      /** Whether an empty result set is an error. */
33      private boolean noResultsIsError;
34  
35      /** {@inheritDoc} */
36      public Class getObjectType() {
37          return StoredIDPrincipalConnector.class;
38      }
39  
40      /**
41       * This returns whether this connector will throw an exception if no search results are found. The default is false.
42       * 
43       * @return <code>boolean</code>
44       */
45      public boolean isNoResultIsError() {
46          return noResultsIsError;
47      }
48  
49      /**
50       * This sets whether this connector will throw an exception if no search results are found.
51       * 
52       * @param b <code>boolean</code>
53       */
54      public void setNoResultIsError(boolean b) {
55          noResultsIsError = b;
56      }
57  
58      /**
59       * Gets the data connector that produced the ID.
60       * 
61       * @return data connector that produced the ID
62       */
63      public StoredIDDataConnector getIdProducer() {
64          return idProducer;
65      }
66  
67      /**
68       * Sets the data connector that produced the ID.
69       * 
70       * @param producer data connector that produced the ID
71       */
72      public void setIdProducer(StoredIDDataConnector producer) {
73          idProducer = producer;
74      }
75  
76      /** {@inheritDoc} */
77      protected Object createInstance() throws Exception {
78          StoredIDPrincipalConnector connector = new StoredIDPrincipalConnector(getIdProducer());
79          populatePrincipalConnector(connector);
80          connector.setNoResultIsError(isNoResultIsError());
81  
82          return connector;
83      }
84  }