1 /* 2 * Copyright [2006] [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.attribute.encoding; 18 19 import edu.internet2.middleware.shibboleth.common.attribute.BaseAttribute; 20 21 22 /** 23 * Attribute encoders convert {@link BaseAttribute}s into protocol specific representations. 24 * 25 * Encoders may have contain a category that can be used to distingush encoder types from 26 * each other. This inteded to be used to look up an encoder that can be used to encode 27 * attributes in accordance with a defined specification or tranmission protcol. 28 * 29 * Encoders MUST be thread-safe and stateless. 30 * 31 * @param <EncodedType> the type of object created by encoding the attribute 32 */ 33 public interface AttributeEncoder<EncodedType> { 34 35 /** 36 * Get the name of the attribute. 37 * 38 * @return name of the attribute 39 */ 40 public String getAttributeName(); 41 42 /** 43 * Sets the name of the attribute. 44 * 45 * @param attributeName name of the attribute 46 */ 47 public void setAttributeName(String attributeName); 48 49 /** 50 * Enocdes the attribute into a protocol specific representations. 51 * 52 * @param attribute the attribute to encode 53 * 54 * @return the Object the attribute was encoded into 55 * 56 * @throws AttributeEncodingException if unable to successfully encode attribute 57 */ 58 public EncodedType encode(BaseAttribute attribute) throws AttributeEncodingException; 59 }