Monthly Archives: November 2019

About OOP for beginners


Why OOP

While you developing an application, application is subjected to change in its business logic’s as a result code will keep changing, so  Easy of use and avoid large chunk of code by eliminating duplication of code , OOP comes into picture.

Reason to use OOP

1) Complex code easier to develop.
2) OOP is exposing only required data, modularity, sharing, easy to maintain, controlling data accessibility.

Approach to Object Oriented Design:

1. Start with the simple object which can be abstracted into individual classes.
2. Identify all the classes in the requirement specification.
3. Identify the commonalities between all or small groups of classes. Do not force fit generalisation where it doesn’t make sense.
4. Keep all the data members private or protected.
5. Identify all the member variables and methods the class should have.
6. Ensure that the class is fully independent of other classes and contains all the necessary attributes and methods.
7. The methods in the class should be abstract.
8. Don’t use the procedural code into a class for the methods in the class.
9. Inherit and extend classes from the base classes when require.
10. Define the “Has-A” or “Uses-A” relationships among the classes

OOP Concepts

Image Source from Google

1) Class
Class is a blue print which is containing only list of variables and method and no memory is allocated for them. A class is a group of objects that has common properties.

2) Object
Objects are usable instances of class. In otherwords Object is the physical as well as logical entity where as class is the only logical entity.

Note:- objects are usable instances of class
Example: Student obj=new Student();
* Here obj is the instance of class Student and ‘new Student()’ is way to create an object
* A new object has been created in memory and it reference has been returned (new Student())
* Holding the object reference in a variable called instance(obj=new Student())

3) Abstraction
Abstraction is a process of hiding the implementation details from the user, only the functionality will be provided to the user.

4) Encapsulation
Encapsulation is a mechanism of wrapping the data (instance variables) and code acting on the data (methods) together as a single unit like a Class.
The variables of a class can be made hidden from other classes, and can be accessed only through the methods of their current class. It is also known as data hiding.

5) Inheritance
Saves time by acquiring the same object into another
The process where one class acquires the members of (methods and properties) of another.

6) Polymorphism
This is the ability of an object to perform in a wide variety of ways.

Will see in detail with example in up coming post

Steps to Install OpenSSL in Ubuntu


Update the Ubuntu repository and install package dependencies
sudo apt update
sudo apt install build-essential checkinstall zlib1g-dev -y

Download OpenSSL
cd /usr/local/src/
wget https://www.openssl.org/source/openssl-1.0.2o.tar.gz

Now extract the openssl.tar.gz file, and go to the ‘openssl’ directory.
tar -xf openssl-1.0.2o.tar.gz
cd openssl-1.0.2o

Install OpenSSL
cd /usr/local/src/openssl-1.0.2o

Configure and compile OpenSSL
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib


make
make test
make install

Configure Link Libraries

cd /etc/ld.so.conf.d/
vim openssl-1.0.2o.conf

Paste the openssl library path directory.
/usr/local/ssl/lib

Save and exit.

Reload the dynamic link
sudo ldconfig -v

Configure OpenSSL Binary
mv /usr/bin/c_rehash /usr/bin/c_rehash.BEKUP
mv /usr/bin/openssl /usr/bin/openssl.BEKUP

Edit the ‘/etc/environment’ file using vim.
vim /etc/environment

Now add the new OpenSSL binary directory as below
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/ssl/bin"

Save and exit.

Reload the environment file and test the new updated binary PATH.
source /etc/environment
echo $PATH
which openssl

Testing
openssl version -a

Steps to create Certificate using OpenSSL


Step 1: Create Private Key

genrsaout C:\cert\private.key 1024

 

Step 2: Create intermediate self-signed root CA certificate

reqnew -x509 –days 1826 –key C:\cert\private.key –out C:\cert\rootCert.crt

 

Step 3: Create intermediate private key

genrsaout C:\cert\intermediatekey.key 1024

 

Step 4: Create intermediate request file

reqnewkey C:\cert\intermediatekey.key –out C:\cert\intermediate.csr

 

Step 5: Create intermediate certificate

x509 -req –days 1826 -in C:\cert\intermediate.csr –CA C:\cert\DSS\rootCert.crt -CAkey C:\cert\private.key –set_serial 01 –out C:\cert\intermediateCert.crt

 

Step 6: Package all the above file into .pfx file

 

pkcs12exportout C:\cert\DSS2.pfx –inkey C:\cert\DSS\intermediatekey.key –in C:\cert\intermediateCert.crt –chainCAfile C:\cert\rootCert.crt

Generate WebReferance Proxy using wsdl.exe


To generate web reference for you project use wsdl.exe and then including the generated file (.cs) into your project.

Based on the .NET framework version your wsdl.exe file will exist in corresponding path as below

In case anyone using VS 2008 (.NET v3.5) is also looking for the wsdl.exe.
I found it here:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\wsdl.exe

Future versions C:\Program Files\Microsoft SDKs\Windows\vx.xx\bin\wsdl.exe

For v4.5.1
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\wsdl.exe

For v4.6.1
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\wsdl.exe

Using any one of below command can generate proxy class

wsdl /language:CS /n:”<NameSpaceName>” <Path of wsdl file>.wsdl

wsdl.exe /language:CS <Path of wsdl file>.wsdl

wsdl.exe <Path of wsdl file>.wsdl

Ref: https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-2.0/7h3ystb6(v=vs.80)?redirectedfrom=MSDN