Java의 Java.net.Authenticator 클래스
인증자 클래스는 일부 URL을 방문하기 위해 인증이 필요한 경우에 사용됩니다. 인증이 필요하다는 것이 알려지면 사용자에게 동일한 메시지를 표시하거나 하드 코딩된 사용자 이름과 비밀번호를 사용합니다.
이 클래스를 사용하려면 다음 단계를 따르십시오.
-
인증자를 확장하는 클래스를 만듭니다. 이름을 customAuth로 지정하겠습니다. - getPasswordAuthentication() 메서드를 재정의합니다. 이 방법에는 인증을 요청하는 엔터티의 세부 정보를 가져오는 여러 가지 방법이 포함되어 있습니다. 이러한 모든 방법은 나중에 자세히 설명됩니다.
- 새로 생성된 하위 클래스를 Authenticator 클래스의 setDefault(Authenticator a) 메서드를 사용하여 http 서버에서 인증을 요청할 때 사용할 기본 인증자로 설정합니다.
-
-
inetaddress를 사용할 수 없는 경우 호스트 이름을 사용할 수 있는 상황에서 사용할 수 있는 또 다른 오버로드된 방법입니다.
-
인증을 요청하는 사이트의 URL만 알려져 있고 inetaddress 및 호스트 이름이 없는 경우 사용할 수 있는 또 다른 오버로드된 방법입니다.
-
-
-
-
-
-
-
-
-
-
setDefault(인증자 a) : HTTP 서버에 인증이 필요할 때 사용할 인증자를 설정합니다.
Syntax : public static void setDefault(Authenticator a) throws SecurityException Parameter : a : authenticator to be set as default Throws : SecurityException : if security manager doesn't allow setting default authenticator
요청비밀번호인증() : 시스템에 등록된 인증자에게 비밀번호를 묻습니다. 사용자 이름/비밀번호를 반환하거나 찾을 수 없으면 null을 반환합니다.
Syntax : public static PasswordAuthentication requestPasswordAuthentication( InetAddress addr int port String protocol String prompt String scheme) Parameter : addr : Inet address of the site asking for authentication port : port of requesting site protocol : protocol used for connection prompt : message for the user scheme : authentication scheme Throws : SecurityException : if security manager doesn't allow setting password authentication.
Syntax : public static PasswordAuthentication requestPasswordAuthentication( String host InetAddress addr int port String protocol String prompt String scheme) Parameter : host : hostname of the site asking for authentication addr : Inet address of the site asking for authentication port : port of requesting site protocol : protocol used for connection prompt : message for the user scheme : authentication scheme Throws : SecurityException : if security manager doesn't allow setting password authentication.
Syntax : public static PasswordAuthentication requestPasswordAuthentication( String host InetAddress addr int port String protocol String prompt URL url String scheme) Parameter : host : hostname of the site asking for authentication addr : Inet address of the site asking for authentication port : port of requesting site protocol : protocol used for connection prompt : message for the user url : URL of the site requesting authentication scheme : authentication scheme Throws : SecurityException : if security manager doesn't allow setting password authentication.
getRequestingHost() : 인증을 요청하는 사이트의 호스트 이름을 반환합니다.
Syntax : protected final String getRequestingHost()
getRequestingSite() : 인증을 요청하는 사이트의 inetaddress를 반환합니다.
Syntax : protected final InetAddress getRequestingSite()
getRequestingPort() : 연결 포트를 반환합니다.
Syntax : protected final int getRequestingPort()
getRequestingProtocol() : 연결을 요청하는 프로토콜을 반환합니다.
Syntax : protected final String getRequestingProtocol()
getRequestingPrompt() : 요청자가 요청한 메시지를 반환합니다.
Syntax : protected final String getRequestingPrompt()
getRequestingScheme() : 요청한 사이트의 구성표를 반환합니다.
Syntax : protected final String getRequestingScheme()
getPassword인증() : 비밀번호 인증이 필요한 경우 호출되는 메소드입니다. 기본 메서드는 항상 null을 반환하므로 모든 하위 클래스는 이 메서드를 재정의해야 합니다.
Syntax : protected PasswordAuthentication getPasswordAuthentication()
getRequestingURL() : 요청자의 URL을 반환합니다.
Syntax : protected final URL getRequestingURL()
getRequestorType() : 요청자가 프록시인지 서버인지를 반환합니다.
Syntax : protected Authenticator.RequestorType getRequestorType()
마음에 드실지도 몰라요
인기 기사
범주
-