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.dataConnector; 18 19 import javax.sql.DataSource; 20 21 import edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector.StoredIDDataConnector; 22 23 /** Spring factory bean for {@link StoredIDDataConnector}s. */ 24 public class StoredIDDataConnectorBeanFactory extends BaseDataConnectorFactoryBean { 25 26 /** Datasource used to communicate with database. */ 27 private DataSource datasource; 28 29 /** ID of the attribute generated by the connector. */ 30 private String generatedAttribute; 31 32 /** ID of the attribute whose first value is used when generating the computed ID. */ 33 private String sourceAttribute; 34 35 /** Salt used when computing the ID. */ 36 private byte[] salt; 37 38 /** {@inheritDoc} */ 39 public Class getObjectType() { 40 return StoredIDDataConnector.class; 41 } 42 43 /** 44 * Gets the datasource used to communicate with database. 45 * 46 * @return datasource used to communicate with database 47 */ 48 public DataSource getDatasource() { 49 return datasource; 50 } 51 52 /** 53 * Sets the datasource used to communicate with database. 54 * 55 * @param source datasource used to communicate with database 56 */ 57 public void setDatasource(DataSource source) { 58 datasource = source; 59 } 60 61 /** 62 * Gets the ID of the attribute generated by the connector. 63 * 64 * @return ID of the attribute generated by the connector 65 */ 66 public String getGeneratedAttribute() { 67 return generatedAttribute; 68 } 69 70 /** 71 * Sets the ID of the attribute generated by the connector. 72 * 73 * @param id ID of the attribute generated by the connector 74 */ 75 public void setGeneratedAttribute(String id) { 76 generatedAttribute = id; 77 } 78 79 /** 80 * Gets the ID of the attribute whose first value is used when generating the computed ID. 81 * 82 * @return ID of the attribute whose first value is used when generating the computed ID 83 */ 84 public String getSourceAttribute() { 85 return sourceAttribute; 86 } 87 88 /** 89 * Sets the ID of the attribute whose first value is used when generating the computed ID. 90 * 91 * @param id ID of the attribute whose first value is used when generating the computed ID 92 */ 93 public void setSourceAttribute(String id) { 94 this.sourceAttribute = id; 95 } 96 97 /** 98 * Gets the salt used when computing the ID. 99 * 100 * @return salt used when computing the ID 101 */ 102 public byte[] getSalt() { 103 return salt; 104 } 105 106 /** 107 * Sets the salt used when computing the ID. 108 * 109 * @param salt salt used when computing the ID 110 */ 111 public void setSalt(byte[] salt) { 112 this.salt = salt; 113 } 114 115 /** {@inheritDoc} */ 116 protected Object createInstance() throws Exception { 117 StoredIDDataConnector connector = new StoredIDDataConnector(getDatasource(), getGeneratedAttribute(), 118 getSourceAttribute(), getSalt()); 119 populateDataConnector(connector); 120 return connector; 121 } 122 }