Skip to content

Java _Authentication #8701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Java/Java _Authentication
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
his is a Java Program to Illustrate how User Authentication is Done.
Enter username and password as input strings. After that we match both strings against given username and password. If it matches then Authentication is successfull or else Authentication fails.

Here is the source code of the Java Program to Illustrate how User Authentication is Done. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.



import java.util.Scanner;
public class User_Authentication
{
public static void main(String args[])
{
String username, password;
Scanner s = new Scanner(System.in);
System.out.print("Enter username:");//username:user
username = s.nextLine();
System.out.print("Enter password:");//password:user
password = s.nextLine();
if(username.equals("user") && password.equals("user"))
{
System.out.println("Authentication Successful");
}

else
{
System.out.println("Authentication Failed");
}
}
}