Skip to main content

Posts

Showing posts with the label Authentication

Youtube Data Api v3 : Authenticate User

Points To Remember You must have a project created in Developers console to use Youtube data api and other api's. You should save the youtube refresh token in a database or file where you can save it for a long time and use it. Youtube refresh token is generated only once , so if you want to regenerate it go to google accounts page  and revoke access to your project and then re authenticate. To revoke access, go to Connected Apps and Sites  in the above mentioned url and click on your project and then click revoke access to revoke access to the app. Steps to Use Youtube Data Api v3 You need to create a new Project in your at  Developers Console . After creating a project you need to go to  Project -> Api & auth -> Credentials  , and then create a new  Client ID . Go to  Project -> Api & auth ->APIs  and enable  Youtube Analytics API  and  YouTube Data API v3 . This will enable your project to use consume these a...

How to create SSL Certificate and add it to Keystore

Points To Remember You need to have a SSL certificate o run an application/ server on https. You can create a SSL certificate using keytool. The keystore file for Java is available in Java/jre/lib/security/cacerts. Default password of the keystore is "changeit". Create a Keystore You can make a SSL certificate by following the steps below. Open a Command-line or Terminal window and make sure you're in your home directory. Execute the following command in the terminal keytool -genkey -alias tomcat -keyalg RSA -validity 365 NOTE, the validity parameter allows you to specify, in the number of days, how long the certificate should be valid for. The longer the time period, the less likely you are to need to recreate it. To recreate it, you'd need to delete the old one and then follow these instructions again. The response will look something like this: Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: $MACHINE_NAME What is the ...

Test CAS Rest API from Java Code

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=igdefault 201 https://ekansh:84...

CAS Rest API Integration and Testing

Points To Remember Please refer to blog How to set up CAS server with database . Now we are going to use the same authentication process through rest api and test it. Step 1: Adding dependency in pom.xml First thing that we need to do here is to add the CAS Rest Api  dependencies to pom.xml so that we can get the related jars in the class path. <dependency> <groupId>org.jasig.cas</groupId> <artifactId>cas-server-integration-restlet</artifactId> <version>${cas.version}</version> <type>jar</type> </dependency> Note : Here we are using CAS v4.0.0 Step 2: Mapping Servlet in web.xml Now, we need to map the restlet servlet in the web.xml. For this copy the previously generated web.xml from the war file and add the following lines in the web.xml file. This will register the servlet and the url pattern with which this servlet can be accessed. Here we are using v1/*  as the url mapping, you can customize...

How to setup & configure CAS with Database

Points To Remember You can user MYSQL, Oracle or PostgreSQL connectors as the database. Make sure you have created a SSL certificate to run the CAS server on browser. Step 1: Adding Dependencies in pom.xml Add the following dependencies to the pom.xml that we created in this tutorial.  These are the dependencies that are required to authenticate the user using the database. <dependency> <groupId>org.jasig.cas</groupId> <artifactId>cas-server-support-generic</artifactId> <version>${cas.version}</version> <type>jar</type> <scope>runtime</scope> </dependency> <dependency> <groupId>org.jasig.cas</groupId> <artifactId>cas-server-support-jdbc</artifactId> <version>${cas.version}</version> </dependency> <dependency> <groupId>c3p0</gr...

How to setup and configure CAS - Central Authentication Service

Points To Remember CAS works on Maven WAR overlay  technique. You need to create a SSL certificate to use CAS and run it over https to enable SSO(single sign on). How to create a SSL certificate and add it to keystore. You can use LDAP, Database and Active Directory techniques to authenticate the user. Requirements You need to have Java SDK v1.6 or greater. Servlet Containers like Tomcat , Websphere, JBoss etc.  Apache Maven v3.0 or greater. Authentication technique related dependencies. For the sake of simplicity let us assume that out application path is PROJECT = /home/ekiras/cas and our tomcat path is TOMCAT = /home/ekiras/apache Step 1 : Create pom.xml You need to create a pom.xml to create the war file and package it. lets create the pom file in the project directory i.e. PROJECT/pom.xml Add the following code to the pom. <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http:...