Package net.i2p.i2pcontrol.security
Class SecurityManager
java.lang.Object
net.i2p.i2pcontrol.security.SecurityManager
Manage the password storing for I2PControl.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSecurityManager
(I2PAppContext ctx, KeyStoreProvider ksp, ConfigurationManager conf) -
Method Summary
Modifier and TypeMethodDescriptionHash input one time with SHA-256, return Base64 encdoded string.getPasswdHash
(String pwd) Hash pwd with using BCrypt with the default salt.boolean
Is this password correct?boolean
Is this password correct?boolean
Set new password.void
validatePasswd
(String pwd) Add a Authentication Token if the provided password is valid.void
verifyToken
(String tokenID) Checks whether the AuthToken with the given ID exists and if it does whether is has expired.
-
Field Details
-
DEFAULT_AUTH_PASSWORD
- See Also:
-
-
Constructor Details
-
SecurityManager
- Parameters:
ksp
- may be null (if webapp)
-
-
Method Details
-
stopTimedEvents
public void stopTimedEvents() -
getPasswdHash
Hash pwd with using BCrypt with the default salt.- Parameters:
pwd
-- Returns:
- BCrypt hash of salt and input string
-
getHash
Hash input one time with SHA-256, return Base64 encdoded string.- Parameters:
string
-- Returns:
- Base64 encoded string
-
isValid
Is this password correct?- Returns:
- true if password is valid.
- Since:
- 0.12
-
isDefaultPasswordValid
public boolean isDefaultPasswordValid()Is this password correct?- Returns:
- true if password is valid.
- Since:
- 0.12
-
validatePasswd
Add a Authentication Token if the provided password is valid. The token will be valid for one day.- Returns:
- AuthToken if password is valid. If password is invalid null will be returned.
-
setPasswd
Set new password. Old tokens will NOT remain valid, to encourage the new password being tested.- Parameters:
newPasswd
-- Returns:
- Returns true if a new password was set.
-
verifyToken
Checks whether the AuthToken with the given ID exists and if it does whether is has expired.- Parameters:
tokenID
- - The token to validate- Throws:
InvalidAuthTokenException
ExpiredAuthTokenException
-