Search in sources :

Example 1 with FtpSender

use of nl.nn.adapterframework.ftp.FtpSender 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 FtpSender

use of nl.nn.adapterframework.ftp.FtpSender 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)

Aggregations

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 HttpSender (nl.nn.adapterframework.http.HttpSender)2 WebServiceSender (nl.nn.adapterframework.http.WebServiceSender)2 MessageSendingPipe (nl.nn.adapterframework.pipes.MessageSendingPipe)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 Adapter (nl.nn.adapterframework.core.Adapter)1 HasPhysicalDestination (nl.nn.adapterframework.core.HasPhysicalDestination)1 HasSender (nl.nn.adapterframework.core.HasSender)1 IAdapter (nl.nn.adapterframework.core.IAdapter)1 IListener (nl.nn.adapterframework.core.IListener)1 IReceiver (nl.nn.adapterframework.core.IReceiver)1 ITransactionalStorage (nl.nn.adapterframework.core.ITransactionalStorage)1 PipeForward (nl.nn.adapterframework.core.PipeForward)1