java.lang.Object
com.sun.net.httpserver.Authenticator
com.sun.net.httpserver.BasicAuthenticator
org.bzdev.ejws.EjwsAuthenticator
org.bzdev.ejws.EjwsBasicAuthenticator
Implementation of BasicAuthenticator using either an in-memory table
of user names and passwords or a user-supplied table.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.bzdev.ejws.EjwsAuthenticator
EjwsAuthenticator.AddStatus, EjwsAuthenticator.GPGKeyIDs, EjwsAuthenticator.UserInfoNested classes/interfaces inherited from class com.sun.net.httpserver.Authenticator
Authenticator.Failure, Authenticator.Result, Authenticator.Retry, Authenticator.Success -
Field Summary
Fields inherited from class org.bzdev.ejws.EjwsAuthenticator
authFunction, loginFunction, logoutFunction, onAccountActive, onAccountRemoval, onAccountRequest, tracerFields inherited from class com.sun.net.httpserver.BasicAuthenticator
realm -
Constructor Summary
ConstructorsConstructorDescriptionEjwsBasicAuthenticator(EmbeddedWebServer ews, String realm) Constructor.EjwsBasicAuthenticator(EmbeddedWebServer ews, String realm, Map<String, EjwsBasicAuthenticator.Entry> map) Constructor providing a map. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a user name and password for this authenticator's HTTP realm.voidAdd a user name, the user's password and the user's roles for this authenticator's HTTP realm.voidAdd a user specified by an instance ofEjwsAuthenticator.UserInfo.booleancheckCredentials(String username, String password) Check credentials.getMode()Get the mode.byte[]Get the SBL file for a uservoidhandleError(HttpExchange t, Exception e) booleanisSBLCompressed(String user) Determine if the SBL file is compresssed using GZIP.voidLoad user-account data obtained from GPG or an SBL directorybooleanmakeUserActive(String name) Make a user activebooleanmakeUserActive(String name, boolean gpg) Make a user active, specifying if the user is one for whom GPG is used to provide the data needed to log in.protected voidproposeMode(EmbeddedWebServer server) voidprune()Remove cached passwords whose timeout has expired.booleanremoveUser(String name) Remove a user.booleanremoveUser(String name, boolean gpg) Make a user active, specifying if the user is one for whom GPG is used to provide the data needed to log in.voidsetTimeLimit(int passphraseTimeout) Set the time limit for a passphrase/password.voidMethods inherited from class org.bzdev.ejws.EjwsAuthenticator
addToAdminMap, addToDeleteSet, createServerCookie, createUser, createUser, createUser, createUser, createUser, deleteWithFingerprint, findServerCookie, generateAdminURI, generateRequestURI, getAdminFingerprint, getAdminUsers, getCanAddAccount, getFingerprint, getGPGUsers, getLoginAlias, getReverseProxy, getSBLDir, getSBLUsers, getTrustedKeyIDs, getUserNameFromSBL, getUserStatus, gpghome, hasGPGKey, hasGPGKey, inDeleteSet, isActiveDefault, isEmailAddress, isTrustedKey, processAdminRequests, readSBLData, removeFromDeleteSet, removePWInfo, requestFromUser, setAllowLoopback, setAuthorizedFunction, setCanAddAccount, setCookie, setDefaultActive, setGPGHome, setLoginFunction, setLogoutFunction, setOnAccountActive, setOnAccountRemoval, setOnAccountRequest, setReverseProxy, setSBLDir, setSelfSigned, setTracer, setTruststore, setTruststorePW, setupKeySigner, setUserStatusFunction, showGPGKey, signKey, signKey, storeGPGKey, storeSBLData, trustGPGKey, validGPGUserMethods inherited from class com.sun.net.httpserver.BasicAuthenticator
getRealm
-
Constructor Details
-
EjwsBasicAuthenticator
Constructor.- Parameters:
realm- the HTTP realm
-
EjwsBasicAuthenticator
public EjwsBasicAuthenticator(EmbeddedWebServer ews, String realm, Map<String, EjwsBasicAuthenticator.Entry> map) Constructor providing a map. A user-supplied map can be implemented so as to allow one to obtain passwords and roles from a database or some other form of persistent storage. If entries can be added while a server using this authenticator is running, the map should have a thread-safe implementation.- Parameters:
realm- the HTTP realmmap- a map associating a user name with a table entry.
-
-
Method Details
-
getSBL
Get the SBL file for a user- Specified by:
getSBLin classEjwsAuthenticator- Parameters:
user- the user- Returns:
- the SBL file as a byte array; null if there is none
-
isSBLCompressed
Determine if the SBL file is compresssed using GZIP.- Specified by:
isSBLCompressedin classEjwsAuthenticator- Returns:
- true if the SBL file is compressed; false otherwise
- See Also:
-
setTimeLimit
Set the time limit for a passphrase/password.- Parameters:
passphraseTimeout- the time interval in seconds for which a password is valid (the default is 1200); 0 to disable the timeout- Throws:
IllegalArgumentException- if the argument is less than zero.
-
add
public void add(String username, String password) throws UnsupportedOperationException, IllegalStateException Add a user name and password for this authenticator's HTTP realm.- Parameters:
username- the user namepassword- the password- Throws:
UnsupportedOperationException- if the map does not allow entries to be added (the default map does not throw this exception)IllegalStateException- if the map already contains the user
-
add
public void add(String username, String password, Set<String> roles) throws UnsupportedOperationException, IllegalStateException Add a user name, the user's password and the user's roles for this authenticator's HTTP realm.- Parameters:
username- the user namepassword- the user's passwordroles- the user's roles- Throws:
UnsupportedOperationException- if the map does not allow entries to be added (the default map does not throw this exception)IllegalStateException- if the map already contains the user
-
setUserTable
-
getUserTable
- Overrides:
getUserTablein classEjwsAuthenticator
-
add
Add a user specified by an instance ofEjwsAuthenticator.UserInfo.- Specified by:
addin classEjwsAuthenticator- Parameters:
info- the user data- Throws:
IllegalStateException
-
removeUser
Description copied from class:EjwsAuthenticatorMake a user active, specifying if the user is one for whom GPG is used to provide the data needed to log in.- Specified by:
removeUserin classEjwsAuthenticator- Parameters:
name- the user's namegpg- true if GPG is used; false if an SBL directory is used
-
removeUser
Description copied from class:EjwsAuthenticatorRemove a user.- Specified by:
removeUserin classEjwsAuthenticator- Parameters:
name- the user's name
-
makeUserActive
Description copied from class:EjwsAuthenticatorMake a user active, specifying if the user is one for whom GPG is used to provide the data needed to log in.- Specified by:
makeUserActivein classEjwsAuthenticator- Parameters:
name- the user's namegpg- true if GPG is used; false if an SBL directory is used
-
makeUserActive
Description copied from class:EjwsAuthenticatorMake a user active- Specified by:
makeUserActivein classEjwsAuthenticator- Parameters:
name- the user's name
-
loadFromDirs
Description copied from class:EjwsAuthenticatorLoad user-account data obtained from GPG or an SBL directory -
handleError
- Throws:
IOException
-
authenticate
- Overrides:
authenticatein classBasicAuthenticator
-
getMode
Get the mode.- Specified by:
getModein classEjwsAuthenticator- Returns:
- SecureBasicUtilities.Mode.PASSWORD
-
proposeMode
- Throws:
IllegalStateException
-
prune
public void prune()Remove cached passwords whose timeout has expired. The method can be called periodically to eliminate passwords when a user has not explicitly logged out. -
checkCredentials
Check credentials. This method is called for each incoming request to verify the given name and password in the context of this Authenticator's realm.- Specified by:
checkCredentialsin classBasicAuthenticator- Parameters:
username- the user namepassword- the password
-