検索
認証JavaAug 30, 2024 pm 03:58 PM
java

認証 Java は、Web アプリケーションの本人確認に対するセキュリティの用語です。プログラミング言語を使用してWebサイト・Webアプリケーションの本人確認を行う機能です。ユーザーの使用を確認し、Java テクノロジーを使用した Web サイト、アプリケーション、ソフトウェア関連製品へのアクセスを許可します。 Java言語のセキュリティ規約を利用して、許可されたユーザーを特定し、アプリケーションの使用を許可するセキュリティ方式です。

無料ソフトウェア開発コースを始めましょう

Web 開発、プログラミング言語、ソフトウェア テスト、その他

これは、独自のコンテンツを使用し、セキュリティ パスワードとユーザー ID で確認するためのクライアントおよびサーバー側の機能です。クライアント側でユーザー ID とパスワードを使用し、Java プログラミング言語を使用して真の識別情報を使用してサーバー側データにアクセスします。これは、Web アプリケーションを安全に保ち、アクセス可能なチーム メンバーのみを使用するための文書化プロセスです。

構文

この構文は、生徒、教師、非教職員、校長など、ユーザーの特定のブランチを認証するために使用されます。ユーザー名、電子メール ID、パスワードを使用してログインし、本人確認を行うことができます。

この構文では、アプリケーションは認証にユーザー名とパスワードを使用します。

public class AppSecurityConfig extends AppSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder authentic) throws Exception {
UserBuilder userid = User.withDefaultPasswordEncoder();
authentic.inMemoryAuthentication()
.withUser(usersid.username("merry").password("test@123").roles("student"))
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/").hasRole("student")
.and()
.formLogin()
.loginPage("/useLoginPage")
.loginProcessingUrl("/authenticatationUser")
.permitAll()
.and()
.logout().permitAll();
}
}

Java では認証はどのように機能しますか?

セキュリティとログインフォームを備えた Web アプリケーションを使用します。このフォームは JSP ページにリダイレクトされます。

<form action="%24%7BpageContext.request.contextPath%7D/authenticateUser" method="POST">
<if test="${param.error ! = null}">
<b class="failed"> username/password does not authenticate here… </b>
</if>
<p>
User ID: <input type="text" name="name">
</p>
<p>
Password: <input type="password" name="pswrd">
</p>
<input type="submit" value="Submit">
</form>

ログインフォームの認証にはWebアプリケーションを使用します。このフォームは JSP ページにリダイレクトされます。

<p>
User: <authentication property="principal.username"></authentication>
</p>

Java Spring フレームワークを使用して Java 認証構文を使用します。 Java は Spring セキュリティを使用して権限を認証します。

public class AppSecurityConfig extends AppSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder authentic) throws Exception {
UserBuilder userid = User.withDefaultPasswordEncoder();
authentic.inMemoryAuthentication()
.withUser (usersid.username ("merry")
.password ("test@123")
.roles ("student"))
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/")
.hasRole("student")
.and()
.formLogin()
.loginPage("/useLoginPage")
.loginProcessingUrl("/authenticatationUser")
.permitAll()
.and()
.logout().permitAll();
}
}

認証 Java の例

以下に例を示します:

例 #1

基本的な例を以下に示します。

コード:

ファイル:authenticationApp.java

public class authenticationApp extends AppSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder authentic) throws Exception {
UserBuilder userid = User.withDefaultPasswordEncoder();
authentic.inMemoryAuthentication()
.withUser (usersid.username ("sunny")
.password ("school@123")
.roles ("student"))
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/")
.hasRole("student")
.and()
.formLogin()
.loginPage("/useLoginPage")
.loginProcessingUrl("/authenticatationUser")
.permitAll()
.and()
.logout().permitAll();
}
}

ファイル: main_login.jsp

<form action="%24%7BpageContext.request.contextPath%7D/authenticateUser" method="POST">
<if test="${param.error ! = null}">
<b class="failed"> username/password does not authenticate here… </b>
</if>
<p>
User ID: <input type="text" name="name">
</p>
<p>
Password: <input type="password" name="pswrd">
</p>
<input type="submit" value="Submit">
</form>
File: authentication.jsp

User name:

出力:

認証Java

出力

認証Java

説明:

  • ここでは、単一のユーザー名での単一ユーザー認証が表示されます。
  • 「Sunny」は Java 認証を使用して学生ポータルにのみアクセスします。
  • 単一の正規ユーザーに対して単一のフォームを取得します。

例 #2

Java の例と出力における 2 つの認証を以下に示します。

コード:

ファイル:authenticationApp.java

public class authenticationApp extends AppSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder authentic) throws Exception {
UserBuilder userid = User.withDefaultPasswordEncoder();
authentic.inMemoryAuthentication()
.withUser (usersid.username ("merry")
.password ("test@123")
.roles ("student"))
.withUser(users.username("sam")
.password("exam@123")
.roles("student", "teacher"))
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/").hasRole("student")
.antMatchers("/teachers/**").hasRole("teacher")
.and()
.formLogin()
.loginPage("/useLoginPage")
.loginProcessingUrl("/authenticatationUser")
.permitAll()
.and()
.logout().permitAll();
}
}

ファイル: main_login.jsp

<form action="%24%7BpageContext.request.contextPath%7D/authenticateUser" method="POST">
<if test="${param.error ! = null}">
<b class="failed"> username/password does not authenticate here… </b>
</if>
<p>
User ID: <input type="text" name="name">
</p>
<p>
Password: <input type="password" name="pswrd">
</p>
<input type="submit" value="Submit">
</form>
File: authentication.jsp

