Java'da Java.net.Authenticator sınıfı
Authenticator sınıfı, bazı URL'leri ziyaret etmek için kimlik doğrulamanın gerekli olduğu durumlarda kullanılır. Kimlik doğrulamanın gerekli olduğu bilindiğinde, kullanıcıdan aynısını ister veya sabit kodlanmış bir kullanıcı adı ve şifre kullanır.
Bu sınıfı kullanmak için aşağıdaki adımlar izlenir:
-
Kimlik Doğrulayıcıyı genişleten bir sınıf oluşturun. CustomAuth adını verelim. - getPasswordAuthentication() yöntemini geçersiz kılın. Bu yöntem, kimlik doğrulama isteyen varlığın ayrıntılarını almak için çeşitli yöntemler içerir. Tüm bu yöntemler daha sonra ayrıntılı olarak tartışılacaktır.
- Yeni oluşturulan alt sınıfı, bir http sunucusu Authenticator sınıfının setDefault(Authenticator a) yöntemiyle kimlik doğrulama istediğinde kullanılacak varsayılan kimlik doğrulayıcı olarak ayarlayın.
-
-
İnetaddress'in mevcut olmaması durumunda ana bilgisayar adının kullanılabileceği durumlarda kullanılabilecek başka bir aşırı yükleme yöntemi.
-
Kimlik doğrulama isteyen sitenin URL'sinin ineaddress ve ana bilgisayar adı değil, yalnızca biliniyor olması durumunda kullanılabilecek başka bir aşırı yükleme yöntemi.
-
-
-
-
-
-
-
-
-
-
setDefault(Authenticator a): Bir HTTP sunucusu kimlik doğrulaması gerektirdiğinde kullanılacak kimlik doğrulayıcıyı ayarlar.
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
requestPasswordAuthentication(): Sisteme kayıtlı kimlik doğrulayıcıdan şifre ister. Kullanıcı adını/şifreyi döndürür veya bulunamazsa null değerini döndürür.
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() : kimlik doğrulama isteyen sitenin ana bilgisayar adını döndürür.
Syntax : protected final String getRequestingHost()
getRequestingSite() : Kimlik doğrulama isteyen sitenin inetadresini döndürür.
Syntax : protected final InetAddress getRequestingSite()
getRequestingPort() : Bağlantı portunu döndürür.
Syntax : protected final int getRequestingPort()
getRequestingProtocol() : Bağlantıyı talep eden protokolü döndürür.
Syntax : protected final String getRequestingProtocol()
getRequestingPrompt() : istek sahibi tarafından istenen mesajı döndürür.
Syntax : protected final String getRequestingPrompt()
getRequestingScheme() : istekte bulunan sitenin şemasını döndürür.
Syntax : protected final String getRequestingScheme()
getPasswordAuthentication() : Şifre kimlik doğrulaması gerektiğinde bu yöntem çağrılır. Varsayılan yöntem her zaman null değerini döndürdüğü için tüm alt sınıfların bu yöntemi geçersiz kılması gerekir.
Syntax : protected PasswordAuthentication getPasswordAuthentication()
getRequestingURL() : istekte bulunanın URL'sini döndürür.
Syntax : protected final URL getRequestingURL()
getRequestorType() : istekte bulunanın proxy veya sunucu olup olmadığını döndürür.
Syntax : protected Authenticator.RequestorType getRequestorType()
Hoşunuza Gidebilir
En Makaleler
Kategori
-