Posts

Showing posts from 2020

aggregation vs composition

Image
Aggregation (collection) differs from ordinary composition in that it does not imply ownership. In composition, when the owning object is destroyed, so are the contained objects. In aggregation, this is not necessarily true Composition (mixture) is a way to combine simple objects or data types into more complex ones. Compositions are a critical building block of many basic data structures Both denotes relationship between object and only differ in their strength. UML notations for different kind of dependency between two classes Composition : Since Engine is part-of Car, relationship between them is Composition. Here is how they are implemented between Java classes.   public class Car { //final will make sure engine is initialized private final Engine engine; public Car(){ engine = new Engine(); } } class Engine { private String type; } Aggregation   : Since Organization has Person as employees, relationship between them is Aggregation. Here is how they

Generate Public, Private key and Certificates using openssl.

Generate Public, Private key and Certificates using openssl. Here’s some openssl commands from our discussion earlier about private/pubic keys. 1. Generate a private key openssl genrsa -out private.pem 2048 2. Create CSR - certificate signing request openssl req -new -key private.pem -out csr.pem 3. Create self signed certificate (sign with private key instead of CA) from the csr (1 year expiry) openssl x509 -req -days 365 -in csr.pem -signkey private.pem -sha256 -out cert.pem -outform PEM 4. Looks at details of certificate openssl x509 -in cert.pem -noout -text 5. Extract public key from certificate - to std out openssl x509 -in cert.pem -noout -pubkey 6. Extract public key from private key - to file openssl rsa -in private.pem -outform PEM -pubout -out public.pem 7. How to check if a certificate and csr matches with your private key Compare: openssl rsa -noout -modulus -in private.pem | openssl md5 openssl x509 -noout -modulus -in cert.pem | openssl md5 openssl req -noout -modulus -i

Git Aliases

# ---------------------- # Git Aliases # ---------------------- alias gclone='git clone' alias ga='git add' alias gaa='git add .' alias gaaa='git add --all' alias gau='git add --update' alias gf='git fetch' alias gb='git branch' alias gbd='git branch --delete ' alias gc='git commit' alias gca='git commit --amend' alias gcm='git commit --message' alias pgacm='git add . && git commit -m' alias gacm='./gradlew goJF && git add . && git commit -m' alias gcf='git commit --fixup' alias gp='git push' alias gpf='git push --force' alias gps='git push --set-upstream origin' alias gco='git checkout' alias gcob='git checkout -b' alias gcom='git checkout master' alias gcos='git checkout staging' alias gcod='git checkout develop' alias gd='git diff' alias gda='git diff HEAD' alias gi='