1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package edu.internet2.middleware.shibboleth.common.config.attribute.encoding;
19
20 import javax.xml.namespace.QName;
21
22 import org.opensaml.xml.util.DatatypeHelper;
23 import org.springframework.beans.factory.BeanCreationException;
24 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
25 import org.springframework.beans.factory.xml.ParserContext;
26 import org.w3c.dom.Element;
27
28 import edu.internet2.middleware.shibboleth.common.attribute.encoding.provider.SAML1ScopedStringAttributeEncoder;
29
30
31
32
33 public class SAML1ScopedStringAttributeEncoderBeanDefinitionParser extends
34 BaseScopedAttributeEncoderBeanDefinitionParser {
35
36
37 public static final QName TYPE_NAME = new QName(AttributeEncoderNamespaceHandler.NAMESPACE, "SAML1ScopedString");
38
39
40 public static final String NAMESPACE_ATTRIBUTE_NAME = "namespace";
41
42
43 protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
44 super.doParse(element, parserContext, builder);
45
46 if (element.hasAttributeNS(null, "scopeType")) {
47 builder.addPropertyValue("scopeType", element.getAttribute("scopeType"));
48 } else {
49 builder.addPropertyValue("scopeType", "attribute");
50 }
51
52 String namespace = "urn:mace:shibboleth:1.0:attributeNamespace:uri";
53 if (element.hasAttributeNS(null, "namespace")) {
54 namespace = DatatypeHelper.safeTrimOrNullString(element.getAttributeNS(null, "namespace"));
55 }
56 builder.addPropertyValue("namespace", namespace);
57
58 String attributeName = DatatypeHelper.safeTrimOrNullString(element.getAttributeNS(null, "name"));
59 if (attributeName == null) {
60 throw new BeanCreationException("SAML 1 attribute encoders must contain a name");
61 }
62 }
63
64
65 protected Class getBeanClass(Element element) {
66 return SAML1ScopedStringAttributeEncoder.class;
67 }
68
69 }