Search in sources :

Example 1 with HttpSender

use of nl.nn.adapterframework.http.HttpSender in project iaf by ibissource.

the class ShowConfigurationStatus method mapAdapterPipes.

private ArrayList<Object> mapAdapterPipes(Adapter adapter) {
    if (!adapter.configurationSucceeded())
        return null;
    PipeLine pipeline = adapter.getPipeLine();
    int totalPipes = pipeline.getPipes().size();
    ArrayList<Object> pipes = new ArrayList<Object>(totalPipes);
    for (int i = 0; i < totalPipes; i++) {
        Map<String, Object> pipesInfo = new HashMap<String, Object>();
        IPipe pipe = pipeline.getPipe(i);
        Map<String, PipeForward> pipeForwards = pipe.getForwards();
        String pipename = pipe.getName();
        Map<String, String> forwards = new HashMap<String, String>();
        for (PipeForward fwrd : pipeForwards.values()) {
            forwards.put(fwrd.getName(), fwrd.getPath());
        }
        pipesInfo.put("name", pipename);
        pipesInfo.put("type", pipe.getType());
        pipesInfo.put("forwards", forwards);
        if (pipe instanceof MessageSendingPipe) {
            MessageSendingPipe msp = (MessageSendingPipe) pipe;
            ISender sender = msp.getSender();
            pipesInfo.put("sender", ClassUtils.nameOf(sender));
            if (sender instanceof WebServiceSender) {
                WebServiceSender s = (WebServiceSender) sender;
                Map<String, Object> certInfo = addCertificateInfo(s);
                if (certInfo != null)
                    pipesInfo.put("certificate", certInfo);
            }
            if (sender instanceof HttpSender) {
                HttpSender s = (HttpSender) sender;
                Map<String, Object> certInfo = addCertificateInfo(s);
                if (certInfo != null)
                    pipesInfo.put("certificate", certInfo);
            }
            if (sender instanceof FtpSender) {
                FtpSender s = (FtpSender) sender;
                Map<String, Object> certInfo = addCertificateInfo(s);
                if (certInfo != null)
                    pipesInfo.put("certificate", certInfo);
            }
            if (sender instanceof HasPhysicalDestination) {
                pipesInfo.put("destination", ((HasPhysicalDestination) sender).getPhysicalDestinationName());
            }
            if (sender instanceof JdbcSenderBase) {
                pipesInfo.put("isJdbcSender", true);
            }
            IListener listener = msp.getListener();
            if (listener != null) {
                pipesInfo.put("listenerName", listener.getName());
                pipesInfo.put("listenerClass", ClassUtils.nameOf(listener));
                if (listener instanceof HasPhysicalDestination) {
                    String pd = ((HasPhysicalDestination) listener).getPhysicalDestinationName();
                    pipesInfo.put("listenerDestination", pd);
                }
            }
            ITransactionalStorage messageLog = msp.getMessageLog();
            if (messageLog != null) {
                pipesInfo.put("hasMessageLog", true);
                String messageLogCount;
                try {
                    if (showCountMessageLog) {
                        messageLogCount = "" + messageLog.getMessageCount();
                    } else {
                        messageLogCount = "?";
                    }
                } catch (Exception e) {
                    log.warn(e);
                    messageLogCount = "error";
                }
                pipesInfo.put("messageLogCount", messageLogCount);
                Map<String, Object> message = new HashMap<String, Object>();
                message.put("name", messageLog.getName());
                message.put("type", "log");
                message.put("slotId", messageLog.getSlotId());
                message.put("count", messageLogCount);
                pipesInfo.put("message", message);
            }
        }
        pipes.add(pipesInfo);
    }
    return pipes;
}
Also used : MessageSendingPipe(nl.nn.adapterframework.pipes.MessageSendingPipe) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IListener(nl.nn.adapterframework.core.IListener) ArrayList(java.util.ArrayList) FtpSender(nl.nn.adapterframework.ftp.FtpSender) HttpSender(nl.nn.adapterframework.http.HttpSender) PipeForward(nl.nn.adapterframework.core.PipeForward) ITransactionalStorage(nl.nn.adapterframework.core.ITransactionalStorage) ISender(nl.nn.adapterframework.core.ISender) WebServiceSender(nl.nn.adapterframework.http.WebServiceSender) PipeLine(nl.nn.adapterframework.core.PipeLine) IPipe(nl.nn.adapterframework.core.IPipe) JdbcSenderBase(nl.nn.adapterframework.jdbc.JdbcSenderBase) HasPhysicalDestination(nl.nn.adapterframework.core.HasPhysicalDestination)

Example 2 with HttpSender

use of nl.nn.adapterframework.http.HttpSender in project iaf by ibissource.

the class ShowSecurityItems method addRegisteredAdapters.

