Archit ITS Report
Archit ITS Report
Submitted
Dr. to:Jha
Pradeep Submitted
Archit to:
Mathur
Head of Department
CSE/IT/AI&DS 22EGJCS037
Certificate
IMs.
takeKangana
this opportunity
Saini, Institute
Assistant
Acknowledgement
to express my deep
Professor sense of gratitude
Department of Computerto myScience
coordinatorand
Engineering
and Global
cooperation throughout of
the Technology,
Practical Jaipur,
training for
work. his
He valuable
provided guidance
constant
Encouragement
Work. WePracticaland unceasing
are grateful enthusiasm
to ourperiod.
respected Dr. at
ICevery stagePrincipal
Sharma, of the practical
GIT for training
guiding
us
We during
express our Training
indebtedness to Dr. Pradeep Jha, Head of Department of for
Computer
providing Science
metimely and Engineering,
ampleguidance,
support during Global Institute
my Practical of Technology,
Training period. Jaipur
Without their
support
seemed and
a farfetched dream. Inthe completion
this respect we offind
our Practical
ourselves Training
lucky to would
have have
mentors
Place ofsuch
– GIT a great potential.
Jaipur Archit Mathur
B Tech 5th Semester,22EGJCS037
3rd year
This Industrial Training Seminargained
(ITS) report Abstract
provides
extensive
Technology
Technology, handsome
program
Jaipur. experience
in
The Computer
report Science
documents during
and
a the thirdanyear
Engineering
comprehensive
overview
ofGlobalofInstitute
the ofof
the Bachelor
atexploration of
Java, Springthe
Throughout
technologies,
Loops,
Boot and Microservices
training,
including
patterns, the
Core
Functions, student
Java
Object
on the
acquired
topics
Oriented
internet.
proficiency
including basic
Programming in a wide
variables,
language array
– of Core
conditions
Inheritance,
Objects, File
Multithreading Polymorphism,
Handling,
Spring, Encapsulation,
Exception
Spring Boot,Handling, Abstraction;
Collections,
Microservices. Interfaces, Classes &
Generics,through real
The
worldreport
create outlines
projects,
inbuilding the practical
emphasizing
next-generation applications
their role in of
Backend
applications. these
Theandtechnologies
the
training opportunities
has not onlythey
equipped
the student
understanding withinvaluable
of the technical skillsItconcludes
but has alsobyfostered a deeper
and
for user-centered
further
student's growth
future andsignificanceof
web
career design
exploration
aspirations. inversion
principles.
the fieldcontrol, collaborative
oftechnology and itsdevelopment,
reflecting impact on the
Chapter – 11.1
Basics
Table Of Contents
............................................................................................................ 1
................................................................................................................... 1
1.2
1.3 Datatypes
Variables
Conditionals ........................................................................................................
.........................................................................................................
.................................................................................................... 11
1.4
1.5 Methods
Loops
Object .......................................................................................................
..............................................................................................................
Oriented .....................................................................................................
Programming 1
............................................................................. 22
2.1
2.3 Inheritance
2.2Encapsulation
Polymorphism
Abstraction ...............................................................................................
....................................................................................................
2.4 .................................................................................................
Interfaces................................................................................................................ 2
Exception
Multithreading
Spring Handling...................................................................................................... 4356
..............................................................................................
....................................................................................................................
Boot ............................................................................................................7
Fine - Grained Authentication .............................................................................. 8
What is Permit .......................................................................... 9
Prerequisites .............................................................................10
What is Fine-Grained Authorization? ..................................... 11
How to Implement FGA in Java and Spring Boot....................12
Setting Up the E-commerce Application.................................13
Conclusion ...............................................................................14
Chapter – 1
Introduction Basics
Java is one of the most popular and widely used programming language and
platform. A platform is an environment that helps to develop and run
programs written in any programming language. Java is fast, reliable and
secure. From desktop to web applications, scientific supercomputers to
gaming consoles, cell phones to the Internet, Java is used in every nook and
corner.
Therefore, below are the basics of Java in the format in which it will help you
the most to get the headstart:
Primitive Data Type: such as boolean, char, int, short, byte, long, float, and
double. The Boolean with uppercase B is a wrapper class for the primitive
data type boolean in Java.
Non-Primitive (Reference) Data Types
The Non-Primitive (Reference) Data Types will contain a memory address
of variable values because the reference types won’t store the variable value
directly in memory. They are strings, objects, arrays, etc.
1. Strings
1.2 Conditions
The Java if statement is the most simple decision-making statement. It is
used to decide whether a certain statement or block of statements will be
executed or not i.e. if a certain condition is true then a block of statements is
executed otherwise not.
Example:
• Data Type – The kind of data that it can hold. For example, int, string,
float, char, etc.
• Variable Name – To identify the variable uniquely within the scope.
• Value – The data assigned to the variable.
There are three types of variables in Java – Local, Instance, and Static.
Example:
// Declaring float variable
float simpleInterest;
1. Local Variables
2. Instance Variables
3. Static Variables
‘To use the Scanner we need to import the Scanner class from the util package
as
import java.util.Scanner;
1.4 Methods
Jav Met
The method in Java or Methods of Java is a collection of statements that perform
some specific tasks and return the result to the caller. A Java method can perform
some specific tasks without returning anything. Java Methods allows us to reuse the
code without retyping the code. In Java, every method must be part of some class that
is different from languages like C, C++, and Python.
• A method is like a function i.e. used to expose the behavior of an object.
• It is a set of codes that perform a particular task.
Syntax of Method:
Method Declaration
1. Modifier: It defines the access type of the method i.e. from where it can be
accessed in your application. In Java, there 4 types of access specifiers.
1.5 Loops
Loops in Java come into use when we need to repeatedly execute a block of
statements. Java for loop provides a concise way of writing the loop
structure. The for statement consumes the initialization, condition, and
increment/decrement in one line thereby providing a shorter, easy-to-debug
structure of looping. Let us understand Java for loop with Examples.
Syntax:
for (initialization expr; test expr; update exp)
{
// body of the loop
// statements we want to execute
}
• Initialization Expression
• Test Expression
• Update Expression
1. Initialization Expression
Example:
int i=1;
2. Test Expression
Example:
i <= 10
3. Update Expression:
Example:
i++;
Chapter – 2
Object Oriented Programming
Object-Oriented Programming or Java OOPs concept refers to languages
that use objects in programming, they use objects as a primary source to
implement what is to happen in the code. Objects are seen by the viewer or
user, performing tasks you assign.
Inheritance
Java
1
//base class or parent class or super class
2
class A{
3
//parent class methods
4
void method1(){}
5
void method2(){}
6
}
7
8
//derived class or child class or base class
9
class B extends A{ //Inherits parent class methods
10
//child class methods
11
void method3(){}
12
void method4(){}
13
}
Polymorphism
Java
1
sleep(1000) //millis
2
sleep(1000,2000) //millis,nanos
Types of Polymorphism
Polymorphism in Java is mainly of 2 types as mentioned below:
1. Method Overloading
2. Method Overriding
Method Overloading and Method Overriding
Encapsulation
Data Abstraction is the property by virtue of which only the essential details
are displayed to the user. The trivial or non-essential units are not displayed
to the user. Ex: A car is viewed as a car rather than its individual components.
Data Abstraction may also be defined as the process of identifying only the
required characteristics of an object, ignoring the irrelevant details. The
properties and behaviors of an object differentiate it from other objects of
similar type and also help in classifying/grouping the object.
Consider a real-life example of a man driving a car. The man only knows that
pressing the accelerators will increase the car speed or applying brakes will
stop the car, but he does not know how on pressing the accelerator, the speed
is actually increasing. He does not know about the inner mechanism of the car
or the implementation of the accelerators, brakes etc. in the car. This is what
abstraction is.
Java Classes
A class in Java is a set of objects which shares common characteristics/
behavior and common properties/ attributes. It is a user-defined blueprint or
prototype from which objects are created. For example, Student is a class
while a particular student named Ravi is an object.
Java Objects
An object in Java is a basic unit of Object-Oriented Programming and
represents real-life entities. Objects are the instances of a class that are
created to use the attributes and methods of a class. A typical Java program
creates many objects, which as you know, interact by invoking methods. An
object consists of :
Class Interface
A class can contain concrete (with The interface cannot contain concrete
implementation) methods (with implementation) methods.
The access specifiers used with
In Interface only one specifier is used-
classes are private, protected, and
Public.
public.
Implementation: To implement an interface, we Ch
implements use –5
theException
keyword Handling
Exception Handling in Java is one of the effective means to handle runtime errors so
that the regular flow of the application can be preserved. Java Exception Handling is a
mechanism to handle runtime errors such as ClassNotFoundException, IOException,
SQLException, RemoteException, etc.
Let us discuss the most important part which is the differences between Error and
Exception that is as follows:
• Error: An Error indicates a serious problem that a reasonable application
should not try to catch.
• Exception: Exception indicates conditions that a reasonable application might
try to catch.
Ch – 6 Multithreading
2
Threads are the backbone of multithreading. We are living in a real world which in itself
is caught on the web surrounded by lots of applications. With the advancement in
technologies, we cannot achieve the speed required to run them simultaneously unless
we introduce the concept of multi-tasking efficiently. It is achieved by the concept of
thread.
Real-life Example of Java Multithreading
Suppose you are using two tasks at a time on the computer, be it using Microsoft Word
and listening to music. These two tasks are called processes . So you start typing in
Word and at the same time start music app, this is called multitasking . Now you
committed a mistake in a Word and spell check shows exception, this means Word is a
process that is broken down into sub-processes. Now if a machine is dual-core then one
process or task is been handled by one core and music is been handled by another core.
In the above example, we come across both multiprocessing and multithreading. These
are somehow indirectly used to achieve multitasking. In this way the mechanism of
dividing the tasks is called multithreading in which every process or task is called by a
thread where a thread is responsible for when to execute, when to stop and how long to
be in a waiting state. Hence, a thread is the smallest unit of processing whereas
multitasking is a process of executing multiple tasks at a time.
It is a static method that puts the thread to sleep for a certain time
sleep()
been passed as an argument to it
notifyAl
It gives out a notification to all the thread in the waiting state
l()
setDae
It set the current thread as Daemon thread
mon()
Streams in Java
Applications of Spring
1. POJO Based: Spring allows developers to use POJOs to create
enterprise-class apps. The advantage of using simply POJOs is that
you don’t require an EJB container product like an application server;
instead, you may use a powerful servlet container like Tomcat or a
commercial product.
2. Modular : Spring is set up in a modular approach. Even if there are a lot
of packages and classes, you only need to worry about the ones you
need and ignore the rest.
3. Integration with Existing Frameworks: Spring does not reinvent the
wheel; rather, it makes extensive use of existing technologies such as
numerous ORM frameworks, logging frameworks, JEE, Quartz, and JDK
timers, and other view technologies.
4. Testability: Because environment-dependent code is put into this
framework, testing a Spring-written application is trivial. Furthermore,
using JavaBeanstyle POJOs makes it easier to employ dependency
injection for injecting test data.
5. Web MVC: Spring’s web framework is a well-designed web MVC
framework that is an excellent alternative to web frameworks like
Struts and other over-engineered or less popular web frameworks.
6. Central Exception Handling: Spring provides a handy API for
converting technology-specific exceptions (such as those raised by
JDBC, Hibernate, or JDO) into consistent, unchecked exceptions.
7. Lightweight: IoC containers are typically lightweight, especially when
compared to EJB containers, for example. This is useful for creating and
distributing programmers on systems with limited memory and CPU
resources.
8. Features of the Spring Framework
9. The features of the Spring framework such as IoC, AOP, and
transaction management, make it unique among the list of frameworks.
Some of the most important features of the Spring framework are as
follows:
10. IoC container:
Refers to the core container that uses the DI or IoC pattern to implicitly
provide an object reference in a class during runtime. This pattern acts
as an alternative to the service locator pattern. The IoC container
contains assembler code that handles the configuration management
of application objects.
The Spring framework provides two packages, namely org.spring
framework.beans and org.springframework.context which helps in
providing the functionality of the IoC container.
11. Data access framework:
Allows the developers to use persistence APIs, such as JDBC and
Hibernate, for storing persistence data in database. It helps in solving
various problems of the developer, such as how to interact with a
database connection, how to make sure that the connection is closed,
how to deal with exceptions, and how to implement transaction
management It also enables the developers to easily write code to
access the persistence data throughout the application.
12. Spring MVC framework:
Allows you to build Web applications based on MVC architecture. All
the requests made by a user first go through the controller and are
then dispatched to different views, that is, to different JSP pages or
Servlets. The form handling and form validating features of the Spring
MVC framework can be easily integrated with all popular view
technologies such as ISP, Jasper Report, FreeMarker, and Velocity.
13. Transaction management:
Helps in handling transaction management of an application without
affecting its code. This framework provides Java Transaction API (JTA)
for global transactions managed by an application server and local
transactions managed by using the JDBC Hibernate, Java Data Objects
(JDO), or other data access APIs. It enables the developer to model a
wide range of transactions on the basis of Spring’s declarative and
programmatic transaction management.
14. Spring Web Service:
Generates Web service endpoints and definitions based on Java
classes, but it is difficult to manage them in an application.
Ch - 9 Spring Boot
What is Spring Boot?
Spring Boot is an open-source Java framework used to create a Micro Service.
Spring boot is developed by Pivotal Team, and it provides a faster way to set
up and an easier, configure, and run both simple and web-based applications.
It is a combination of Spring Framework and Embedded Servers. The main goal
of Spring Boot is to reduce development, unit test, and integration test time
and in Spring Boot, there is no requirement for XML configuration.
💡
Then open the code in your Java IDE. I used JetBrains for all my
work.
Installing Permit package SDK
To install the Permit package SDK, you add the SDK under the
dependencies block in the build.graddle file.
## Dependencies
`build.gradle` file:
```groovy
dependencies {
implementation
'org.springframework.boot:spring-boot-starter-
web'
implementation 'org.springdoc:springdoc-
openapi-starter-webmvc-ui:2.3.0'
developmentOnly
'org.springframework.boot:spring-boot-devtools'
testImplementation
'org.springframework.boot:spring-boot-starter-
test'
testRuntimeOnly 'org.junit.platform:junit-
platform-launcher'
// Add this line to install the Permit.io Java SDK in your project
implementation 'io.permit:permit-sdk-
java:2.0.0'
}
package com.boostmytool.store.config;
import io.permit.sdk.Permit;
import io.permit.sdk.PermitConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
package com.boostmytool.store.service;
import com.boostmytool.store.exception.ForbiddenAccessException;
import com.boostmytool.store.exception.UnauthorizedException;
import io.permit.sdk.Permit;
import io.permit.sdk.api.PermitApiError;
import io.permit.sdk.api.PermitContextError;
import io.permit.sdk.enforcement.Resource;
import io.permit.sdk.enforcement.User;
import org.springframework.stereotype.Service;
import java.io.IOException;
/**
* Simulates user login by creating and returning a Permit User object.
*
* @param key User's unique key
* @return User object
*/
/**
* Handles user signup by creating and syncing a new Permit User.
*
* @param key User's unique key
* @return Created and synced User object
*/
return user;
}
/**
* Assigns a role to the user within the "default" environment.
*
* @param user User object to assign the role to
* @param role Role to be assigned
*/
permit.api.users.assignRole(user.getKey(),
role, "default"); // Assigns role in the "default" environment
/**
* Checks if the user is authorized to perform a specific action on a
resource.
*
* @param user User object requesting authorization
* @param action Action to be authorized
* @param resource Resource on which the action will be performed
* @throws UnauthorizedException if user is not logged in
* @throws ForbiddenAccessException if user is denied access
*/
resource) {
if ( user == null) {
throw new UnauthorizedException("Not logged in"); //
Throws exception if user is not logged in
}
try {
permitted = permit.check(user,
var
Conclusion
This industrial training seminar has equipped me with not just
technical skills, but a profound understanding of the entire
Spring boot ecosystem. It bridges the gap between the client-
facing interface and the server-side logic, empowering me as a
Java Dev. Beyond the technical aspects, this training has
emphasized the significance of collaboration, version control,
and adhering to best practices—a combination that is
indispensable when working within a development team.
In conclusion, this Industrial Training Seminar serves as a solid
foundation for continued growth and exploration in the domain
of web development. It is not merely about mastering
technologies; it is about harnessing them to create innovative
and impactful web applications. The knowledge gained here is a
springboard into the ever-evolving field of web development,
where creativity, problem-solving, and the pursuit of excellence
are the driving forces. The integration of design, deployment,
and security measures has equipped us to build web applications
that not only meet the demands of today's digital landscape but
also thrive in it. Whether it is designing beautiful user interfaces,
building powerful backends, or securing web applications, we
now possess the tools and understanding to excel.