Search in sources :

Example 1 with Doc

use of com.predic8.membrane.annot.model.doc.Doc in project service-proxy by membrane.

the class AuthHead2BodyInterceptor method handleRequest.

public Outcome handleRequest(AbstractExchange exchange) throws Exception {
    Document doc = getDocument(exchange.getRequest().getBodyAsStreamDecoded(), exchange.getRequest().getCharset());
    Element header = getAuthorisationHeader(doc);
    if (header == null)
        return Outcome.CONTINUE;
    // System.out.println(DOM2String(doc));
    Element nor = getNorElement(doc);
    nor.appendChild(getUsername(doc, header));
    nor.appendChild(getPassword(doc, header));
    header.getParentNode().removeChild(header);
    exchange.getRequest().setBody(new Body(DOM2String(doc).getBytes(exchange.getRequest().getCharset())));
    return Outcome.CONTINUE;
}
Also used : Element(org.w3c.dom.Element) MCElement(com.predic8.membrane.annot.MCElement) Document(org.w3c.dom.Document) Body(com.predic8.membrane.core.http.Body)

Example 2 with Doc

use of com.predic8.membrane.annot.model.doc.Doc in project service-proxy by membrane.

the class AuthHead2BodyInterceptor method getPassword.

private Node getPassword(Document doc, Element header) {
    Element e = doc.createElement("password");
    e.appendChild(doc.createTextNode(((Element) doc.getElementsByTagNameNS(COM_NS, "password").item(0)).getTextContent()));
    e.setAttributeNS(XSI_NS, "xsi:type", "xsd:string");
    return e;
}
Also used : Element(org.w3c.dom.Element) MCElement(com.predic8.membrane.annot.MCElement)

Example 3 with Doc

use of com.predic8.membrane.annot.model.doc.Doc in project service-proxy by membrane.

the class HelpReference method handleDoc.

private void handleDoc(AbstractJavadocedInfo info) throws XMLStreamException {
    Doc doc = info.getDoc(processingEnv);
    if (doc == null)
        return;
    xew.writeStartElement("documentation");
    for (Doc.Entry e : doc.getEntries()) handleDoc(e);
    xew.writeEndElement();
}
Also used : Doc(com.predic8.membrane.annot.model.doc.Doc)

Example 4 with Doc

use of com.predic8.membrane.annot.model.doc.Doc in project service-proxy by membrane.

the class AdminPageBuilder method createHelpIcon.

private void createHelpIcon(Interceptor i, String id) {
    String helpId = i.getHelpId();
    if (helpId != null) {
        div().style("float:right;");
        a().href("http://membrane-soa.org/service-proxy-doc/" + getVersion() + "/configuration/reference/" + helpId + ".htm");
        span().classAttr("ui-icon ui-icon-help").title("help").end();
        end();
        end();
    }
}
Also used : URLParamUtil.createQueryString(com.predic8.membrane.core.util.URLParamUtil.createQueryString)

Example 5 with Doc

use of com.predic8.membrane.annot.model.doc.Doc in project service-proxy by membrane.

the class XMLContentFilter method removeElementsIfNecessary.

/**
 * @param originalMessage
 * @param xopDecodedMessage
 * @param doc
 * @throws XPathExpressionException
 * @throws TransformerException
 * @throws TransformerConfigurationException
 * @throws TransformerFactoryConfigurationError
 */
private void removeElementsIfNecessary(Message originalMessage, Message xopDecodedMessage, Document doc) throws XPathExpressionException, TransformerException, TransformerConfigurationException, TransformerFactoryConfigurationError {
    NodeList toBeDeleted = (NodeList) createXPathExpression().evaluate(doc, XPathConstants.NODESET);
    if (toBeDeleted.getLength() > 0) {
        // change is necessary
        originalMessage.getHeader().removeFields(Header.CONTENT_ENCODING);
        if (xopDecodedMessage != null) {
            originalMessage.getHeader().removeFields(Header.CONTENT_TYPE);
            if (xopDecodedMessage.getHeader().getContentType() != null)
                originalMessage.getHeader().setContentType(xopDecodedMessage.getHeader().getContentType());
        }
        for (int i = 0; i < toBeDeleted.getLength(); i++) {
            Node n = toBeDeleted.item(i);
            n.getParentNode().removeChild(n);
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        createTransformer().transform(new DOMSource(doc), new StreamResult(baos));
        originalMessage.setBodyContent(baos.toByteArray());
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) StreamResult(javax.xml.transform.stream.StreamResult) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ContainerNode(com.predic8.membrane.core.interceptor.xmlcontentfilter.SimpleXPathParser.ContainerNode) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

MCElement (com.predic8.membrane.annot.MCElement)3 Doc (com.predic8.membrane.annot.model.doc.Doc)3 Response (com.predic8.membrane.core.http.Response)3 Element (org.w3c.dom.Element)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 Entry (com.predic8.membrane.annot.model.doc.Doc.Entry)1 Body (com.predic8.membrane.core.http.Body)1 Request (com.predic8.membrane.core.http.Request)1 ResponseBuilder (com.predic8.membrane.core.http.Response.ResponseBuilder)1 Interceptor (com.predic8.membrane.core.interceptor.Interceptor)1 WSDLInterceptor (com.predic8.membrane.core.interceptor.WSDLInterceptor)1 ContainerNode (com.predic8.membrane.core.interceptor.xmlcontentfilter.SimpleXPathParser.ContainerNode)1 ResourceRetrievalException (com.predic8.membrane.core.resolver.ResourceRetrievalException)1 HttpClient (com.predic8.membrane.core.transport.http.HttpClient)1 EndOfStreamException (com.predic8.membrane.core.util.EndOfStreamException)1 URLParamUtil.createQueryString (com.predic8.membrane.core.util.URLParamUtil.createQueryString)1 PrintWriter (java.io.PrintWriter)1