private void addRegisteredAdapters(XmlBuilder securityItems) {
    XmlBuilder registeredAdapters = new XmlBuilder("registeredAdapters");
    securityItems.addSubElement(registeredAdapters);
    for (IAdapter iAdapter : ibisManager.getRegisteredAdapters()) {
        Adapter adapter = (Adapter) iAdapter;
        XmlBuilder adapterXML = new XmlBuilder("adapter");
        registeredAdapters.addSubElement(adapterXML);
        adapterXML.addAttribute("name", adapter.getName());
        Iterator recIt = adapter.getReceiverIterator();
        if (recIt.hasNext()) {
            XmlBuilder receiversXML = new XmlBuilder("receivers");
            while (recIt.hasNext()) {
                IReceiver receiver = (IReceiver) recIt.next();
                XmlBuilder receiverXML = new XmlBuilder("receiver");
                receiversXML.addSubElement(receiverXML);
                receiverXML.addAttribute("name", receiver.getName());
                if (receiver instanceof HasSender) {
                    ISender sender = ((HasSender) receiver).getSender();
                    if (sender != null) {
                        receiverXML.addAttribute("senderName", sender.getName());
                    }
                }
            }
            adapterXML.addSubElement(receiversXML);
        }
        // make list of pipes to be displayed in configuration status
        XmlBuilder pipesElem = new XmlBuilder("pipes");
        adapterXML.addSubElement(pipesElem);
        PipeLine pipeline = adapter.getPipeLine();
        for (int i = 0; i < pipeline.getPipes().size(); i++) {
            IPipe pipe = pipeline.getPipe(i);
            String pipename = pipe.getName();
            if (pipe instanceof MessageSendingPipe) {
                MessageSendingPipe msp = (MessageSendingPipe) pipe;
                XmlBuilder pipeElem = new XmlBuilder("pipe");
                pipeElem.addAttribute("name", pipename);
                ISender sender = msp.getSender();
                pipeElem.addAttribute("sender", ClassUtils.nameOf(sender));
                pipesElem.addSubElement(pipeElem);
                if (sender instanceof WebServiceSender) {
                    WebServiceSender s = (WebServiceSender) sender;
                    String certificate = s.getCertificate();
                    if (StringUtils.isNotEmpty(certificate)) {
                        XmlBuilder certElem = new XmlBuilder("certificate");
                        certElem.addAttribute("name", certificate);
                        String certificateAuthAlias = s.getCertificateAuthAlias();
                        certElem.addAttribute("authAlias", certificateAuthAlias);
                        URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
                        if (certificateUrl == null) {
                            certElem.addAttribute("url", "");
                            pipeElem.addSubElement(certElem);
                            XmlBuilder infoElem = new XmlBuilder("info");
                            infoElem.setCdataValue("*** ERROR ***");
                            certElem.addSubElement(infoElem);
                        } else {
                            certElem.addAttribute("url", certificateUrl.toString());
                            pipeElem.addSubElement(certElem);
                            String certificatePassword = s.getCertificatePassword();
                            CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
                            String keystoreType = s.getKeystoreType();
                            addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
                        }
                    }
                } else {
                    if (sender instanceof HttpSender) {
                        HttpSender s = (HttpSender) sender;
                        String certificate = s.getCertificate();
                        if (StringUtils.isNotEmpty(certificate)) {
                            XmlBuilder certElem = new XmlBuilder("certificate");
                            certElem.addAttribute("name", certificate);
                            String certificateAuthAlias = s.getCertificateAuthAlias();
                            certElem.addAttribute("authAlias", certificateAuthAlias);
                            URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
                            if (certificateUrl == null) {
                                certElem.addAttribute("url", "");
                                pipeElem.addSubElement(certElem);
                                XmlBuilder infoElem = new XmlBuilder("info");
                                infoElem.setCdataValue("*** ERROR ***");
                                certElem.addSubElement(infoElem);
                            } else {
                                certElem.addAttribute("url", certificateUrl.toString());
                                pipeElem.addSubElement(certElem);
                                String certificatePassword = s.getCertificatePassword();
                                CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
                                String keystoreType = s.getKeystoreType();
                                addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
                            }
                        }
                    } else {
                        if (sender instanceof FtpSender) {
                            FtpSender s = (FtpSender) sender;
                            String certificate = s.getCertificate();
                            if (StringUtils.isNotEmpty(certificate)) {
                                XmlBuilder certElem = new XmlBuilder("certificate");
                                certElem.addAttribute("name", certificate);
                                String certificateAuthAlias = s.getCertificateAuthAlias();
                                certElem.addAttribute("authAlias", certificateAuthAlias);
                                URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
                                if (certificateUrl == null) {
                                    certElem.addAttribute("url", "");
                                    pipeElem.addSubElement(certElem);
                                    XmlBuilder infoElem = new XmlBuilder("info");
                                    infoElem.setCdataValue("*** ERROR ***");
                                    certElem.addSubElement(infoElem);
                                } else {
                                    certElem.addAttribute("url", certificateUrl.toString());
                                    pipeElem.addSubElement(certElem);
                                    String certificatePassword = s.getCertificatePassword();
                                    CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
                                    String keystoreType = s.getCertificateType();
                                    addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : MessageSendingPipe(nl.nn.adapterframework.pipes.MessageSendingPipe) CredentialFactory(nl.nn.adapterframework.util.CredentialFactory) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) FtpSender(nl.nn.adapterframework.ftp.FtpSender) HttpSender(nl.nn.adapterframework.http.HttpSender) HasSender(nl.nn.adapterframework.core.HasSender) URL(java.net.URL) IReceiver(nl.nn.adapterframework.core.IReceiver) ISender(nl.nn.adapterframework.core.ISender) Iterator(java.util.Iterator) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) WebServiceSender(nl.nn.adapterframework.http.WebServiceSender) PipeLine(nl.nn.adapterframework.core.PipeLine) IAdapter(nl.nn.adapterframework.core.IAdapter) IPipe(nl.nn.adapterframework.core.IPipe)

Example 3 with HttpSender

use of nl.nn.adapterframework.http.HttpSender in project iaf by ibissource.

the class SvnUtils method getReportHtml.

private static String getReportHtml(String urlString, String revision, String path) throws ConfigurationException, SenderException, TimeOutException {
    HttpSender httpSender = null;
    try {
        httpSender = new HttpSender();
        httpSender.setUrl(urlString);
        httpSender.setAllowSelfSignedCertificates(true);
        httpSender.setVerifyHostname(false);
        httpSender.setIgnoreCertificateExpiredException(true);
        httpSender.setXhtml(true);
        httpSender.setMethodType("REPORT");
        httpSender.configure();
        httpSender.open();
        String logReportRequest = "<S:log-report xmlns:S=\"svn:\">" + "<S:start-revision>" + revision + "</S:start-revision>" + "<S:end-revision>" + revision + "</S:end-revision>" + "<S:limit>1</S:limit>" + "<S:path>" + path + "</S:path>" + "</S:log-report>";
        httpSender.setMethodType("REPORT");
        httpSender.configure();
        httpSender.open();
        String result = httpSender.sendMessage(null, logReportRequest);
        return result;
    } finally {
        if (httpSender != null) {
            httpSender.close();
        }
    }
}
Also used : HttpSender(nl.nn.adapterframework.http.HttpSender)

Example 4 with HttpSender

use of nl.nn.adapterframework.http.HttpSender in project iaf by ibissource.

the class ScanTibcoSolutionPipe method getHtml.

private String getHtml(String urlString) throws ConfigurationException, SenderException, TimeOutException {
    HttpSender httpSender = null;
    try {
        httpSender = new HttpSender();
        httpSender.setUrl(urlString);
        httpSender.setAllowSelfSignedCertificates(true);
        httpSender.setVerifyHostname(false);
        httpSender.setIgnoreCertificateExpiredException(true);
        httpSender.setXhtml(true);
        httpSender.configure();
        httpSender.open();
        String result = httpSender.sendMessage(null, "");
        return result;
    } finally {
        if (httpSender != null) {
            httpSender.close();
        }
    }
}
Also used : HttpSender(nl.nn.adapterframework.http.HttpSender)

Example 5 with HttpSender

use of nl.nn.adapterframework.http.HttpSender in project iaf by ibissource.

the class SvnUtils method getHeadHtml.

private static String getHeadHtml(String urlString) throws ConfigurationException, SenderException, TimeOutException {
    HttpSender httpSender = null;
    try {
        httpSender = new HttpSender();
        httpSender.setUrl(urlString);
        httpSender.setAllowSelfSignedCertificates(true);
        httpSender.setVerifyHostname(false);
        httpSender.setIgnoreCertificateExpiredException(true);
        httpSender.setXhtml(true);
        httpSender.setMethodType("HEAD");
        httpSender.configure();
        httpSender.open();
        String result = httpSender.sendMessage(null, "");
        return result;
    } finally {
        if (httpSender != null) {
            httpSender.close();
        }
    }
}
Also used : HttpSender(nl.nn.adapterframework.http.HttpSender)

Aggregations

HttpSender (nl.nn.adapterframework.http.HttpSender)6 WebServiceSender (nl.nn.adapterframework.http.WebServiceSender)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 LinkedHashMap (java.util.LinkedHashMap)2 IPipe (nl.nn.adapterframework.core.IPipe)2 ISender (nl.nn.adapterframework.core.ISender)2 PipeLine (nl.nn.adapterframework.core.PipeLine)2 FtpSender (nl.nn.adapterframework.ftp.FtpSender)2 MessageSendingPipe (nl.nn.adapterframework.pipes.MessageSendingPipe)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 URL (java.net.URL)1 ParseException (java.text.ParseException)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)1 DirectoryClassLoader (nl.nn.adapterframework.configuration.classloaders.DirectoryClassLoader)1