List of usage examples for org.w3c.dom Element getAttributeNodeNS
public Attr getAttributeNodeNS(String namespaceURI, String localName) throws DOMException;
Attr
node by local name and namespace URI. From source file:edu.washington.shibboleth.attribute.resolver.spring.dc.rws.RwsDataConnectorParser.java
/** * Parse attribute requirements// w ww. j a v a 2 s . c om * * @param elements DOM elements of type <code>Attribute</code> * * @return the attributes */ protected List<RwsAttribute> parseAttributes(List<Element> elements) { if (elements == null || elements.size() == 0) { return null; } List<RwsAttribute> rwsAttributes = new Vector<RwsAttribute>(); for (Element ele : elements) { RwsAttribute rwsAttribute = new RwsAttribute(); rwsAttribute.name = StringSupport.trimOrNull(ele.getAttributeNS(null, "name")); log.debug("parseattribute: " + rwsAttribute.name); System.out.println("parseattribute: " + rwsAttribute.name); rwsAttribute.xPath = StringSupport.trimOrNull(ele.getAttributeNS(null, "xPath")); rwsAttribute.maxResultSize = 1; if (ele.hasAttributeNS(null, "maxResultSize")) { rwsAttribute.maxResultSize = Integer.parseInt(ele.getAttributeNS(null, "maxResultSize")); } boolean noResultsIsError = false; if (ele.hasAttributeNS(null, "noResultIsError")) { rwsAttribute.noResultIsError = AttributeSupport .getAttributeValueAsBoolean(ele.getAttributeNodeNS(null, "noResultIsError")); } rwsAttributes.add(rwsAttribute); } return rwsAttributes; }
From source file:edu.internet2.middleware.shibboleth.common.config.security.saml.IssueInstantRuleBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(Element element, BeanDefinitionBuilder builder) { long skew = 300; if (element.hasAttributeNS(null, "clockSkew")) { skew = SpringConfigurationUtils.parseDurationToMillis( "'clockSkew' on security rule of type " + XMLHelper.getXSIType(element), element.getAttributeNS(null, "clockSkew"), 1000) / 1000; }//from w w w . j a va 2 s. co m builder.addConstructorArgValue(skew); long expirationThreshold = 60; if (element.hasAttributeNS(null, "expirationThreshold")) { expirationThreshold = SpringConfigurationUtils.parseDurationToMillis( "'expirationThreshold' on security rule of type " + XMLHelper.getXSIType(element), element.getAttributeNS(null, "expirationThreshold"), 1000) / 1000; } builder.addConstructorArgValue(expirationThreshold); if (element.hasAttributeNS(null, "required")) { builder.addPropertyValue("requiredRule", XMLHelper.getAttributeValueAsBoolean(element.getAttributeNodeNS(null, "required"))); } else { builder.addPropertyValue("requiredRule", true); } }
From source file:edu.internet2.middleware.shibboleth.common.config.metadata.HTTPMetadataProviderBeanDefinitionParser.java
/** * Builds the HTTP client used to fetch metadata. * //w w w . j a v a2s. 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:com.microsoft.windowsazure.management.sql.ServerOperationsImpl.java
/** * Provisions a new SQL Database server in a subscription. * * @param parameters Required. The parameters needed to provision a server. * @throws ParserConfigurationException Thrown if there was an error * configuring the parser for the response body. * @throws SAXException Thrown if there was an error parsing the response * body.//from ww w . ja v a 2 s . co m * @throws TransformerException Thrown if there was an error creating the * DOM transformer. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @return The response returned from the Create Server operation. This * contains all the information returned from the service when a server is * created. */ @Override public ServerCreateResponse create(ServerCreateParameters parameters) throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException { // Validate if (parameters == null) { throw new NullPointerException("parameters"); } if (parameters.getAdministratorPassword() == null) { throw new NullPointerException("parameters.AdministratorPassword"); } if (parameters.getAdministratorUserName() == null) { throw new NullPointerException("parameters.AdministratorUserName"); } if (parameters.getLocation() == null) { throw new NullPointerException("parameters.Location"); } // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); tracingParameters.put("parameters", parameters); CloudTracing.enter(invocationId, this, "createAsync", tracingParameters); } // Construct URL String url = ""; url = url + "/"; if (this.getClient().getCredentials().getSubscriptionId() != null) { url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8"); } url = url + "/services/sqlservers/servers"; String baseUrl = this.getClient().getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpPost httpRequest = new HttpPost(url); // Set Headers httpRequest.setHeader("Content-Type", "application/xml"); httpRequest.setHeader("x-ms-version", "2012-03-01"); // Serialize Request String requestContent = null; DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document requestDoc = documentBuilder.newDocument(); Element serverElement = requestDoc.createElementNS("http://schemas.microsoft.com/sqlazure/2010/12/", "Server"); requestDoc.appendChild(serverElement); Element administratorLoginElement = requestDoc .createElementNS("http://schemas.microsoft.com/sqlazure/2010/12/", "AdministratorLogin"); administratorLoginElement.appendChild(requestDoc.createTextNode(parameters.getAdministratorUserName())); serverElement.appendChild(administratorLoginElement); Element administratorLoginPasswordElement = requestDoc .createElementNS("http://schemas.microsoft.com/sqlazure/2010/12/", "AdministratorLoginPassword"); administratorLoginPasswordElement .appendChild(requestDoc.createTextNode(parameters.getAdministratorPassword())); serverElement.appendChild(administratorLoginPasswordElement); Element locationElement = requestDoc.createElementNS("http://schemas.microsoft.com/sqlazure/2010/12/", "Location"); locationElement.appendChild(requestDoc.createTextNode(parameters.getLocation())); serverElement.appendChild(locationElement); if (parameters.getVersion() != null) { Element versionElement = requestDoc.createElementNS("http://schemas.microsoft.com/sqlazure/2010/12/", "Version"); versionElement.appendChild(requestDoc.createTextNode(parameters.getVersion())); serverElement.appendChild(versionElement); } DOMSource domSource = new DOMSource(requestDoc); StringWriter stringWriter = new StringWriter(); StreamResult streamResult = new StreamResult(stringWriter); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); transformer.transform(domSource, streamResult); requestContent = stringWriter.toString(); StringEntity entity = new StringEntity(requestContent); httpRequest.setEntity(entity); httpRequest.setHeader("Content-Type", "application/xml"); // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_CREATED) { ServiceException ex = ServiceException.createFromXml(httpRequest, requestContent, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result ServerCreateResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_CREATED) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new ServerCreateResponse(); DocumentBuilderFactory documentBuilderFactory2 = DocumentBuilderFactory.newInstance(); documentBuilderFactory2.setNamespaceAware(true); DocumentBuilder documentBuilder2 = documentBuilderFactory2.newDocumentBuilder(); Document responseDoc = documentBuilder2.parse(new BOMInputStream(responseContent)); Element serverNameElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://schemas.microsoft.com/sqlazure/2010/12/", "ServerName"); if (serverNameElement != null) { Attr fullyQualifiedDomainNameAttribute = serverNameElement.getAttributeNodeNS( "http://schemas.microsoft.com/sqlazure/2010/12/", "FullyQualifiedDomainName"); if (fullyQualifiedDomainNameAttribute != null) { result.setFullyQualifiedDomainName(fullyQualifiedDomainNameAttribute.getValue()); } result.setServerName(serverNameElement.getTextContent()); } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:com.microsoft.windowsazure.management.websites.WebSiteOperationsImpl2.java
@Override public WebSiteGetPublishProfileResponse getPublishProfile(String webSpaceName, String webSiteName) throws IOException, ServiceException, ParserConfigurationException, SAXException, URISyntaxException { // Validate/*from w w w. ja va2s . c o m*/ if (webSpaceName == null) { throw new NullPointerException("webSpaceName"); } if (webSiteName == null) { throw new NullPointerException("webSiteName"); } // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); tracingParameters.put("webSpaceName", webSpaceName); tracingParameters.put("webSiteName", webSiteName); CloudTracing.enter(invocationId, this, "getPublishProfileAsync", tracingParameters); } // Construct URL String url = "/" + (this.getClient().getCredentials().getSubscriptionId() != null ? this.getClient().getCredentials().getSubscriptionId().trim() : "") + "/services/WebSpaces/" + webSpaceName.trim() + "/sites/" + webSiteName.trim() + "/publishxml"; String baseUrl = this.getClient().getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpGet httpRequest = new HttpGet(url); // Set Headers httpRequest.setHeader("x-ms-version", "2014-04-01"); // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { ServiceException ex = ServiceException.createFromXml(httpRequest, null, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result WebSiteGetPublishProfileResponse result = null; // Deserialize Response InputStream responseContent = httpResponse.getEntity().getContent(); result = new WebSiteGetPublishProfileResponse(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent)); Element publishDataElement = XmlUtility.getElementByTagNameNS(responseDoc, "", "publishData"); if (publishDataElement != null) { if (publishDataElement != null) { for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(publishDataElement, "", "publishProfile").size(); i1 = i1 + 1) { org.w3c.dom.Element publishProfilesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(publishDataElement, "", "publishProfile").get(i1)); WebSiteGetPublishProfileResponse.PublishProfile publishProfileInstance = new WebSiteGetPublishProfileResponse.PublishProfile(); result.getPublishProfiles().add(publishProfileInstance); Attr profileNameAttribute = publishProfilesElement.getAttributeNodeNS(null, "profileName"); if (profileNameAttribute != null) { publishProfileInstance.setProfileName(profileNameAttribute.getValue()); } Attr publishMethodAttribute = publishProfilesElement.getAttributeNodeNS(null, "publishMethod"); if (publishMethodAttribute != null) { publishProfileInstance.setPublishMethod(publishMethodAttribute.getValue()); } Attr publishUrlAttribute = publishProfilesElement.getAttributeNodeNS(null, "publishUrl"); if (publishUrlAttribute != null) { publishProfileInstance.setPublishUrl(publishUrlAttribute.getValue()); } Attr msdeploySiteAttribute = publishProfilesElement.getAttributeNodeNS(null, "msdeploySite"); if (msdeploySiteAttribute != null) { publishProfileInstance.setMSDeploySite(msdeploySiteAttribute.getValue()); } Attr ftpPassiveModeAttribute = publishProfilesElement.getAttributeNodeNS(null, "ftpPassiveMode"); if (ftpPassiveModeAttribute != null) { publishProfileInstance.setFtpPassiveMode(DatatypeConverter .parseBoolean(ftpPassiveModeAttribute.getValue().toLowerCase())); } Attr userNameAttribute = publishProfilesElement.getAttributeNodeNS(null, "userName"); if (userNameAttribute != null) { publishProfileInstance.setUserName(userNameAttribute.getValue()); } Attr userPWDAttribute = publishProfilesElement.getAttributeNodeNS(null, "userPWD"); if (userPWDAttribute != null) { publishProfileInstance.setUserPassword(userPWDAttribute.getValue()); } Attr destinationAppUrlAttribute = publishProfilesElement.getAttributeNodeNS(null, "destinationAppUrl"); if (destinationAppUrlAttribute != null) { publishProfileInstance .setDestinationAppUri(new URI(destinationAppUrlAttribute.getValue())); } Attr sQLServerDBConnectionStringAttribute = publishProfilesElement.getAttributeNodeNS(null, "SQLServerDBConnectionString"); if (sQLServerDBConnectionStringAttribute != null) { publishProfileInstance .setSqlServerConnectionString(sQLServerDBConnectionStringAttribute.getValue()); } Attr mySQLDBConnectionStringAttribute = publishProfilesElement.getAttributeNodeNS(null, "mySQLDBConnectionString"); if (mySQLDBConnectionStringAttribute != null) { publishProfileInstance .setMySqlConnectionString(mySQLDBConnectionStringAttribute.getValue()); } Attr hostingProviderForumLinkAttribute = publishProfilesElement.getAttributeNodeNS(null, "hostingProviderForumLink"); if (hostingProviderForumLinkAttribute != null) { publishProfileInstance.setHostingProviderForumUri( new URI(hostingProviderForumLinkAttribute.getValue())); } Attr controlPanelLinkAttribute = publishProfilesElement.getAttributeNodeNS(null, "controlPanelLink"); if (controlPanelLinkAttribute != null) { publishProfileInstance .setControlPanelUri(new URI(controlPanelLinkAttribute.getValue())); } Element databasesSequenceElement = XmlUtility.getElementByTagNameNS(publishProfilesElement, "", "databases"); if (databasesSequenceElement != null) { for (int i2 = 0; i2 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(databasesSequenceElement, "", "add") .size(); i2 = i2 + 1) { org.w3c.dom.Element databasesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(databasesSequenceElement, "", "add").get(i2)); WebSiteGetPublishProfileResponse.Database addInstance = new WebSiteGetPublishProfileResponse.Database(); publishProfileInstance.getDatabases().add(addInstance); Attr nameAttribute = databasesElement.getAttributeNodeNS(null, "name"); if (nameAttribute != null) { addInstance.setName(nameAttribute.getValue()); } Attr connectionStringAttribute = databasesElement.getAttributeNodeNS(null, "connectionString"); if (connectionStringAttribute != null) { addInstance.setConnectionString(connectionStringAttribute.getValue()); } Attr providerNameAttribute = databasesElement.getAttributeNodeNS(null, "providerName"); if (providerNameAttribute != null) { addInstance.setProviderName(providerNameAttribute.getValue()); } Attr typeAttribute = databasesElement.getAttributeNodeNS(null, "type"); if (typeAttribute != null) { addInstance.setType(typeAttribute.getValue()); } } } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:edu.internet2.middleware.shibboleth.common.config.relyingparty.RelyingPartyConfigurationBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(Element config, ParserContext parserContext, BeanDefinitionBuilder builder) { String rpId = getRelyingPartyId(config); log.info("Parsing configuration for relying party with id: {}", rpId); builder.addPropertyValue("relyingPartyId", rpId); String provider = DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "provider")); log.debug("Relying party configuration - provider ID: {}", provider); builder.addPropertyValue("providerId", provider); String authnMethod = DatatypeHelper .safeTrimOrNullString(config.getAttributeNS(null, "defaultAuthenticationMethod")); log.debug("Relying party configuration - default authentication method: {}", authnMethod); builder.addPropertyValue("defaultAuthenticationMethod", authnMethod); String secCredRef = DatatypeHelper .safeTrimOrNullString(config.getAttributeNS(null, "defaultSigningCredentialRef")); if (secCredRef != null) { log.debug("Relying party configuration - default signing credential: {}", secCredRef); builder.addPropertyReference("defaultSigningCredential", secCredRef); }/* w w w. j a va 2 s. co m*/ Attr precedenceAttr = config.getAttributeNodeNS(null, "nameIDFormatPrecedence"); if (precedenceAttr != null) { List<String> precedence = XMLHelper.getAttributeValueAsList(precedenceAttr); log.debug("Relying party configuration - NameID format precedence: {}", precedence); builder.addPropertyValue("nameIdFormatPrecedence", precedence); } List<Element> profileConfigs = XMLHelper.getChildElementsByTagNameNS(config, RelyingPartyNamespaceHandler.NAMESPACE, "ProfileConfiguration"); if (profileConfigs != null && profileConfigs.size() > 0) { log.debug("Relying party configuration - {} profile configurations", profileConfigs.size()); builder.addPropertyValue("profileConfigurations", SpringConfigurationUtils.parseInnerCustomElements(profileConfigs, parserContext)); } }
From source file:com.microsoft.windowsazure.management.websites.WebSiteManagementClientImpl.java
/** * The Get Operation Status operation returns the status of the specified * operation. After calling a long-running operation, you can call Get * Operation Status to determine whether the operation has succeeded, * failed, timed out, or is still in progress. (see * http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx for * more information)//from ww w.j a v a2s.c o m * * @param webSpaceName Required. The name of the webspace for the website * where the operation was targeted. * @param siteName Required. The name of the site where the operation was * targeted. * @param operationId Required. The operation ID for the operation you wish * to track. The operation ID is returned in the ID field in the body of * the response for long-running operations. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @throws ParserConfigurationException Thrown if there was a serious * configuration error with the document parser. * @throws SAXException Thrown if there was an error parsing the XML * response. * @return The response body contains the status of the specified * long-running operation, indicating whether it has succeeded, is * inprogress, has timed out, or has failed. Note that this status is * distinct from the HTTP status code returned for the Get Operation Status * operation itself. If the long-running operation failed, the response * body includes error information regarding the failure. */ @Override public WebSiteOperationStatusResponse getOperationStatus(String webSpaceName, String siteName, String operationId) throws IOException, ServiceException, ParserConfigurationException, SAXException { // Validate if (webSpaceName == null) { throw new NullPointerException("webSpaceName"); } if (siteName == null) { throw new NullPointerException("siteName"); } if (operationId == null) { throw new NullPointerException("operationId"); } // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); tracingParameters.put("webSpaceName", webSpaceName); tracingParameters.put("siteName", siteName); tracingParameters.put("operationId", operationId); CloudTracing.enter(invocationId, this, "getOperationStatusAsync", tracingParameters); } // Construct URL String url = ""; url = url + "/"; if (this.getCredentials().getSubscriptionId() != null) { url = url + URLEncoder.encode(this.getCredentials().getSubscriptionId(), "UTF-8"); } url = url + "/services/WebSpaces/"; url = url + URLEncoder.encode(webSpaceName, "UTF-8"); url = url + "/sites/"; url = url + URLEncoder.encode(siteName, "UTF-8"); url = url + "/operations/"; url = url + URLEncoder.encode(operationId, "UTF-8"); String baseUrl = this.getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpGet httpRequest = new HttpGet(url); // Set Headers httpRequest.setHeader("x-ms-version", "2014-04-01"); // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { ServiceException ex = ServiceException.createFromXml(httpRequest, null, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result WebSiteOperationStatusResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new WebSiteOperationStatusResponse(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent)); Element operationElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://schemas.microsoft.com/windowsazure", "Operation"); if (operationElement != null) { Element createdTimeElement = XmlUtility.getElementByTagNameNS(operationElement, "http://schemas.microsoft.com/windowsazure", "CreatedTime"); if (createdTimeElement != null) { Calendar createdTimeInstance; createdTimeInstance = DatatypeConverter.parseDateTime(createdTimeElement.getTextContent()); result.setCreatedTime(createdTimeInstance); } Element errorsSequenceElement = XmlUtility.getElementByTagNameNS(operationElement, "http://schemas.microsoft.com/windowsazure", "Errors"); if (errorsSequenceElement != null) { boolean isNil = false; Attr nilAttribute = errorsSequenceElement .getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "nil"); if (nilAttribute != null) { isNil = "true".equals(nilAttribute.getValue()); } if (isNil == false) { for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(errorsSequenceElement, "http://schemas.microsoft.com/windowsazure", "Error") .size(); i1 = i1 + 1) { org.w3c.dom.Element errorsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(errorsSequenceElement, "http://schemas.microsoft.com/windowsazure", "Error") .get(i1)); WebSiteOperationStatusResponse.Error errorInstance = new WebSiteOperationStatusResponse.Error(); result.getErrors().add(errorInstance); Element codeElement = XmlUtility.getElementByTagNameNS(errorsElement, "http://schemas.microsoft.com/windowsazure", "Code"); if (codeElement != null) { boolean isNil2 = false; Attr nilAttribute2 = codeElement .getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "nil"); if (nilAttribute2 != null) { isNil2 = "true".equals(nilAttribute2.getValue()); } if (isNil2 == false) { String codeInstance; codeInstance = codeElement.getTextContent(); errorInstance.setCode(codeInstance); } } Element messageElement = XmlUtility.getElementByTagNameNS(errorsElement, "http://schemas.microsoft.com/windowsazure", "Message"); if (messageElement != null) { boolean isNil3 = false; Attr nilAttribute3 = messageElement .getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "nil"); if (nilAttribute3 != null) { isNil3 = "true".equals(nilAttribute3.getValue()); } if (isNil3 == false) { String messageInstance; messageInstance = messageElement.getTextContent(); errorInstance.setMessage(messageInstance); } } Element extendedCodeElement = XmlUtility.getElementByTagNameNS(errorsElement, "http://schemas.microsoft.com/windowsazure", "ExtendedCode"); if (extendedCodeElement != null) { boolean isNil4 = false; Attr nilAttribute4 = extendedCodeElement .getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "nil"); if (nilAttribute4 != null) { isNil4 = "true".equals(nilAttribute4.getValue()); } if (isNil4 == false) { String extendedCodeInstance; extendedCodeInstance = extendedCodeElement.getTextContent(); errorInstance.setExtendedCode(extendedCodeInstance); } } Element messageTemplateElement = XmlUtility.getElementByTagNameNS(errorsElement, "http://schemas.microsoft.com/windowsazure", "MessageTemplate"); if (messageTemplateElement != null) { boolean isNil5 = false; Attr nilAttribute5 = messageTemplateElement .getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "nil"); if (nilAttribute5 != null) { isNil5 = "true".equals(nilAttribute5.getValue()); } if (isNil5 == false) { String messageTemplateInstance; messageTemplateInstance = messageTemplateElement.getTextContent(); errorInstance.setMessageTemplate(messageTemplateInstance); } } Element parametersSequenceElement = XmlUtility.getElementByTagNameNS(errorsElement, "http://schemas.microsoft.com/windowsazure", "Parameters"); if (parametersSequenceElement != null) { boolean isNil6 = false; Attr nilAttribute6 = parametersSequenceElement .getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "nil"); if (nilAttribute6 != null) { isNil6 = "true".equals(nilAttribute6.getValue()); } if (isNil6 == false) { for (int i2 = 0; i2 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(parametersSequenceElement, "http://schemas.microsoft.com/2003/10/Serialization/Arrays", "string") .size(); i2 = i2 + 1) { org.w3c.dom.Element parametersElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(parametersSequenceElement, "http://schemas.microsoft.com/2003/10/Serialization/Arrays", "string") .get(i2)); errorInstance.getParameters().add(parametersElement.getTextContent()); } } else { errorInstance.setParameters(null); } } Element innerErrorsElement = XmlUtility.getElementByTagNameNS(errorsElement, "http://schemas.microsoft.com/windowsazure", "InnerErrors"); if (innerErrorsElement != null) { boolean isNil7 = false; Attr nilAttribute7 = innerErrorsElement .getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "nil"); if (nilAttribute7 != null) { isNil7 = "true".equals(nilAttribute7.getValue()); } if (isNil7 == false) { String innerErrorsInstance; innerErrorsInstance = innerErrorsElement.getTextContent(); errorInstance.setInnerErrors(innerErrorsInstance); } } } } else { result.setErrors(null); } } Element expirationTimeElement = XmlUtility.getElementByTagNameNS(operationElement, "http://schemas.microsoft.com/windowsazure", "ExpirationTime"); if (expirationTimeElement != null) { Calendar expirationTimeInstance; expirationTimeInstance = DatatypeConverter .parseDateTime(expirationTimeElement.getTextContent()); result.setExpirationTime(expirationTimeInstance); } Element geoMasterOperationIdElement = XmlUtility.getElementByTagNameNS(operationElement, "http://schemas.microsoft.com/windowsazure", "GeoMasterOperationId"); if (geoMasterOperationIdElement != null) { boolean isNil8 = false; Attr nilAttribute8 = geoMasterOperationIdElement .getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "nil"); if (nilAttribute8 != null) { isNil8 = "true".equals(nilAttribute8.getValue()); } if (isNil8 == false) { String geoMasterOperationIdInstance; geoMasterOperationIdInstance = geoMasterOperationIdElement.getTextContent(); result.setGeoMasterOperationId(geoMasterOperationIdInstance); } } Element idElement = XmlUtility.getElementByTagNameNS(operationElement, "http://schemas.microsoft.com/windowsazure", "Id"); if (idElement != null) { boolean isNil9 = false; Attr nilAttribute9 = idElement .getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "nil"); if (nilAttribute9 != null) { isNil9 = "true".equals(nilAttribute9.getValue()); } if (isNil9 == false) { String idInstance; idInstance = idElement.getTextContent(); result.setOperationId(idInstance); } } Element modifiedTimeElement = XmlUtility.getElementByTagNameNS(operationElement, "http://schemas.microsoft.com/windowsazure", "ModifiedTime"); if (modifiedTimeElement != null) { Calendar modifiedTimeInstance; modifiedTimeInstance = DatatypeConverter .parseDateTime(modifiedTimeElement.getTextContent()); result.setModifiedTime(modifiedTimeInstance); } Element nameElement = XmlUtility.getElementByTagNameNS(operationElement, "http://schemas.microsoft.com/windowsazure", "Name"); if (nameElement != null) { boolean isNil10 = false; Attr nilAttribute10 = nameElement .getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "nil"); if (nilAttribute10 != null) { isNil10 = "true".equals(nilAttribute10.getValue()); } if (isNil10 == false) { String nameInstance; nameInstance = nameElement.getTextContent(); result.setName(nameInstance); } } Element statusElement = XmlUtility.getElementByTagNameNS(operationElement, "http://schemas.microsoft.com/windowsazure", "Status"); if (statusElement != null && statusElement.getTextContent() != null && !statusElement.getTextContent().isEmpty()) { WebSiteOperationStatus statusInstance; statusInstance = WebSiteOperationStatus.valueOf(statusElement.getTextContent()); result.setStatus(statusInstance); } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.attributeDefinition.BaseAttributeDefinitionBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(String pluginId, Element pluginConfig, Map<QName, List<Element>> pluginConfigChildren, BeanDefinitionBuilder pluginBuilder, ParserContext parserContext) { String sourceAttributeId = pluginConfig.getAttributeNS(null, "sourceAttributeID"); log.debug("Setting source attribute ID for attribute definition {} to: {}", pluginId, sourceAttributeId); pluginBuilder.addPropertyValue("sourceAttributeId", sourceAttributeId); List<Element> displayNames = pluginConfigChildren .get(new QName(AttributeResolverNamespaceHandler.NAMESPACE, "DisplayName")); if (displayNames != null) { log.debug("Setting {} display names for attribute definition {}", displayNames.size(), pluginId); pluginBuilder.addPropertyValue("displayNames", processLocalizedElement(displayNames)); }// w w w. j av a2s . c o m List<Element> displayDescriptions = pluginConfigChildren .get(new QName(AttributeResolverNamespaceHandler.NAMESPACE, "DisplayDescription")); if (displayDescriptions != null) { log.debug("Setting {} display descriptions for attribute definition {}", displayDescriptions.size(), pluginId); pluginBuilder.addPropertyValue("displayDescriptions", processLocalizedElement(displayDescriptions)); } boolean dependencyOnly = false; if (pluginConfig.hasAttributeNS(null, "dependencyOnly")) { dependencyOnly = XMLHelper .getAttributeValueAsBoolean(pluginConfig.getAttributeNodeNS(null, "dependencyOnly")); } if (log.isDebugEnabled()) { log.debug("Attribute definition {} produces attributes that are only dependencies: {}", pluginId, dependencyOnly); } pluginBuilder.addPropertyValue("dependencyOnly", dependencyOnly); pluginBuilder.addPropertyValue("attributeEncoders", SpringConfigurationUtils .parseInnerCustomElements(pluginConfigChildren.get(ATTRIBUTE_ENCODER_ELEMENT_NAME), parserContext)); }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.dataConnector.LdapDataConnectorBeanDefinitionParser.java
/** * Process the LDAP result handling configuration for the LDAP data connector. * /*from w ww . jav a 2s. c o m*/ * @param pluginId ID of the LDAP plugin * @param pluginConfig LDAP plugin configuration element * @param pluginConfigChildren child elements of the plugin * @param pluginBuilder plugin builder * @param parserContext current parsing context */ protected void processResultHandlingConfig(String pluginId, Element pluginConfig, Map<QName, List<Element>> pluginConfigChildren, BeanDefinitionBuilder pluginBuilder, ParserContext parserContext) { int searchTimeLimit = 3000; if (pluginConfig.hasAttributeNS(null, "searchTimeLimit")) { searchTimeLimit = (int) SpringConfigurationUtils.parseDurationToMillis( "'searchTimeLimit' on data connector " + pluginId, pluginConfig.getAttributeNS(null, "searchTimeLimit"), 0); } log.debug("Data connector {} search timeout: {}ms", pluginId, searchTimeLimit); pluginBuilder.addPropertyValue("searchTimeLimit", searchTimeLimit); int maxResultSize = 1; if (pluginConfig.hasAttributeNS(null, "maxResultSize")) { maxResultSize = Integer.parseInt(pluginConfig.getAttributeNS(null, "maxResultSize")); } log.debug("Data connector {} max search result size: {}", pluginId, maxResultSize); pluginBuilder.addPropertyValue("maxResultSize", maxResultSize); boolean mergeResults = false; if (pluginConfig.hasAttributeNS(null, "mergeResults")) { mergeResults = XMLHelper .getAttributeValueAsBoolean(pluginConfig.getAttributeNodeNS(null, "mergeResults")); } log.debug("Data connector {} merge results: {}", pluginId, mergeResults); pluginBuilder.addPropertyValue("mergeResults", mergeResults); boolean noResultsIsError = false; if (pluginConfig.hasAttributeNS(null, "noResultIsError")) { noResultsIsError = XMLHelper .getAttributeValueAsBoolean(pluginConfig.getAttributeNodeNS(null, "noResultIsError")); } log.debug("Data connector {} no results is error: {}", pluginId, noResultsIsError); pluginBuilder.addPropertyValue("noResultsIsError", noResultsIsError); boolean lowercaseAttributeNames = false; if (pluginConfig.hasAttributeNS(null, "lowercaseAttributeNames")) { lowercaseAttributeNames = XMLHelper .getAttributeValueAsBoolean(pluginConfig.getAttributeNodeNS(null, "lowercaseAttributeNames")); } log.debug("Data connector {} will lower case attribute IDs: {}", pluginId, lowercaseAttributeNames); pluginBuilder.addPropertyValue("lowercaseAttributeNames", lowercaseAttributeNames); }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.dataConnector.LdapDataConnectorBeanDefinitionParser.java
/** * Process the LDAP connection security configuration for the LDAP data connector. * /*from www . ja v a2s . c om*/ * @param pluginId ID of the LDAP plugin * @param pluginConfig LDAP plugin configuration element * @param pluginConfigChildren child elements of the plugin * @param pluginBuilder plugin builder * @param parserContext current parsing context */ protected void processSecurityConfig(String pluginId, Element pluginConfig, Map<QName, List<Element>> pluginConfigChildren, BeanDefinitionBuilder pluginBuilder, ParserContext parserContext) { RuntimeBeanReference trustCredential = processCredential( pluginConfigChildren .get(new QName(DataConnectorNamespaceHandler.NAMESPACE, "StartTLSTrustCredential")), parserContext); if (trustCredential != null) { log.debug("Data connector {} using provided SSL/TLS trust material", pluginId); pluginBuilder.addPropertyValue("trustCredential", trustCredential); } RuntimeBeanReference connectionCredential = processCredential( pluginConfigChildren.get( new QName(DataConnectorNamespaceHandler.NAMESPACE, "StartTLSAuthenticationCredential")), parserContext); if (connectionCredential != null) { log.debug("Data connector {} using provided SSL/TLS client authentication material", pluginId); pluginBuilder.addPropertyValue("connectionCredential", connectionCredential); } boolean useStartTLS = false; if (pluginConfig.hasAttributeNS(null, "useStartTLS")) { useStartTLS = XMLHelper .getAttributeValueAsBoolean(pluginConfig.getAttributeNodeNS(null, "useStartTLS")); } log.debug("Data connector {} use startTLS: {}", pluginId, useStartTLS); pluginBuilder.addPropertyValue("useStartTLS", useStartTLS); }