Package net.i2p.i2pcontrol.security
Class SecurityManager
java.lang.Object
net.i2p.i2pcontrol.security.SecurityManager
public class SecurityManager extends Object
Manage the password storing for I2PControl.
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_AUTH_PASSWORD -
Constructor Summary
Constructors Constructor Description SecurityManager(I2PAppContext ctx, KeyStoreProvider ksp, ConfigurationManager conf) -
Method Summary
Modifier and Type Method Description StringgetHash(String string)Hash input one time with SHA-256, return Base64 encdoded string.StringgetPasswdHash(String pwd)Hash pwd with using BCrypt with the default salt.booleanisDefaultPasswordValid()Is this password correct?booleanisValid(String pwd)Is this password correct?booleansetPasswd(String newPasswd)Set new password.voidstopTimedEvents()AuthTokenvalidatePasswd(String pwd)Add a Authentication Token if the provided password is valid.voidverifyToken(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:
- Constant Field Values
-
-
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
public void verifyToken(String tokenID) throws InvalidAuthTokenException, ExpiredAuthTokenExceptionChecks whether the AuthToken with the given ID exists and if it does whether is has expired.- Parameters:
tokenID- - The token to validate- Throws:
InvalidAuthTokenExceptionExpiredAuthTokenException
-