In this lecture, let's try to create our first milestone project, which is like first I'll create
a simple spring application, which has one reste service Expo's so that anyone can invoke it.
So first we build the basic spring boat application and we don't put any security to our service and
anyone can invoke it and see the response post that.
I'll also show you how easy to put some security for that service by using default configurations with
the help of spring security framework.
So in order to create a springboard application, I came to the website start that spring that I wore,
which we can use to generate a sample spring boot application based upon the dependencies that we define.
Again, if you are not familiar with Spring but Basic Sandahl, please follow my discussion.
You should be able to understand and follow very easily.
I am going to cover each and every detail throughout this course, like whenever I discussed some angular
code or UI application, backend application or any springboard configurations.
So I'm going to spend some time explaining all those things so that you are comfortable with them along
by putting major focus on spring security framework.
So here I have to select the project as my project type and the language that I want to use is Java
and Springboard version.
I will go with the default version that is Selecter Group I just mentioned come Easybeats and artifact.
I'll mention spring security, basic animal soil maintenance being security.
Basic Project and Description is a demo project for spring security and the package will be populated
automatically and the packaging will be Jatt.
And the Java version that I want to use now is eight.
Now, in order to generate a springboard application, I need to define what dependencies I need.
So first, my focus is only to generate a springboard application with a reservoir is built inside it
so we know how to implement a service.
Inside my springboard application, I will need a dependency, which is bring them.
So I'll just add that dependency.
This is a starter project which will take care of providing all dependencies and just that you'll need
inside your application.
So I'll just click generate here and when I click generate, I'll get a Sampi Mavin skeleton project
will be generated for my configurations that I have defined here.
So what I'm going to do is I'm going to take this zip and extract that into a location where I want
to save my workspace.
So now I'm going to extract my spring security basic project into the same location.
So once it is extracted, you can see there'll be a -- symbol inside it which indicate that
this is Mavin project.
Now I go to my eclipse and import this Mavin project into my workspace.
So here I have to select import projects and type Mavin.
So existing Mavin projects I want to import.
So I'll click next and browse to the location where I have my project extracted.
So you can see I just selected that folder and as soon as I selected will detect a bomb that is present
inside it.
And once I click finish, that entire project will be imported into my workspace.
And at the same time, all the Mavin dependencies that are needed for this bring security basic project
will be imported by the Mavin framework.
So if you don't have Mavin, I would request you to install Mavin inside your system so that it can
detect the bomb that XML dependencies and download all the dependencies that you need.
So if we go and absorb the Pontotoc symbol.
So here I just mentioned that dependency, which is Dr. Vep and by default every spring board application
will get a spring, would start a test dependency as well.
So with this single starter project dependency, I'm able to get all the dependencies that are needed,
like springboard logging and there'll be no tonkatsu, spring core libraries and unit related.
So everything and getting through the help of this project, that's the power of starter projects inside
springboard applications.
If you don't follow Springboard applications development, if you follow traditional way of building
spring applications, you have to define all those jobs dependencies inside your mavin, pondered XML.
But here, with the help of Starter Project, my springboard will take care of getting all those dependencies
for me.
So now let me show you the sample package that got generated.
So this is the package name.
Like, I'm not easy, but it starts being security basic and inside that we have a main springboard
application class and you can identify by seeing the annotations bring good application.
So this does not have any business logic.
So this just a skeleton project.
If I tried to start this project, also, nothing will happen.
It will just start.
But there is no business.
To invoke so far the same, I'll just try to create a new reservists so that we can start this over
and test our reservists that we have created.
So for the same, I am going to create a separate package with the name com dot easybeats dot controller.
And inside that, I'll create a class with the name Welcome Controller.
So inside this welcome controller, I'm going to make some chord changes, which I have already done.
So I just pasted those chord changes to save some time for us.
So but I'll explain to you what changes have done.
So first, I have put an annotation on the controller to indicate to my springboard application that
whatever happens that I'm mentioning inside this class, they will act as error steps.
Inside this I have written a method, say will come with the annotation, get mapping and the parts
will come, which means anyone can invoke my recipe part with the name Slashfilm and the heterotopia
method call that I want to support is get to type.
If we want to support post, you can use post mapping.
But here, since I want to invoke through browser, I just get to mapping.
And what this will come Eppy supports is it will just return a sample Maciste to the user saying welcome
from spring application without security.
So I have my service right now.
What I will do is inside my main springboard application.
Before I start my application, I'll also add an annotation aderet component can and you mentioned the
package near where my welcome control is staying.
So this is a standard that we need to follow.
So whenever we use components and so I'm telling to my springboard application outside the package that
you are sitting, there are other packages.
Please go and scan all those packages and classers annotations.
And whenever my springboard application sees that there is a rest controller get mapping annotation,
it will expose the EPA with the name slash.
Welcome.
So with these changes, we should be good to start our application.
So to start the springboard application, you just have to right click on the Springboard main class
and you run as Java application.
So as soon as I give this command, you can see my server will start.
I didn't add my project to any server because Springwood has an embedded Tomcat server which will be
used to start the project.
So you can see it is started at the port.
Now, in order to access my welcome page and go to the port localhost, obviously this is the hosting
that we have to use and port is 88 and the part that we have for our last Web service.
Welcome.
So as soon as I hit this, you can see I'm getting a response.
So this way, we have built successfully a rare service.
But unfortunately, my Web application and this service does not have any security so anyone can invoke
my service and they can get the response from my application.
Now, I want to show you how easy to implement security for this service with the help of spring security
framework.
So for the same, let me go to the same page like Stoddart's Spring that over the dependency that we
have to add to a springboard project is just type security.
And when you type, you'll get a spring security.
So that's a dependency I have I want to add.
So I'll go and explore the bomb.
Similar cogenitor.
I'm just trying to take this entire on that XML and replace that into my existing Paumgarten XML.
Before that I start my server also.
So let me copy paste my latest on Bartek Sumell and the latest dependency that we have added is springboard
starter security.
I'll build my application now.
See the magic.
I have not added any other configurations.
I'll just go ahead and start my application with the help of Run as Java application and server will
start at the same Port 88 and once the server is started, I'll go to the same location like localhost
88 slash.
Welcome.
I'm going to refresh the page.
You can see here now it is asking me to enter credentials to access my resources so I didn't tell anything
to my springboard application.
Go ahead and protect my welcome AP By default, your spring security framework will protect all the
apps present inside your application.
So we'll discuss how to customize those for which you want to protect, which you want to give full
access to the public in the coming lectures.
For now, I want you to understand the power of spring security framework.
I didn't call anything related to login page.
Still, it is giving me some login.
Which is present inside the framework, so now here it is asking me to enter credentials to access that
resource.
So by default, the user name is user and the password is you can see the random password generator
in the console.
You can use that password.
And if you enter signing, you can see the response now.
So this is the beauty and power of spring security framework that I want you to understand.
And of course, this is not a production grade or production very application.
This is the baby steps that we are taking in the spring security framework.
Now, you may ask me, like, can we use our own user credentials?
Of course we can do that for that.
What I have to do is I just have to open the application.
That property's present inside my project here.
I had to go to properties where I can configure username and password.
So the properties are spring security user dot name, which is easy easybeats.
The user name that I want to use and the password that I want to use is one, two, three, four, five.
So with these changes, I will restart my application.
Now, if you observe in the console, there won't be any password that will be generated by Springs'
framework.
The reason is we have mentioned our own password inside application dot properties.
Now, if I try to refresh the page, it will again as the login and this time I have to enter easy bytes.
And the password is one, two, three, four, five.
So we'll get that response will come from springs' application without security.
Of course we implemented security.
I can update the statements saying that welcome from spring application with security and I'll restart
my application again so that we get the proper message this time.
So I am going to refresh again.
It is going to ask me what are the credentials.
I'll tell easy bytes and password is one, two, three, four, five.
So now you can see I'm getting a proper response this way.
Spring security will help you to implement security inside your web applications.
I know you might have a lot of questions like this is pretty basic.
How do I configure so many users inside my application, their user name credentials?
How do I encrypt decrypted passwords?
How do I store their passwords?
So all these questions will answer in the coming lectures one by one.
Don't worry.
But since I want to start with the basic springboard application with Swing's security enable, I showed
this demo.
I hope this is very clear to you.
I request you to do the same exercise like create a simple springboard application at spring security
dependency target and try playing with it and understand how this is working by doing a coding exercise.
Thank you.
And I'll see you in the next lecture by.