Engineering Full Stack Apps with Java and JavaScript
Security is one of the most important aspects of almost all web applications. There are many areas of concern like client and server machine security, transmission channel security, database security etc.
While most security concerns are the responsibility of server or network administrators, application developers should also be concerned about some of the aspects of security such as authentication, authorization, data integrity and confidentiality.
Authentication
is the process of verifying if the user, usually with a username and password.
Once authenticated, we may call a user as an authenticated user or a logged in user.
Authorization
is the process of checking if a user is allowed to access a particular resource on the server.
Data integrity
is the process of verifying if data is transmitted without corruption or modification, thus making sure that the data received at the receiver end is in fact the same message sent by the sender.
Confidentiality
is the process of maintaining data privacy wherein we secure the communications channel, to make sure the data is not accessed in its original form by a third party by eavesdropping.
Java EE provides four different ways to authenticate a user:
Basic Authentication
Digest Authentication
Form Authentication
SSL Certificates
Data used to authenticate a user are called credentials; while the first three rely on username and password provided by user, the fourth one relies on encryption techniques and certificates.
Authorization may be done in different ways, including:
Programmatically controlling access to resources based on individual user’s credentials.
Assigning users into different groups called roles and assigning permissions based on the roles
Steps for role based authorization can be summarized as:
Define roles, users and create mapping between them
Define resource collections to which security should be applied
Map roles with security constraints
Confidentiality and data integrity are related to securing the communications channel.
We can declaratively specify what level of channel security you need: NONE, INTEGRAL or CONFIDENTIAL (implies INTEGRAL).
Java EE allows us to define these security requirements, mainly in three ways:
We can declaratively declare security requirements for an individual or set of resources through the deployment descriptor (web.xml)
We can declare security requirements for individual components through the use of annotations.
We can program security requirements using Java code rather than relying on containers declarative security model.
We will see all these in detail in further notes in this notebook.