Posts

Showing posts from 2016

What is JSON Web Token?

Image
1. Overview JSON Web Token or JWT ( jot ) for short is an open standard (RFC 7519) that defines a compact, URL-safe means of representing claims to be transferred between two parties.  The claims in a JWT are encoded as a JSON object that is used as the payload of a JSON Web Signature (JWS) structure or as the plaintext of a JSON Web Encryption (JWE) structure, enabling the claims to be digitally signed or integrity protected with a Message Authentication Code (MAC) and/or encrypted. 2. Structure The compacted representation of a signed JWT is a string that has three parts, each separated by a dots (.) : Eg:  eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 . eyJzdWIiOiJBYmR1bCIsImlhdCI6MTIzNDU2Nzg5MCwiZXhwIjoxMjM0NTY3ODkwLCJuYmYiOjEyMzQ1Njc4OTAsImlzcyI6Imh0dHA6Ly93YWhlZWR0ZWNoYmxvZy5pbiIsInNjb3BlIjpbInJlYWQiLCJ3cml0ZSJdLCJhZG1pbiI6dHJ1ZX0 . Ats92uWxgSjQ8vFgQieK9tpBi66csIFHxkTke70FGlI Each section is Base64Encoded and the first section is called header, the second section ...

@Embeddable and @Embedded in Hibernate Annotation

Image
Before jumping to @Embeddable and @Embedded annotation. Let me explain about hibernate different objects:          Entity Object o    Entity object are those object which can stand alone like Student or Professor and has its own database identity.          Value Object o    Objects which cannot stand alone like Address as you need to map address with some Entities like Student. It will belongs to an entity, and its persistent state is embedded in the table row of the owning entity In short, always use @Embeddable for the value object and @Embedded with the entity class. Let's understand it by a simple example: We have one Address (Value object) and it is having attributes like city, state, zip code. Now we have two more different entity Student and Professor (Entity Object) . Student or Professor can have Address attributes just by embedding the Address into its Entity. The  @Embedd...

What is MappedSuperClass in hibernate ?

Image
MapperSuperClass ·         A mapped superclass has no separate table defined for it. ·         Designates a class whose mapping information is applied to the entities that inherit from it.  ·         A class designated with the  MappedSuperclass  annotation can be mapped in the same way as an entity except that the mappings will apply only to its subclasses since no table exists for the mapped superclass itself.  ·         When applied to the subclasses the inherited mappings will apply in the context of the subclass tables.  ·         Mapping information may be overridden in such subclasses by using the  AttributeOverride  and  AssociationOverride  annotations or corresponding XML elements. ·         It avoids the cod...

MongoDB basic Overview

Overview MongoDB is a cross-platform, documented oriented database and it is not based on schema like relational database. It uses dynamic schema and stores data in JSON format. It provides high performance, high availability, and easy scalability and it works on concept of collection and document. It is an open-source software. MongoDB is mainly written in C++, JavaScript and C. Download Please refer this link to setup MongoDB on your machine. Terminology ·          Document Document is similar to row/tuples in RDBMS, it is a set of key-value pairs and having dynamic schema i.e. the documents in the same collection do not need to have the same set of fields or structure and another document may hold different types of data. ·          Collection It is the equivalent to a TABLE in RDBMS and do not enforce a schema. It exists within a single database and each document wit...

How to install and verify MongoDB on Windows 7 ?

Image
Step by Step instructions: 1.       Download MongoDB Check MongoDB msi from Official website and download Windows Server 2008 R2 64-bit and later version. 2.       Install MongoDB Double click on downloaded MSI (mongodb-win32-x86_64-2008plus-ssl-3.2.11-signed.msi) file and follow the click on next button on wizard to complete the installation. 3.       Create Default Directory MongoDB requires a data directory to store all data and its default data directory path is \data\db. On Windows, By default it will always look for above directory under C:/ structure, Goto C: directory and create /data/db, So the full path of db folder will be C:\data\db 4.       Set environment variables Set MongoDB location to system's environment variables and give path till bin folder. 5.   5.       Start MongoDB To ...

How to extract Private key from keystore ?

There can be a situation where you want to extract private key from your keystore but it is not a straight forward as we think as It involves two steps i.e. ·          Extracting private key from keystore in PKCS#12 format ·          Converting it to .PEM file Step1: Extracting in PKCS format keytool -v -importkeystore -srckeystore KEYSTORE_NAME -srcalias CERTIFICATE_ALIAS -destkeystore FILE_NAME.p12 -deststoretype PKCS12 Eg: keytool -v -importkeystore -srckeystore keystore.jks -srcalias  application -destkeystore privatekey.p12 -deststoretype PKCS12 Note: If you don’t know the alias name of your certificate then you can display it: keytool -list -v -keystore keystore.jks Step2: Converting it into .PEM FILE openssl pkcs12 -in privatekey.p12 -out private.pem