Class AuthService
- java.lang.Object
-
- in.cs699.tensors.delagram.auth_service.service.AuthService
-
@Service public class AuthService extends Object
The service layer that abstracts out the business-logic for this particular micro-service
-
-
Constructor Summary
Constructors Constructor Description AuthService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkEmailUnregistered(String emailId)
check if the email id is already registeredvoid
checkUserIDUniqueness(String userId)
checks if the userid is unique or notvoid
signUp(Map<String,Object> payload)
Pushes the user data to firebase as a new uservoid
validateEmailId(String emailId)
Checks if the entered email id belongs to IIT Bombay domain or notUser
verifyTokenAndGetUser(String authorizationToken)
This method is a wrapper for verifying the Firebase token, and returning the associated user object
-
-
-
Method Detail
-
validateEmailId
public void validateEmailId(String emailId) throws UserNotInScopeException
Checks if the entered email id belongs to IIT Bombay domain or not- Parameters:
emailId
- email id which has to be checked for domain- Throws:
UserNotInScopeException
- thrown if the email id is not in the domain of IIT Bombay
-
checkEmailUnregistered
public void checkEmailUnregistered(String emailId) throws AuthenticationFailedException, EmailAlreadyRegistered
check if the email id is already registered- Parameters:
emailId
- email id to check if it is registered- Throws:
AuthenticationFailedException
- Thrown in case the authorization token is invalidEmailAlreadyRegistered
- Thrown if the email id is already registered with firebase
-
checkUserIDUniqueness
public void checkUserIDUniqueness(String userId) throws AuthenticationFailedException, UserIDAlreadyExistsException
checks if the userid is unique or not- Parameters:
userId
- userid to check uniqueness- Throws:
AuthenticationFailedException
- Thrown in case the authorization token is invalidUserIDAlreadyExistsException
- Thrown if userid is already taken
-
signUp
public void signUp(Map<String,Object> payload) throws AuthenticationFailedException, javax.mail.internet.AddressException, javax.mail.MessagingException
Pushes the user data to firebase as a new user- Parameters:
payload
- a Map which contains all the user data from the sign up form- Throws:
AuthenticationFailedException
- Thrown in case the authorization token is invalidjavax.mail.internet.AddressException
- Thrown in case the address is malformedjavax.mail.MessagingException
- Thrown in case the verification message couldn't be sent
-
verifyTokenAndGetUser
public User verifyTokenAndGetUser(String authorizationToken) throws AuthenticationFailedException, InternalServerException
This method is a wrapper for verifying the Firebase token, and returning the associated user object- Parameters:
authorizationToken
- The token that is to be verified- Returns:
- The User object
- Throws:
AuthenticationFailedException
- This is thrown in case the authorization token is invalidInternalServerException
- Thrown in case some error occurs while fetching the user details
-
-