Authentication java 是 Web 應用程式身分確認的安全術語。它是使用程式語言確認網站和網路應用程式的用戶身份的功能。它確認使用者的使用並允許他們使用 Java 技術存取網站、應用程式和軟體相關產品。它是一種安全方法,用於使用 Java 語言的安全條款來識別授權使用者並授予使用應用程式的權限。
開始您的免費軟體開發課程
網頁開發、程式語言、軟體測試及其他
它是一個客戶端和伺服器端功能,使用唯一的內容並透過安全密碼和使用者身分進行確認。它在客戶端使用使用者id和密碼,並使用Java程式語言以真實身分存取伺服器端資料。這是一個保持 Web 應用程式安全並僅使用可存取的團隊成員的文件流程。
文法
此語法用於驗證使用者的特定分支,例如學生、教師、非教學人員和校長。您可以使用使用者名稱、電子郵件地址和密碼登入並確認身分。
在此語法中,應用程式使用使用者名稱和密碼進行身份驗證。
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 中的身份驗證如何運作?
使用具有安全性和登入表單的網路應用程式。此表單會重新導向至 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>
使用網頁應用程式對登入表單進行身份驗證。此表單會重新導向至 JSP 頁面。
<p> User: <authentication property="principal.username"></authentication> </p>
使用 java spring 框架使用 Java 驗證語法。 Java使用Spring security來進行權限認證。
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.jspUser name:
輸出:
輸出
說明:
- 在這裡,您可以看到單一使用者名稱中的單一使用者身份驗證。
- 「Sunny」僅透過 Java 驗證存取學生入口網站。
- 您將獲得單一真實使用者的單一表格。
範例#2
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")) } @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.jspUser:
Teachrs portal
輸出:
輸出:
說明:
- 在這裡,您可以在一個使用者名稱中看到兩個身份驗證。
- 「sam」透過 Java 身份驗證存取教師和學生入口網站。
- 您將獲得多個真實使用者的單一表單。
範例#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
輸出:
輸出:
說明:
- 在這裡,您可以看到單一使用者名稱中的多個身份驗證。
- 「Ram」透過 Java 身份驗證存取教師、學生和管理入口網站。
- 您將獲得多個真實使用者的單一表格。
結論
Java 中的驗證提供資料和權限的安全性、安全性和隱私性。身份驗證用於存取相應使用者和權限的資料庫的一部分。它變得簡單、有吸引力、用戶友好且優雅的網站和 Web 應用程式。此函數根據使用者的身分對文件進行排序,並僅傳回所需的資料。它有助於輕鬆獲得複雜的訊息,同時又不會侵犯他人的隱私。
以上是認證Java的詳細內容。更多資訊請關注PHP中文網其他相關文章!

Java在不同操作系統上的表現存在細微差異。 1)JVM實現不同,如HotSpot、OpenJDK,影響性能和垃圾回收。 2)文件系統結構和路徑分隔符不同,需使用Java標準庫處理。 3)網絡協議實現差異影響網絡性能。 4)GUI組件外觀和行為在不同系統上有別。通過使用標準庫和虛擬機測試,可減少這些差異的影響,確保Java程序穩定運行。

javaoffersrobustobject-IentiendedProgrammming(OOP)和Top-Notchsecurityfeatures.1)OopinjavainCludesClasses,對象,繼承,多態性,和列出,andeclingfleximaintainablesys.ss.2)SecurityFeateTuersLudEtersludEterMachine(

JavaScriptandJavahavedistinctstrengths:JavaScriptexcelsindynamictypingandasynchronousprogramming,whileJavaisrobustwithstrongOOPandtyping.1)JavaScript'sdynamicnatureallowsforrapiddevelopmentandprototyping,withasync/awaitfornon-blockingI/O.2)Java'sOOPf

JAVAACHIEVESPLATFORMINDEPENTENCETHROUGHJAVAVIRTAILMACHINE(JVM)和BYTECODE.1)THEJVMINTERPRETSBBYTECODE,允許theingthesmecodetorunonanyanyanyanyplatformwithajvm.2)

java'splatformendependecemeansapplicationscanrunonanyplatformwithajvm,使“ Writeonce,runanywhere”。

JVM'SperformanceIsCompetitiveWithOtherRuntimes,operingabalanceOfspeed,安全性和生產性。 1)JVMUSESJITCOMPILATIONFORDYNAMICOPTIMIZAIZATIONS.2)c提供NativePernativePerformanceButlanceButlactsjvm'ssafetyFeatures.3)

JavaachievesPlatFormIndependencEthroughTheJavavIrtualMachine(JVM),允許CodeTorunonAnyPlatFormWithAjvm.1)codeisscompiledIntobytecode,notmachine-specificodificcode.2)bytecodeisisteredbytheybytheybytheybythejvm,enablingcross-platerssectectectectectross-eenablingcrossectectectectectection.2)

TheJVMisanabstractcomputingmachinecrucialforrunningJavaprogramsduetoitsplatform-independentarchitecture.Itincludes:1)ClassLoaderforloadingclasses,2)RuntimeDataAreafordatastorage,3)ExecutionEnginewithInterpreter,JITCompiler,andGarbageCollectorforbytec


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具