List of usage examples for javax.xml.soap SOAPBodyElement getNamespaceURI
public String getNamespaceURI();
null
if it is unspecified (see ). From source file:org.wso2.carbon.identity.sso.saml.servlet.SAMLArtifactResolveServlet.java
/** * All requests are handled by this handleRequest method. Request should come with a soap envelop that * wraps an ArtifactResolve object. First we try to extract resolve object and if successful, call * handle artifact method.//from w w w. j a v a2s.c om * * @param req HttpServletRequest object received. * @param resp HttpServletResponse object to be sent. * @throws ServletException * @throws IOException */ private void handleRequest(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { ArtifactResolve artifactResolve = null; try { MessageFactory messageFactory = MessageFactory.newInstance(); InputStream inStream = req.getInputStream(); SOAPMessage soapMessage = messageFactory.createMessage(new MimeHeaders(), inStream); if (log.isDebugEnabled()) { OutputStream outputStream = new ByteArrayOutputStream(); soapMessage.writeTo(outputStream); log.debug("SAML2 Artifact Resolve request received: " + outputStream.toString()); } SOAPBody soapBody = soapMessage.getSOAPBody(); Iterator iterator = soapBody.getChildElements(); while (iterator.hasNext()) { SOAPBodyElement artifactResolveElement = (SOAPBodyElement) iterator.next(); if (StringUtils.equals(SAMLConstants.SAML20P_NS, artifactResolveElement.getNamespaceURI()) && StringUtils.equals(ArtifactResolve.DEFAULT_ELEMENT_LOCAL_NAME, artifactResolveElement.getLocalName())) { DOMSource source = new DOMSource(artifactResolveElement); StringWriter stringResult = new StringWriter(); TransformerFactory.newInstance().newTransformer().transform(source, new StreamResult(stringResult)); artifactResolve = (ArtifactResolve) SAMLSSOUtil.unmarshall(stringResult.toString()); } } } catch (SOAPException e) { throw new ServletException("Error while extracting SOAP body from the request.", e); } catch (TransformerException e) { throw new ServletException("Error while extracting ArtifactResponse from the request.", e); } catch (IdentityException e) { throw new ServletException("Error while unmarshalling ArtifactResponse from the request.", e); } if (artifactResolve != null) { handleArtifact(req, resp, artifactResolve); } else { log.error("Invalid SAML Artifact Resolve request received."); } } finally { SAMLSSOUtil.removeSaaSApplicationThreaLocal(); SAMLSSOUtil.removeUserTenantDomainThreaLocal(); SAMLSSOUtil.removeTenantDomainFromThreadLocal(); } }