1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package edu.internet2.middleware.shibboleth.idp.config.profile.authn;
19
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import org.opensaml.xml.util.DatatypeHelper;
24 import org.opensaml.xml.util.XMLHelper;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
28 import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
29 import org.w3c.dom.Element;
30
31 import edu.internet2.middleware.shibboleth.common.config.SpringConfigurationUtils;
32 import edu.internet2.middleware.shibboleth.idp.config.profile.ProfileHandlerNamespaceHandler;
33
34
35
36
37 public abstract class AbstractLoginHandlerBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
38
39
40 private static Logger log = LoggerFactory.getLogger(AbstractLoginHandlerBeanDefinitionParser.class);
41
42
43 protected void doParse(Element config, BeanDefinitionBuilder builder) {
44 log.debug("Parsing configuration for {} authentication handler.", XMLHelper.getXSIType(config).getLocalPart());
45
46 long duration = 30 * 60 * 1000;
47 if (config.hasAttributeNS(null, "authenticationDuration")) {
48 duration = SpringConfigurationUtils.parseDurationToMillis("'authenticationDuration' on LoginHandler of type "
49 + XMLHelper.getXSIType(config), config.getAttributeNS(null, "authenticationDuration"), 1000 * 60);
50 }
51 log.debug("Authentication duration: {}ms", duration);
52 builder.addPropertyValue("authenticationDuration", duration);
53
54 String authnMethod;
55 ArrayList<String> authnMethods = new ArrayList<String>();
56 List<Element> authnMethodElems = XMLHelper.getChildElementsByTagNameNS(config,
57 ProfileHandlerNamespaceHandler.NAMESPACE, "AuthenticationMethod");
58 for (Element authnMethodElem : authnMethodElems) {
59 authnMethod = DatatypeHelper.safeTrimOrNullString(authnMethodElem.getTextContent());
60 log.debug("Authentication handler declared support for authentication method {}", authnMethod);
61 authnMethods.add(authnMethod);
62 }
63 builder.addPropertyValue("authenticationMethods", authnMethods);
64 }
65
66
67 protected boolean shouldGenerateId() {
68 return true;
69 }
70 }