Package ch.bztf.m226blb1.Auth
Class Credentials
java.lang.Object
ch.bztf.m226blb1.Auth.Credentials
The class for validating parameters and creating API-Keys.
- 
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsNumber(String value) Checks if the string contains a digit.static intextractLimit(Optional<Integer> limit) Extracts and validates thelimitto a integer.static StringgenerateApiKey(@NonNull AuthAccount account) Creates an API-key for the givenaccount.static booleanisValidUsername(String username) Checks if the username is valid.static voidvalidateApiKey(String apiKey) Validates if theapi keyis valid.static voidvalidateCredentials(@NonNull AuthAccount auth)  
- 
Method Details
- 
generateApiKey
Creates an API-key for the givenaccount.- Parameters:
 account- the account to create the API key for.- Returns:
 - an 
API-Keygenerated with the givenemail,passwordand thecurrent time - See Also:
 - 
SHA-512 hasher
 
 - 
validateApiKey
Validates if theapi keyis valid.- Parameters:
 apiKey- the api key to validate- Throws:
 javax.validation.ValidationException- if the api key is not valid
 - 
validateCredentials
public static void validateCredentials(@NonNull @NonNull AuthAccount auth) throws javax.validation.ValidationException  - 
extractLimit
Extracts and validates thelimitto a integer.- Parameters:
 limit- the limit to extract and validate- Returns:
 - the extracted limit
 - API Note:
 - The default limit is 
10. 
 - 
containsNumber
Checks if the string contains a digit.- Parameters:
 value- the string to be checked- Returns:
 trueif the string contains a digit
 - 
isValidUsername
Checks if the username is valid.- Parameters:
 username- the username to be checked- Returns:
 trueif the username is valid
 
 -