User:
Teachrs portal

出力:

認証Java

出力:

認証Java

説明:

  • ここでは、1 つのユーザー名に 2 つの認証が表示されています。
  • 「サム」は Java 認証を使用して教師と生徒のポータルにアクセスします。
  • 複数の認証ユーザーに対して 1 つのフォームを取得できます。

例 #3

Java の例と出力における複数の認証を以下に示します。

コード:

ファイル:authenticationApp.java

public class authenticationApp extends AppSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder authentic) throws Exception {
UserBuilder userid = User.withDefaultPasswordEncoder();
authentic.inMemoryAuthentication()
.withUser (usersid.username ("merry")
.password ("test@123")
.roles ("student"))
.withUser(users.username("sam")
.password("exam@123")
.roles("student", "teacher"))
.withUser(users.username("Ram")
.password("admin@123")
.roles("student", "teacher", "principle"))
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/")
.hasRole("student")
.antMatchers("/teachers/**").hasRole("teacher")
.antMatchers("/principles/**").hasRole("principle")
.and()
.formLogin()
.loginPage("/useLoginPage")
.loginProcessingUrl("/authenticatationUser")
.permitAll()
.and()
.logout().permitAll();
}
}

ファイル: main_login.jsp

<form action="%24%7BpageContext.request.contextPath%7D/authenticateUser" method="POST">
<if test="${param.error ! = null}">
<b class="failed"> username/password does not authenticate here… </b>
</if>
<p>
User ID: <input type="text" name="name">
</p>
<p>
Password: <input type="password" name="pswrd">
</p>
<input type="submit" value="Submit">
</form>
File: authentication.jsp

User:
Teachers portal
Principle portal

出力:

認証Java

出力:

認証Java

説明:

  • ここでは、単一のユーザー名に複数の認証が表示されています。
  • 「Ram」は、Java 認証を使用して教師、生徒、管理者のポータルにアクセスします。
  • 複数の認証ユーザーに対して 1 つのフォームを取得できます。

結論

Java の認証は、データと権限のセキュリティ、安全性、プライバシーを提供します。認証は、各ユーザーおよび権限がデータベースの一部にアクセスするために使用します。簡単、魅力的、ユーザーフレンドリー、エレガントな Web サイトと Web アプリケーションになります。この関数は、ユーザーの ID ごとにドキュメントを並べ替え、必要なデータのみを返します。他人のプライバシーを侵害することなく、複雑な情報を簡単に入手するのに役立ちます。

以上が認証Javaの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
带你搞懂Java结构化数据处理开源库SPL带你搞懂Java结构化数据处理开源库SPLMay 24, 2022 pm 01:34 PM

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于结构化数据处理开源库SPL的相关问题,下面就一起来看一下java下理想的结构化数据处理类库,希望对大家有帮助。

Java集合框架之PriorityQueue优先级队列Java集合框架之PriorityQueue优先级队列Jun 09, 2022 am 11:47 AM

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于PriorityQueue优先级队列的相关知识,Java集合框架中提供了PriorityQueue和PriorityBlockingQueue两种类型的优先级队列,PriorityQueue是线程不安全的,PriorityBlockingQueue是线程安全的,下面一起来看一下,希望对大家有帮助。

完全掌握Java锁(图文解析)完全掌握Java锁(图文解析)Jun 14, 2022 am 11:47 AM

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于java锁的相关问题,包括了独占锁、悲观锁、乐观锁、共享锁等等内容,下面一起来看一下,希望对大家有帮助。

一起聊聊Java多线程之线程安全问题一起聊聊Java多线程之线程安全问题Apr 21, 2022 pm 06:17 PM

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于多线程的相关问题,包括了线程安装、线程加锁与线程不安全的原因、线程安全的标准类等等内容,希望对大家有帮助。

Java基础归纳之枚举Java基础归纳之枚举May 26, 2022 am 11:50 AM

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于枚举的相关问题,包括了枚举的基本操作、集合类对枚举的支持等等内容,下面一起来看一下,希望对大家有帮助。

详细解析Java的this和super关键字详细解析Java的this和super关键字Apr 30, 2022 am 09:00 AM

本篇文章给大家带来了关于Java的相关知识,其中主要介绍了关于关键字中this和super的相关问题,以及他们的一些区别,下面一起来看一下,希望对大家有帮助。

Java数据结构之AVL树详解Java数据结构之AVL树详解Jun 01, 2022 am 11:39 AM

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于平衡二叉树(AVL树)的相关知识,AVL树本质上是带了平衡功能的二叉查找树,下面一起来看一下,希望对大家有帮助。

一文掌握Java8新特性Stream流的概念和使用一文掌握Java8新特性Stream流的概念和使用Jun 23, 2022 pm 12:03 PM

本篇文章给大家带来了关于Java的相关知识,其中主要整理了Stream流的概念和使用的相关问题,包括了Stream流的概念、Stream流的获取、Stream流的常用方法等等内容,下面一起来看一下,希望对大家有帮助。

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

SublimeText3 Linux 新バージョン

SublimeText3 Linux 新バージョン

SublimeText3 Linux 最新バージョン

PhpStorm Mac バージョン

PhpStorm Mac バージョン

最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

AtomエディタMac版ダウンロード

AtomエディタMac版ダウンロード

最も人気のあるオープンソースエディター

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境