public abstract class FileLoginModule extends Object implements Loggable, LoginModule
Modifier and Type | Class and Description |
---|---|
static class |
FileLoginModule.ManageUsersException |
static class |
FileLoginModule.UserInfo |
Modifier and Type | Field and Description |
---|---|
static File |
authenticationLockFile
file used to prevent concurrent modification of login.cfg or group.cfg
|
protected CallbackHandler |
callbackHandler
JAAS call back handler used to get authentication request parameters
|
static String |
DOMAIN_SEP |
static String |
ENCRYPTED_DATA_SEP |
protected String |
groupFile
The file where to store group management
|
static String |
LOCK_FILE_NAME |
protected String |
loginFile
The file where to store the allowed user//password
|
protected Subject |
subject |
protected String |
tenantFile
The file where to store tenant management
|
Constructor and Description |
---|
FileLoginModule() |
Modifier and Type | Method and Description |
---|---|
boolean |
abort() |
protected void |
addShadowAccount(String domain,
String username) |
protected void |
checkGroupFile() |
protected void |
checkLoginFile() |
protected void |
checkTenantFile() |
boolean |
commit() |
protected void |
createAndStoreCredentialFile(String domain,
String username,
String password,
boolean isShadowAccount) |
protected boolean |
createOrUpdateShadowAccount(FileLoginModule.UserInfo userInfo) |
protected String |
generateRandomPassword() |
protected abstract Set<String> |
getConfiguredDomains() |
protected abstract String |
getGroupFileName()
Defines group file name
|
protected abstract String |
getLoginFileName()
Defines login file name
|
protected abstract PrivateKey |
getPrivateKey()
Defines private key
|
protected abstract PublicKey |
getPublicKey()
Defines public key
|
protected abstract String |
getTenantFileName()
Defines tenant file name
|
protected void |
groupMembership(String domain,
String username)
Return corresponding group for a user from the group file.
|
void |
initialize(Subject subject,
CallbackHandler callbackHandler,
Map<String,?> sharedState,
Map<String,?> options) |
protected abstract boolean |
isLegacyPasswordEncryption()
Returns true if legacy password encryption is used (hybrid symetric key).
|
boolean |
login() |
boolean |
logout() |
protected boolean |
logUser(String username,
String password,
String domain,
boolean isNotFallbackAuthentication)
First Check user and password from login file.
|
protected void |
removeOldFailedAttempts(String username) |
protected void |
resetFailedAttempt(String username) |
protected int |
retryInHowManyMinutes(String username) |
protected void |
storeFailedAttempt(String username) |
protected void |
tenantMembership(String domain,
String username)
Return corresponding tenant for a user from the tenant file.
|
protected boolean |
tooManyFailedAttempts(String username) |
protected void |
updateUserGroups(String login,
Collection<String> groups,
com.google.common.collect.Multimap<String,String> groupsMap) |
protected void |
updateUserPassword(PublicKey pubKey,
String login,
String password,
Properties props) |
public static String DOMAIN_SEP
public static final String ENCRYPTED_DATA_SEP
protected CallbackHandler callbackHandler
protected String loginFile
protected String groupFile
protected String tenantFile
public static final String LOCK_FILE_NAME
public static File authenticationLockFile
protected Subject subject
protected abstract String getLoginFileName()
protected abstract String getGroupFileName()
protected abstract String getTenantFileName()
protected abstract PrivateKey getPrivateKey() throws KeyException
KeyException
protected abstract PublicKey getPublicKey() throws KeyException
KeyException
protected abstract boolean isLegacyPasswordEncryption()
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String,?> sharedState, Map<String,?> options)
initialize
in interface LoginModule
LoginModule.initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler, java.util.Map, java.util.Map)
protected void checkLoginFile()
protected void checkGroupFile()
protected void checkTenantFile()
public boolean login() throws LoginException
login
in interface LoginModule
LoginException
- if userName of password are not correctLoginModule.login()
protected boolean logUser(String username, String password, String domain, boolean isNotFallbackAuthentication) throws LoginException
username
- user's loginpassword
- user's passwordisNotFallbackAuthentication
- true if this method is not called inside a fallback mechanismLoginException
- if authentication or group membership fails.protected void storeFailedAttempt(String username)
protected void resetFailedAttempt(String username)
protected void removeOldFailedAttempts(String username)
protected boolean tooManyFailedAttempts(String username)
protected int retryInHowManyMinutes(String username)
protected void groupMembership(String domain, String username) throws LoginException
username
- user's loginLoginException
- if group file is not found or unreadable.protected void tenantMembership(String domain, String username) throws LoginException
username
- user's loginLoginException
- if tenant file is not found or unreadable.public boolean commit() throws LoginException
commit
in interface LoginModule
LoginException
LoginModule.commit()
public boolean abort() throws LoginException
abort
in interface LoginModule
LoginException
LoginModule.abort()
public boolean logout() throws LoginException
logout
in interface LoginModule
LoginException
LoginModule.logout()
protected String generateRandomPassword()
protected void addShadowAccount(String domain, String username) throws LoginException
LoginException
protected boolean createOrUpdateShadowAccount(FileLoginModule.UserInfo userInfo) throws LoginException
LoginException
protected void updateUserPassword(PublicKey pubKey, String login, String password, Properties props) throws KeyException
KeyException
protected void createAndStoreCredentialFile(String domain, String username, String password, boolean isShadowAccount)
protected void updateUserGroups(String login, Collection<String> groups, com.google.common.collect.Multimap<String,String> groupsMap)