Java Program to Demonstrate How User Authentication is Done
Authentication is the process of verifying the identity of users or information. User authentication is the process of verifying the identity of the user when that user logs in to a computer system. The main objective of authentication is to allow authorized users to access the computer and to deny access to unauthorized users.
Example
Default Assumption: User name = Geeks For Geeks , Password = Geeks For Geeks
Input: User name = Geeks For Geeks, Password = Geeks For Geeks
Output: Authentication Successful
Input: User name = Geeks For Geeks, Password = Hello world
Output: User name/ Password not matching
Approach
- Take username and password as string input from the user.
- Check if the username matches the password or not.
- If it matches then welcome the user.
- Else display an appropriate message.
Below is the implementation of the above approach
Java
import java.util.*;
public class Gfg
{
public static void main(String args[])
{
String user_name = "Geeks For Geeks" ;
String password = "Geeks For Geeks" ;
if (user_name.equals( "Geeks For Geeks" ) && password.equals( "Geeks For Geeks" ))
{
System.out.println( "Authentication Successful" );
}
else
{
System.out.println( "User name/ Password not matching" );
}
}
}
|
Output
Authentication Successful
Last Updated :
04 Nov, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...