Skip to main content

Posts

GoF Design Patterns

Design Patterns listed out in GoF  Creational Pattern Abstract Factory Builder Factory Method Prototype Singleton Structural Pattern Adaptor Bridge Composite Decorator Facade Flyweight Proxy Behavioral Pattern Chain of Resposibility Command Interpreter Iterator Mediator Momento Observer State Strategy Template Method Visitor

Secugen Hamster Fingerprint reader API cannot function without the device

For those who are familiar with Secugen Devices, might know that there are two function calls to initialize the device API.   The Init(long devName) and  The InitEx(long width, long height, long dpi) As per the official Javadoc, the first one is meant to " Initialize the SecuGen libraries using attached SecuGen fingerprint sensor. This method should be called after Open() is called."  while the second one is for " Initializes the SecuGen libraries using image parameters. Only 8bits per pixel raw images are supported."  For the same function, the C++ documentation says , "Use when running fingerprint algorithm module without a SecuGen reader." I had a use case wherein, I want to do the fingerprint verification/matching at server-side. This made me wonder if I can use the second initialization function at the server end without the device and use the fingerprint matching APIs. I tried using the aforementioned approach, but the InitEx() method was failing ...

PostgreSQL with SSL auth (Java client)

PostgreSQL Server 1. Generate certificates Download easyrsa2 from github and extract it   # ./easyrsa build-ca # ./easyrsa build-server-full postgresql-server # ./easyrsa build-client-full postgresql-client   This will generate ca.crt in pki folder, postgres-server.crt , postgres-client.crt in pki/issued folder and postgres-server.key and postgres-client.key in pki/private folder.   PostgreSQL JDBC library cannot read .key file, which is why we have to convert the key to DER format (.pk8) file.   openssl pkcs8 -topk8 -outform DER -in postgres-client.key -out postgres-client.key.pk8 -nocrypt    Give proper unix permissions to the certificates and keys, for eg.   # chown postgres:postgres postgres-server.key  # chown postgres:postgres postgres-server.crt # chmod go-r postgres-server.key     2. Edit postgresql.conf ssl = on          ssl_cert_file = '/opt/postgres-sec/postgres-server.crt...

Importing OSM (PBF file) to PostGIS (PGSNAPSHOT schema)

OSM Data can be used for variety of usecases like rendering, searching, data analytics etc. Each usecase yield quickest result in a particular data format. Due to the large volume of data, this can cause significant difference in the response times.  Some of these formats are, PBF  -- A highly compressed format used almost exclusively for storage and downloads owing to the small sizes. These format are not human readable and gzip compressed. PostgreSQL with PostGIS extension -- A data format backed up by PostgreSQL database. There are various schemas supported for multiple use cases which can greatly impact the response time as indexes and normalization are used to speed up queries. Some popular schemas along with their usecase and certain features are as below. The table is taken directly from openstreetmap wiki. Schema name Created with Used by Primary use case Updatable Geometries ( PostGIS ) Lossless hstore  columns Database osm2pgsql osm2pgsql Mapnik ,  Kothic...

Extend virtual disk size of a VDI image

BACK UP EVERYTHING BEFORE TRYING THIS. The entire process can be split into 4 stages. 1. Physically increasing the vdi file size on the host machine. This requires help from the hypervisor OEM. For VDI, which is a native VirtualBox image, we'll use VBoxManage. VBoxmanage modifyhd centos.vdi --resize 100000 If the above command doesn't work and throw an error about this feature not being implemented, you might try the following instead. Create a new disk with higher capacity VBoxManage clonemedium --existing 2. Resize the LVM. For this we'll use GParted to resize the image. Boot up a GParted live CD and resize the required LVM partition to suit your need. 3. Resize the LVM-2 Boot up the machine with the newly extended image and check df -h and fdisk -l. You'll see that the disk has indeed grown, but LVM hasn't. Use the following command to resize LVM to full size. pvresize /dev/sda2 (assuming your LVM partition is sda...

Multimaster replication with Symmetric DS

Symmetric DS is an awesome tool for trigger based replication whcih works for all major database vendors, including but not limited to PostgreSQL, MySQL, MSSQL, Oracle and many others. Symmetric-DS is a java application and can execute on any platform on whcih JRE is available including Windows and Linux. Trigger based replication, in constrast to disk based (eg. DRBD ) or transaction log file shipping based or statement based , works by registering triggers on DMLs and sending the data thus generated to remote machines. Another very popular trigger based DB replication tool is Slony . Symmetric-DS in addition to being database agnostic also supports multi-master replication (MMR). MMR usecase involves multiple database nodes, connected in a pool with DML updates coming from any of them. This is different from the normal master-slave replication, where slaves are not expected to generate any data events, and the sole authority of database is the master. MMR requirement causes d...

SSL cIpher suits and what they mean?

I'm sure you have wondered at all those cipher suits SSL supports and watched in wonder as to what the hell does all those weird abbreviation mean. To find out what all cipher suits your openssl installation supports try, $ openssl ciphers -v ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH     Au=RSA  Enc=AESGCM(256) Mac=AEAD ECDHE-ECDSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH     Au=ECDSA Enc=AESGCM(256) Mac=AEAD ECDHE-RSA-AES256-SHA384 TLSv1.2 Kx=ECDH     Au=RSA  Enc=AES(256)  Mac=SHA384 ECDHE-ECDSA-AES256-SHA384 TLSv1.2 Kx=ECDH     Au=ECDSA Enc=AES(256)  Mac=SHA384 ECDHE-RSA-AES256-SHA    SSLv3 Kx=ECDH     Au=RSA  Enc=AES(256)  Mac=SHA1 ECDHE-ECDSA-AES256-SHA  SSLv3 Kx=ECDH     Au=ECDSA Enc=AES(256)  Mac=SHA1 SRP-DSS-AES-256-CBC-SHA SSLv3 Kx=SRP      Au=DSS  Enc=AES(256)  Mac=SHA1 S...