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