Posts

Creating ISO8583 Server using Spring Integration

Image
Hi, in this post we are going to talk about Creating ISO8583 Server using Spring Integration , i know there is library called jPOS that has complete feature regarding financial transaction, especially ISO8583 messaging. But jPOS isn't free for commercial purposes, you need to buy its licence or make your code open source (i don't think that's possible for commercial purposes). Some Developers combine jPOS with Spring Application on a single project, that could work, yeah! But personally i don't like it, the difference in design pattern between Pull Configuration used by jPOS and Dependency Injection by Spring, our code will be more readable and clean if we are using one Pattern on our project. Well, that's what I thought! Instead of creating ISO8583 Server using jPOS and processing it with Spring code, we will Create ISO8583 Server using Spring Integration . More about Spring Integration Here . Server Configuration: Server Connection Fac...

Create ZIP Stream Before Uploading Files to SFTP

Image
This post is related to SFTP Client Using SSHJ , we are going to  Create ZIP Stream Before Uploading Files to SFTP .  ZIP Stream means we are not going to save zipped files to local storage / disk.  With SSHJ, we can upload files from the local path and from LocalSourceFile , with LocalSourceFile we can set the InputStream to be uploaded. We are going to implement LocalSourceFile by extending InMemorySourceFile , let's create class named ZipStreamSourceFile import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; import java.security.MessageDigest; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import net.schmizz.sshj.xfer.InMemorySourceFile; public class ZipStreamSourceFile extends InMemorySourceFile { private String name; private ByteArrayOutputStream bos; public ZipStream...

SFTP Client using SSHJ

Image
In this post we are going to create a SFTP Client using the SSHJ library. Compared to JSch, SSHJ has a more clear and simple java API especially for authentication. All we need to do is import SSHJ dependency. <dependency> <groupId>com.hierynomus</groupId> <artifactId>sshj</artifactId> <version>0.39.0</version> </dependency> Then create a SFTP client: SSHJSftpClient private interface Action<T> { T handle(SFTPClient sftpClient) throws Exception; } private <T> T doInSftpSession(Action<T> action) throws Exception { try(SSHClient client = new SSHClient()) { client.addHostKeyVerifier(new PromiscuousVerifier()); System.out.println("SSHJ CONNECT: ["+host+"] ["+port+"] ["+username+"]"); client.connect(host, port); client.authPassword(username, password); try (SFTPClient sftpClient ...

Creating Serial COMM-Port Simulator using Socat

Image
Developing an application that integrates with devices like Printer, Cash Acceptor, or any other device requires us to carry the devices anywhere and anytime when we are going to work, especially when we are working in a hybrid WFH-WHO office. In this post, we will talk about Creating a Serial COMM-Port Simulator using Socat. Socat stands for SOcket CAT, its utility to transfer data between two channels with both directions.   There are many different types of channels socat can connect, including: Files Pipes Devices (serial line, pseudo-terminal, etc) Sockets (UNIX, IP4, IP6 - raw, UDP, TCP) SSL sockets Proxy CONNECT connections File descriptors (stdin, etc) The GNU line editor (readline) Programs Combinations of two of these For more information about Socat you can find it on its documentations ( http://www.dest-unreach.org/socat/ )  We are going to create a Printer Simulator using Serial comm-port forwarded to TCP Servers’s Simulator using Socat and Java: First of al...