1.Oracle has a data type TIMESTAMP,
which can also represent a date (with time). If you subtract TIMESTAMP values, you get an INTERVAL .
To extract numeric values ,use the EXTRACT function.
select
extract( day from diff ) Days,
extract( hour from diff ) Hours,
extract( minute from diff ) Minutes ,
( extract( day from diff ) 24*60*60*60 + extract( hour from diff )60*60*60 +
extract( minute from diff )*60*60 ) TotalMiliSecResult
from (
select ( CAST( action_time as timestamp) - CAST( idle_time as timestamp) ) diff
from mwt_idle_wallet
);
Version :- 1.0.0
Saturday, July 20, 2019
Sunday, June 16, 2019
Array Vs Collections in Java
Java offers two types of constructs where you can store multiple objects of the same type: Arrays and Collections. They have following differences and features .
- Array fixed sized and Collections is dynamic sized (Collections automatically expand in size when needed)
- Due to above reason Collections are preferred over Arrays with respect to memory.
- Array can contain both primitive data types as well as objects of a class depending on the definition of the array. However, Collections only supports object entries, not the primitive data types
- With respect to performance its better to use arrays but with respect to performance collection are not good to use.
References Used :- array-vs-arraylist-in-java
Version :- 1.0.0
Wednesday, June 12, 2019
HTTP vs HTTPS
What is HTTP?
HTTP is stands for Hypertext Transfer Protocol. HTTP offers set of rules and standards for web browsers & servers to communicate and govern how any information can be transmitted on the World Wide Web.HTTP is an application layer network protocol which is built on top of TCP. HTTP uses Hypertext structured text which establishes the logical link between nodes containing text. It is also known as "stateless protocol".
Advantages of HTTP:
- HTTP can be implemented with other protocol on the Internet, or on other networks
- HTTP pages are stored on computer and internet caches, so it is quickly accessible
- Platform independent which allows cross-platform porting
- Does not need any Run time support
- Usable over Firewalls! Global applications are possible
- Not Connection Oriented; so no network overhead to create and maintain session state and information
Limitations of HTTP
- There is no privacy as anyone can see content
- Data integrity is a big issue as someone can alter the content. That's why HTTP protocol is an insecure method as no encryption methods are used.
- Anyone who intercepts the request can get the username and password.
What is HTTPS?
HTTPS is stands for Hyper Text Transfer Protocol Secure. It is highly advanced and secure version of HTTP. It uses the port no. 443 for Data Communication. It allows the secure transactions by encrypting the entire communication with SSL. It is a combination of SSL/TLS protocol and HTTP. It provides encrypted and secure identification of a network server.Allows you to create a secure encrypted connection between the server and the browser. It offers the bi-directional security of Data. This helps you to protect potentially sensitive information from being stolen.
In HTTPS protocol SSL transactions are negotiated with the help of key-based encryption algorithm.
Advantages of HTTPS
- In most cases, sites running over HTTPS will have a redirect in place. Therefore, even if you type in HTTP:// it will redirect to an https over a secured connection
- SSL technology protects any users and builds trust
- An independent authority verifies the identity of the certificate owner. So each SSL Certificate contains unique, authenticated information about the certificate owner.
- It allows users to perform critical transactions such as online banking.
Limitations of HTTPS
- HTTPS protocol can't stop stealing confidential information from the pages cached on the browser
- SSL data can be encrypted only during transmission on the network. So it can't clear the text in the browser memory
- HTTPS can increase computational overhead as well as network overhead of the organization
Difference Between HTTP and HTTPS
| Parameter | HTTP | HTTPS |
|---|---|---|
| Protocol | It is hypertext transfer protocol. | It is hypertext transfer protocol with secure. |
| Security | It is less secure as the data can be vulnerable to hackers. | It is designed to prevent hackers from accessing critical information. It is secure against such attacks. |
| Port | It uses port 80 by default | It was use port 443 by default. |
| Starts with | http:// | https:// |
| Used for | It's a good fit for websites designed for information consumption like blogs. | If the website needs to collect the private information such as credit card number, then it is a more secure protocol. |
| Scrambling | HTTP does not scramble the data to be transmitted. That's why there is a higher chance that transmitted information is available to hackers. | HTTPS scrambles the data before transmission. At the receiver end, it descrambles to recover the original data. Therefore, the transmitted information is secure which can't be hacked. |
| Protocol | It operates at TCP/IP level. | HTTPS does not have any separate protocol. It operates using HTTP but uses encrypted TLS/SSL connection. |
| Domain Name Validation | HTTP website do not need SSL. | HTTPS requires SSL certificate. |
| Data encryption | HTTP website doesn't use encryption. | HTTPS websites use data encryption. |
| Search Ranking | HTTP does not improve search rankings. | HTTPS helps to improve search ranking. |
| Speed | Fast | Slower than HTTP |
| Vulnerability | Vulnerable to hackers | It Is highly secure as the data is encrypted before it is seen across a network. |
Description of short terms
Secure Sockets Layer (SSL) : is the standard security technology for establishing an encrypted link between a web server and a browser. This link ensures that all data passed between the web server and browsers remain private and integral.
Transport layer security (TLS) : is a protocol that provides communication security between client/server applications that communicate with each other over the Internet.
Stateless Protocol : each command is executed separately, without using reference of previous executions .
References Used :- difference-http-vs-https.html
Version :- 1.0.0
Saturday, April 27, 2019
Technology Stack ,What We Love
Actually most of us not gets to work with the
technology stack we love. Even if the opportunities have not been
presented yet, it is mighty important to keep learning and practicing
the things you love. Because, we never know when the opportunity will
come knocking on your door. Mastering a language or a technology could
prove to be difficult, if we do not back our self and predict the
future developments based on the current context. The struggle could
prove to be immense, if we lose our direction in an industry that
changes everyday. Trust your instincts, take a leap of faith and let
our effort determine our success!
References Used :- Blog.zone24x7 > The-challenges-and-struggles-software-engineers-face-today
References Used :- Blog.zone24x7 > The-challenges-and-struggles-software-engineers-face-today
Monday, March 25, 2019
Basic Security Threats , Technologies and Tools Used for Security and control
Computer crimes reported by most of the organizations may be related to different types of security problems such as
'Malware' includes
In simple words,
Sniffing means to illegally listen into another's conversation
Spoofing means to pretend to be someone else.
Sniffing and spoofing are security threats that target the lower layers of the networking infrastructure supporting
applications that use the Internet.
Sniffing is a passive security attack in which a machine separate from the intended destination reads data on a network.
Spoofing is an active security attack in which one machine on the network masquerades as a different machine.
This masquerade aims to fool other machines on the network into accepting the impostor as an original, either to lure
the other machines into sending it data or to allow it to alter data.
Identity theft is a form of stealing someone's identity.
Someone pretends to be someone else in identity theft, by assuming that person's identity, usually as
a method to gain access to resources or obtain credit and other benefits in that person's name.
What-is-the-difference-between-spoofing-and-sniffing
'Malware' includes
- Computer Viruses - computer programs that can spread across computers and networks by making copies of itself without the user's knowledge.
- Worms - similar to viruses but do not need a carrier program or document. create exact copies of themselves and use a network to spread.
- Trojan Horses - programs that pretend to be legitimate software, but actually carry out hidden, harmful functions.
- Spyware - includes methods to collect information about the use of the computer on which the software is installed.
In simple words,
Sniffing means to illegally listen into another's conversation
Spoofing means to pretend to be someone else.
Sniffing and spoofing are security threats that target the lower layers of the networking infrastructure supporting
applications that use the Internet.
Sniffing is a passive security attack in which a machine separate from the intended destination reads data on a network.
Spoofing is an active security attack in which one machine on the network masquerades as a different machine.
This masquerade aims to fool other machines on the network into accepting the impostor as an original, either to lure
the other machines into sending it data or to allow it to alter data.
Identity theft is a form of stealing someone's identity.
Someone pretends to be someone else in identity theft, by assuming that person's identity, usually as
a method to gain access to resources or obtain credit and other benefits in that person's name.
Phishing
is the act of attempting to acquire information such as usernames, passwords, and credit card details by
masquerading as a trustworthy entity in an electronic communication.
E.g.s
an e-mail can be sent to the victim
luring the victim to enter a site and when entered, information
such as
usernames, passwords and credit card information may be collected by the
criminal posing as the victim’s bank site.
These tools and techniques address how to:
Virus scanners, firewalls and Intrusion Detection Systems (IDS) .
References Used :- BIT UCSC Notes
Technologies and Tools Used for Security and control
These tools and techniques address how to:
- Authentication - Verify that users are who they say they are .
- Authorization - Control access to data and functions .
- Data Privacy and Integrity - Protect the privacy and integrity of information assets.
- Non-Repudiation - Ensure non-repudiation, so parties can't deny their actions .
Virus scanners, firewalls and Intrusion Detection Systems (IDS) .
| These techniques and tools cannot alone provide information security. Limiting physical access to servers, routers and other systems is required. By physically reorganizing or consolidating information assets, we can simplify the management of those assets while increasing their security. These servers and the other computer infrastructures should be physically protected as well.
Security Audits
The information security status of critical IT environments should be subject to thorough, independent and regular security audits/reviews.
In principle, security audits/reviews should be:
|
What-is-the-difference-between-spoofing-and-sniffing
Friday, January 25, 2019
Useful ways to working with Strings in Java
- When we want to print a array , We can use this way
System.out.println( Arrays.toString( text .split("a") ) );
The string you give
split defines a regular expression, so any characters special in regular expressions have to be escaped:
String[] parts = string.split("\\$@");
- When we want to convert List <String> stringListValues , to string value . We can use following way
- When we have string values set such as String names = "Saman , Kumara , Ramanayaka " ; and we want
String[] nameArray = names.split( " , " );
- String newStringValue = String.join( "-> ", "Wake up", "Eat", "Play", "Sleep", "Wake up" );
Output will be : Wake up-> Eat-> Play-> Sleep-> Wake up
- To reverse a string
String stringObj= "Hiiiiii Kamlal";
StringBuffer stringBufferObj = new StringBuffer( stringObj );
stringBufferObj.reverse();
Version : - 1.1.0
Tuesday, January 22, 2019
Singleton Class in Java
In object-oriented programming, a singleton class is a class that can have only one object (an instance of the class) at a time.
After first time, if we try to instantiate the Singleton class, the new variable also points to the first instance created. So whatever modifications we do to any variable inside the class through any instance, it affects the variable of the single instance created and is visible if we access that variable through any variable of that class type defined.
To design a singleton class:
In terms of practical use Singleton patterns are used in logging, caches, thread pools, configuration settings, device driver objects.
Configuration File: This is another usage of Singleton pattern because this has a performance benefit as it prevents multiple users to repeatedly access and read the configuration file or properties file. It creates a single instance of the configuration file which can be accessed by multiple calls concurrently as it will provide static config data loaded into in-memory objects. The application only reads from the configuration file at the first time and there after from second call onwards the client applications read the data from in-memory objects
We can use the cache as a singleton object as it can have a global point of reference and for all future calls to the cache object the client application will use the in-memory object
Why can’t we use a static class instead of singleton?
References Used :- singleton-class by geeksforgeeks
dzone.com- singleton-design-pattern
After first time, if we try to instantiate the Singleton class, the new variable also points to the first instance created. So whatever modifications we do to any variable inside the class through any instance, it affects the variable of the single instance created and is visible if we access that variable through any variable of that class type defined.
To design a singleton class:
- Make constructor as private.
- Write a static method that has return type object of this singleton class. Here, the concept of Lazy initialization in used to write this static method
public class Singleton {
private static final Singleton instance = new Singleton();
private Singleton() {}
public static Singleton getInstance() {
return instance;
}
}
In terms of practical use Singleton patterns are used in logging, caches, thread pools, configuration settings, device driver objects.
Configuration File: This is another usage of Singleton pattern because this has a performance benefit as it prevents multiple users to repeatedly access and read the configuration file or properties file. It creates a single instance of the configuration file which can be accessed by multiple calls concurrently as it will provide static config data loaded into in-memory objects. The application only reads from the configuration file at the first time and there after from second call onwards the client applications read the data from in-memory objects
We can use the cache as a singleton object as it can have a global point of reference and for all future calls to the cache object the client application will use the in-memory object
Why can’t we use a static class instead of singleton?
- One of the key advantages of singleton over static class is that it can implement interfaces and extend classes while the static class cannot (it can extend classes, but it does not inherit their instance members). If we consider a static class it can only be a nested static class as top level class cannot be a static class. Static means that it belongs to a class it is in and not to any instance. So it cannot be a top level class.
- Another difference is that static class will have all its member as static only unlike Singleton.
- Another advantage of Singleton is that it can be lazily loaded whereas static will be initialized whenever it is first loaded.
- Singleton object stores in Heap but, static object stores in stack.
- We can clone the object of Singleton but, we can not clone the static class object.
- Singleton can use the Object Oriented feature of polymorphism but static class cannot.
References Used :- singleton-class by geeksforgeeks
dzone.com- singleton-design-pattern
Version :- 1.1.0
Subscribe to:
Posts (Atom)
Some interesting things to explore more
Here some some things to study more , How Google Search works https://developers.google.com/search/docs/fundamental...
-
"Injection attacks": Common Types of Injection Attacks : There are several types of injection attacks, including SQL injection,...
-
The AI-Driven Software Developer: Optimize, Innovate, Transform": AI Transformation in Software Development : Understand how AI is re...
-
With Java 25 , One interesting changes can view is JEP 512, "Compact Source Files and Instance Main Methods," significa...
