Points To Remember
- Make sure that your CAS Server is up and running. How to set up CAS Rest api with JDBC Authentication.
- You have created a database and have dummy data in it.
Program : Test CAS Rest Api from a Java Code
You can use the following piece of code to test the CAS Rest API.You need to follow the following points for Authentication a user on CAS
- You need to make a GET or POST call depending on your CAS server setup.
- If the Username and Password are correct then you will get a TGT (Ticket Granting Token)
- Now we will make a call to the service url of our application to get the Service Ticket.
- On success you will get a Service Ticket
- If you have service the Service Token, then you have successfully authenticated the user.
- Save this service ticket in a cookie or session, since a service ticket can be used only once
You will get the following type of response if everything is working fine.
string s = username=admin%40gmail.com&password=igdefaultIf the authentication fails at the server then you will get a response like the following
201
https://ekansh:8443/cas/v1/tickets/TGT-3-eeSgMb35iv3TkqYzqekyhjZcGyNwKKq2s94reeoRINtdKJBvjx-ekansh
Tgt is : TGT-3-eeSgMb35iv3TkqYzqekyhjZcGyNwKKq2s94reeoRINtdKJBvjx-ekansh
Service url is : service=http%3A%2F%2Fekansh%3A8090%2F
https://ekansh:8443/cas/v1/tickets/TGT-3-eeSgMb35iv3TkqYzqekyhjZcGyNwKKq2s94reeoRINtdKJBvjx-ekansh
Response code is: 200
200
ST-3-Uagfse2pVB7hR5GL09WB-ekansh
string s = username=ekansh%40ekiras.com&password=pwdTGT - It is the token by the ticket granting token.
400
ST-3-Uagfse2pVB7hR5GL09WB-ekansh - It is the service token.
Comments
Post a Comment