List of usage examples for org.w3c.dom Element getAttributeNS
public String getAttributeNS(String namespaceURI, String localName) throws DOMException;
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.dataConnector.RDBMSDataConnectorBeanDefinitionParser.java
/** * Processes the Column descriptor configuration elements. * //from ww w. j av a 2 s . c om * @param pluginId ID of this data connector * @param pluginConfigChildren configuration elements * @param pluginBuilder the bean definition parser * * @return result set column descriptors */ protected List<RDBMSColumnDescriptor> processColumnDescriptors(String pluginId, Map<QName, List<Element>> pluginConfigChildren, BeanDefinitionBuilder pluginBuilder) { List<RDBMSColumnDescriptor> columnDescriptors = new ArrayList<RDBMSColumnDescriptor>(); QName columnElementName = new QName(DataConnectorNamespaceHandler.NAMESPACE, "Column"); RDBMSColumnDescriptor columnDescriptor; String columnName; String attributeId; String dataType; if (pluginConfigChildren.containsKey(columnElementName)) { for (Element columnElem : pluginConfigChildren.get(columnElementName)) { columnName = columnElem.getAttributeNS(null, "columnName"); attributeId = columnElem.getAttributeNS(null, "attributeID"); if (columnElem.hasAttributeNS(null, "type")) { dataType = columnElem.getAttributeNS(null, "type"); } else { dataType = DATA_TYPES.String.toString(); } columnDescriptor = new RDBMSColumnDescriptor(columnName, attributeId, DATA_TYPES.valueOf(dataType)); columnDescriptors.add(columnDescriptor); } log.debug("Data connector {} column descriptors: {}", pluginId, columnDescriptors); } return columnDescriptors; }
From source file:com.evolveum.midpoint.prism.marshaller.JaxbDomHack.java
private ItemDefinition resolveDynamicItemDefinition(ItemDefinition parentDefinition, QName elementName, Element element, PrismContext prismContext) throws SchemaException { QName typeName = null;//from www. j av a 2s . c o m // QName elementName = null; // Set it to multi-value to be on the safe side int maxOccurs = -1; // for (Object element : valueElements) { // if (elementName == null) { // elementName = JAXBUtil.getElementQName(element); // } // TODO: try JAXB types if (element instanceof Element) { Element domElement = (Element) element; if (DOMUtil.hasXsiType(domElement)) { typeName = DOMUtil.resolveXsiType(domElement); if (typeName != null) { String maxOccursString = domElement.getAttributeNS( PrismConstants.A_MAX_OCCURS.getNamespaceURI(), PrismConstants.A_MAX_OCCURS.getLocalPart()); if (!StringUtils.isBlank(maxOccursString)) { // TODO // maxOccurs = parseMultiplicity(maxOccursString, elementName); } // break; } } } // } // FIXME: now the definition assumes property, may also be property // container? if (typeName == null) { return null; } PrismPropertyDefinitionImpl propDef = new PrismPropertyDefinitionImpl(elementName, typeName, prismContext); propDef.setMaxOccurs(maxOccurs); propDef.setDynamic(true); return propDef; }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.filtering.AttributeFilterPolicyBeanDefinitionParser.java
/** {@inheritDoc} */ protected String resolveId(Element configElement, AbstractBeanDefinition beanDefinition, ParserContext parserContext) {//from w w w.j ava2s .c o m if (!configElement.hasAttributeNS(null, "id")) { log.warn( "AttributeFilterPolicy elements should include an 'id' attribute. This is not currently required but will be in future versions."); } return getQualifiedId(configElement, configElement.getLocalName(), configElement.getAttributeNS(null, "id")); }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.dataConnector.LdapDataConnectorBeanDefinitionParser.java
/** * Processes the LDAP properties provided in the configuration. * /*from www. j ava 2 s .c o m*/ * @param propertyElems LDAP properties provided in the configuration * * @return LDAP properties provided in the configuration */ protected Map<String, String> processLDAPProperties(List<Element> propertyElems) { if (propertyElems == null || propertyElems.size() == 0) { return null; } HashMap<String, String> properties = new HashMap<String, String>(5); String propName; String propValue; for (Element propertyElem : propertyElems) { propName = DatatypeHelper.safeTrimOrNullString(propertyElem.getAttributeNS(null, "name")); propValue = DatatypeHelper.safeTrimOrNullString(propertyElem.getAttributeNS(null, "value")); properties.put(propName, propValue); } return properties; }
From source file:edu.internet2.middleware.shibboleth.idp.config.profile.authn.AbstractLoginHandlerBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(Element config, BeanDefinitionBuilder builder) { log.debug("Parsing configuration for {} authentication handler.", XMLHelper.getXSIType(config).getLocalPart()); long duration = 30 * 60 * 1000; if (config.hasAttributeNS(null, "authenticationDuration")) { duration = SpringConfigurationUtils.parseDurationToMillis( "'authenticationDuration' on LoginHandler of type " + XMLHelper.getXSIType(config), config.getAttributeNS(null, "authenticationDuration"), 1000 * 60); }/*w ww. j av a2 s .c o m*/ log.debug("Authentication duration: {}ms", duration); builder.addPropertyValue("authenticationDuration", duration); String authnMethod; ArrayList<String> authnMethods = new ArrayList<String>(); List<Element> authnMethodElems = XMLHelper.getChildElementsByTagNameNS(config, ProfileHandlerNamespaceHandler.NAMESPACE, "AuthenticationMethod"); for (Element authnMethodElem : authnMethodElems) { authnMethod = DatatypeHelper.safeTrimOrNullString(authnMethodElem.getTextContent()); log.debug("Authentication handler declared support for authentication method {}", authnMethod); authnMethods.add(authnMethod); } builder.addPropertyValue("authenticationMethods", authnMethods); }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.attributeDefinition.CryptoTransientIdAttributeDefinitionBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(String pluginId, Element pluginConfig, Map<QName, List<Element>> pluginConfigChildren, BeanDefinitionBuilder pluginBuilder, ParserContext parserContext) { super.doParse(pluginId, pluginConfig, pluginConfigChildren, pluginBuilder, parserContext); if (pluginConfig.hasAttributeNS(null, "lifetime")) { long lifetime = SpringConfigurationUtils.parseDurationToMillis( "'lifetime' on AttributeDefinition of type " + XMLHelper.getXSIType(pluginConfig), pluginConfig.getAttributeNS(null, "lifetime"), 1000 * 60); pluginBuilder.addPropertyValue("idLifetime", lifetime); }/*from w ww. jav a 2 s .c om*/ pluginBuilder.addPropertyReference("dataSealer", DatatypeHelper.safeTrimOrNullString(pluginConfig.getAttributeNS(null, "dataSealerRef"))); }
From source file:net.shibboleth.idp.profile.spring.relyingparty.metadata.impl.AbstractDynamicHTTPMetadataProviderParser.java
/** * Build the definition of the HTTPClientBuilder which contains all our configuration. * /*from w w w. j a v a 2 s. c o m*/ * @param element the HTTPMetadataProvider parser. * @param parserContext thee context * @param haveTLSTrustEngine whether have a TLS TrustEngine configured * @return the bean definition with the parameters. */ // Checkstyle: CyclomaticComplexity OFF // Checkstyle: MethodLength OFF private BeanDefinition buildHttpClient(Element element, ParserContext parserContext, boolean haveTLSTrustEngine) { String caching = DEFAULT_CACHING; if (element.hasAttributeNS(null, "httpCaching")) { caching = StringSupport.trimOrNull(element.getAttributeNS(null, "httpCaching")); } BeanDefinitionBuilder clientBuilder = null; switch (caching) { case "none": clientBuilder = BeanDefinitionBuilder.genericBeanDefinition(HttpClientFactoryBean.class); break; case "file": clientBuilder = BeanDefinitionBuilder.genericBeanDefinition(FileCachingHttpClientFactoryBean.class); if (element.hasAttributeNS(null, "httpCacheDirectory")) { clientBuilder.addPropertyValue("cacheDirectory", StringSupport.trimOrNull(element.getAttributeNS(null, "httpCacheDirectory"))); } if (element.hasAttributeNS(null, "httpMaxCacheEntries")) { clientBuilder.addPropertyValue("maxCacheEntries", StringSupport.trimOrNull(element.getAttributeNS(null, "httpMaxCacheEntries"))); } if (element.hasAttributeNS(null, "httpMaxCacheEntrySize")) { clientBuilder.addPropertyValue("maxCacheEntrySize", StringSupport.trimOrNull(element.getAttributeNS(null, "httpMaxCacheEntrySize"))); } break; case "memory": clientBuilder = BeanDefinitionBuilder.genericBeanDefinition(InMemoryCachingHttpClientFactoryBean.class); if (element.hasAttributeNS(null, "httpMaxCacheEntries")) { clientBuilder.addPropertyValue("maxCacheEntries", StringSupport.trimOrNull(element.getAttributeNS(null, "httpMaxCacheEntries"))); } if (element.hasAttributeNS(null, "httpMaxCacheEntrySize")) { clientBuilder.addPropertyValue("maxCacheEntrySize", StringSupport.trimOrNull(element.getAttributeNS(null, "httpMaxCacheEntrySize"))); } break; default: throw new BeanDefinitionParsingException( new Problem(String.format("Caching value '%s' is unsupported", caching), new Location(parserContext.getReaderContext().getResource()))); } clientBuilder.setLazyInit(true); if (element.hasAttributeNS(null, "requestTimeout")) { clientBuilder.addPropertyValue("connectionTimeout", StringSupport.trimOrNull(element.getAttributeNS(null, "requestTimeout"))); } if (haveTLSTrustEngine) { clientBuilder.addPropertyValue("tLSSocketFactory", new SecurityEnhancedTLSSocketFactory( HttpClientSupport.buildNoTrustTLSSocketFactory(), new StrictHostnameVerifier())); } if (element.hasAttributeNS(null, "disregardTLSCertificate")) { clientBuilder.addPropertyValue("connectionDisregardTLSCertificate", StringSupport.trimOrNull(element.getAttributeNS(null, "disregardTLSCertificate"))); } else if (element.hasAttributeNS(null, "disregardSslCertificate")) { log.warn("disregardSslCertificate is deprecated, please switch to disregardTLSCertificate"); clientBuilder.addPropertyValue("connectionDisregardTLSCertificate", StringSupport.trimOrNull(element.getAttributeNS(null, "disregardSslCertificate"))); } if (element.hasAttributeNS(null, "proxyHost")) { clientBuilder.addPropertyValue("connectionProxyHost", StringSupport.trimOrNull(element.getAttributeNS(null, "proxyHost"))); } if (element.hasAttributeNS(null, "proxyPort")) { clientBuilder.addPropertyValue("connectionProxyPort", StringSupport.trimOrNull(element.getAttributeNS(null, "proxyPort"))); } if (element.hasAttributeNS(null, "proxyUser")) { clientBuilder.addPropertyValue("connectionProxyUsername", StringSupport.trimOrNull(element.getAttributeNS(null, "proxyUser"))); } if (element.hasAttributeNS(null, "proxyPassword")) { clientBuilder.addPropertyValue("connectionProxyPassword", element.getAttributeNS(null, "proxyPassword")); } return clientBuilder.getBeanDefinition(); }
From source file:edu.internet2.middleware.shibboleth.common.config.metadata.HTTPMetadataProviderBeanDefinitionParser.java
/** * Builds the HTTP client used to fetch metadata. * //from w w w . j a va 2 s . com * @param config the metadata provider configuration element * @param providerId the ID of the metadata provider * @param metadataURL the URL from which metadata will be fetched * * @return the constructed HTTP client */ protected HttpClient buildHttpClient(Element config, String providerId, URL metadataURL) { HttpClientBuilder builder = new HttpClientBuilder(); int requestTimeout = 5000; if (config.hasAttributeNS(null, "requestTimeout")) { requestTimeout = (int) SpringConfigurationUtils.parseDurationToMillis( "'requestTimeout' on metadata provider " + providerId, config.getAttributeNS(null, "requestTimeout"), 0); } log.debug("Metadata provider '{}' HTTP request timeout: {}ms", providerId, requestTimeout); builder.setConnectionTimeout(requestTimeout); if (metadataURL.getProtocol().equalsIgnoreCase("https")) { boolean disregardSslCertificate = false; if (config.hasAttributeNS(null, "disregardSslCertificate")) { disregardSslCertificate = XMLHelper .getAttributeValueAsBoolean(config.getAttributeNodeNS(null, "disregardSslCertificate")); } log.debug("Metadata provider '{}' disregards server SSL certificate: {}", providerId, disregardSslCertificate); if (disregardSslCertificate) { builder.setHttpsProtocolSocketFactory( new TLSProtocolSocketFactory(null, buildNoTrustTrustManager())); } } setHttpProxySettings(builder, config, providerId); HttpClient httpClient = builder.buildClient(); setHttpBasicAuthSettings(httpClient, config, providerId, metadataURL); return httpClient; }
From source file:edu.internet2.middleware.assurance.mcb.config.profile.authn.MCBLoginHandlerBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(Element config, BeanDefinitionBuilder builder) { super.doParse(config, builder); if (config.hasAttributeNS(null, "previousSession")) { builder.addPropertyValue("previousSession", XMLHelper.getAttributeValueAsBoolean(config.getAttributeNodeNS(null, "previousSession"))); } else {//w w w . j a v a 2 s . c o m builder.addPropertyValue("previousSession", false); } if (config.hasAttributeNS(null, "depends-on")) { builder.addPropertyValue("dependsOn", DatatypeHelper.safeTrim(config.getAttributeNS(null, "depends-on"))); } else { builder.addPropertyValue("dependsOn", null); } }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.dataConnector.RDBMSDataConnectorBeanDefinitionParser.java
/** * Builds a JDBC {@link javax.sql.DataSource} from an ApplicationManagedConnection configuration element. * /*from w w w . j a va 2s.c o m*/ * @param pluginId ID of this data connector * @param amc the application managed configuration element * * @return the built data source */ protected DataSource buildApplicationManagedConnection(String pluginId, Element amc) { ComboPooledDataSource datasource = new ComboPooledDataSource(); String driverClass = DatatypeHelper.safeTrim(amc.getAttributeNS(null, "jdbcDriver")); ClassLoader classLoader = this.getClass().getClassLoader(); try { classLoader.loadClass(driverClass); } catch (ClassNotFoundException e) { log.error( "Unable to create relational database connector, JDBC driver can not be found on the classpath"); throw new BeanCreationException( "Unable to create relational database connector, JDBC driver can not be found on the classpath"); } try { datasource.setDriverClass(driverClass); datasource.setJdbcUrl(DatatypeHelper.safeTrim(amc.getAttributeNS(null, "jdbcURL"))); datasource.setUser(DatatypeHelper.safeTrim(amc.getAttributeNS(null, "jdbcUserName"))); datasource.setPassword(DatatypeHelper.safeTrim(amc.getAttributeNS(null, "jdbcPassword"))); if (amc.hasAttributeNS(null, "poolAcquireIncrement")) { datasource.setAcquireIncrement(Integer .parseInt(DatatypeHelper.safeTrim(amc.getAttributeNS(null, "poolAcquireIncrement")))); } else { datasource.setAcquireIncrement(3); } if (amc.hasAttributeNS(null, "poolAcquireRetryAttempts")) { datasource.setAcquireRetryAttempts(Integer .parseInt(DatatypeHelper.safeTrim(amc.getAttributeNS(null, "poolAcquireRetryAttempts")))); } else { datasource.setAcquireRetryAttempts(36); } if (amc.hasAttributeNS(null, "poolAcquireRetryDelay")) { datasource.setAcquireRetryDelay(Integer .parseInt(DatatypeHelper.safeTrim(amc.getAttributeNS(null, "poolAcquireRetryDelay")))); } else { datasource.setAcquireRetryDelay(5000); } if (amc.hasAttributeNS(null, "poolBreakAfterAcquireFailure")) { datasource.setBreakAfterAcquireFailure(XMLHelper .getAttributeValueAsBoolean(amc.getAttributeNodeNS(null, "poolBreakAfterAcquireFailure"))); } else { datasource.setBreakAfterAcquireFailure(true); } if (amc.hasAttributeNS(null, "poolMinSize")) { datasource.setMinPoolSize( Integer.parseInt(DatatypeHelper.safeTrim(amc.getAttributeNS(null, "poolMinSize")))); } else { datasource.setMinPoolSize(2); } if (amc.hasAttributeNS(null, "poolMaxSize")) { datasource.setMaxPoolSize( Integer.parseInt(DatatypeHelper.safeTrim(amc.getAttributeNS(null, "poolMaxSize")))); } else { datasource.setMaxPoolSize(50); } if (amc.hasAttributeNS(null, "poolMaxIdleTime")) { datasource.setMaxIdleTime( Integer.parseInt(DatatypeHelper.safeTrim(amc.getAttributeNS(null, "poolMaxIdleTime")))); } else { datasource.setMaxIdleTime(600); } if (amc.hasAttributeNS(null, "poolIdleTestPeriod")) { datasource.setIdleConnectionTestPeriod( Integer.parseInt(DatatypeHelper.safeTrim(amc.getAttributeNS(null, "poolIdleTestPeriod")))); } else { datasource.setIdleConnectionTestPeriod(180); } log.debug("Created application managed data source for data connector {}", pluginId); return datasource; } catch (PropertyVetoException e) { log.error("Unable to create data source for data connector {} with JDBC driver class {}", pluginId, driverClass); return null; } }