Class AuthService
java.lang.Object
com.fredriksonsound.iot_backoffice_auth.service.AuthService
- All Implemented Interfaces:
IAuthService
@Component @Service public class AuthService extends java.lang.Object implements IAuthService
AuthService implementation
-
Constructor Summary
Constructors Constructor Description AuthService() -
Method Summary
Modifier and Type Method Description booleandeleteRefreshToken(java.lang.String id)Deletes a specified access token by idPair<java.lang.String,java.lang.String>generateAndSaveTokens(java.lang.String email)Generates a new access token and refresh token.java.lang.Stringrefresh(java.lang.String access, java.lang.String refreshId)Generates a new access token given an expired accesstoken and a refresh token idbooleanvalidateAccessFor(java.lang.String accessToken, java.lang.String subject)Validates whether a tokens access-level (authToken.subject) is valid for accessing the resource (subject)booleanvalidateUserPassword(java.lang.String email, java.lang.String password)Checks that a given password matches a given user email
-
Constructor Details
-
AuthService
public AuthService()
-
-
Method Details
-
validateUserPassword
public boolean validateUserPassword(java.lang.String email, java.lang.String password)Checks that a given password matches a given user email- Specified by:
validateUserPasswordin interfaceIAuthService- Parameters:
email- the users emailpassword- the password- Returns:
- true if match, false if not match
-
generateAndSaveTokens
Generates a new access token and refresh token.- Specified by:
generateAndSaveTokensin interfaceIAuthService- Parameters:
email- the email of the user- Returns:
- and access token and a refresh token id.
-
deleteRefreshToken
public boolean deleteRefreshToken(java.lang.String id)Deletes a specified access token by id- Specified by:
deleteRefreshTokenin interfaceIAuthService- Parameters:
id- the access token identifier- Returns:
- true if the deletion was a success
-
validateAccessFor
public boolean validateAccessFor(java.lang.String accessToken, java.lang.String subject) throws ValidationErrorValidates whether a tokens access-level (authToken.subject) is valid for accessing the resource (subject)- Specified by:
validateAccessForin interfaceIAuthService- Parameters:
accessToken- the accesstoken providedsubject- the subject to match- Returns:
- true if match and valid token
- Throws:
ValidationError- on invalid or expired token or nonmatching user
-
refresh
public java.lang.String refresh(java.lang.String access, java.lang.String refreshId) throws ValidationErrorGenerates a new access token given an expired accesstoken and a refresh token id- Specified by:
refreshin interfaceIAuthService- Parameters:
access- the expired accessToken to refreshrefreshId- the matching refreshtoken identifier- Returns:
- a new access token
- Throws:
ValidationError- if invalid parameters
-