View Javadoc

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