Class AuthController


  • @RestController
    public class AuthController
    extends Object
    Controller APIs for Authentication and Authorization
    Since:
    1.0.0
    Author:
    Ramadurai Pandian
    • Constructor Summary

      Constructors 
      Constructor Description
      AuthController()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponse> clientIdSecretKey​(@Valid io.mosip.kernel.core.http.RequestWrapper<io.mosip.kernel.core.authmanager.model.ClientSecret> clientSecretDto, javax.servlet.http.HttpServletResponse res)
      API to authenticate using clientId and secretKey clientSecretDto is of type ClientSecretDto
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponseDto> getAllAuthTokens​(@Valid io.mosip.kernel.core.http.RequestWrapper<io.mosip.kernel.core.authmanager.model.LoginUserWithClientId> request, javax.servlet.http.HttpServletResponse res)
      Internal API used by syncdata delegate API
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponseDto> getAllAuthTokensForOTP​(@Valid io.mosip.kernel.core.http.RequestWrapper<io.mosip.kernel.core.authmanager.model.UserOtp> request, javax.servlet.http.HttpServletResponse res)
      Internal API used by syncdata delegate API
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.RolesListDto> getAllRoles​(String appId)  
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.IndividualIdDto> getIndividualId​(String appId, String userId)
      This API will fetch RID based on appId and userId.
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.MosipUserListDto> getListOfUsersDetails​(io.mosip.kernel.core.http.RequestWrapper<UserDetailsRequestDto> userDetails, String appId)  
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.RIdDto> getRId​(String appId, String userId)
      This API will fetch RID based on appId and userId.
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.MosipUserSaltListDto> getUserDetailsWithSalt​(io.mosip.kernel.core.http.RequestWrapper<UserDetailsRequestDto> userDetails, String appId)  
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.MosipUserListDto> getUsersDetails​(String appId, String roleName, int pageStart, int pageFetch, String email, String firstName, String lastName, String userName, String search)
      This API will fetch all users based on appId and roles for role bases search only pagination will work.
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponse> invalidateToken​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse res)
      API to invalidate token when both refresh and auth token expires
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthResponseDto> logoutUser​(String token, javax.servlet.http.HttpServletResponse res)  
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponseDto> refreshAuthToken​(String appId, io.mosip.kernel.core.authmanager.model.RefreshTokenRequest refreshTokenRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse res)
      Internal API used by syncdata delegate API
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponse> refreshToken​(String appId, io.mosip.kernel.core.authmanager.model.RefreshTokenRequest refreshTokenRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse res)
      API to retry token when auth token expires
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponse> sendOTP​(@Valid io.mosip.kernel.core.http.RequestWrapper<io.mosip.kernel.core.authmanager.model.OtpUser> otpUserDto)
      API to send OTP otpUser is of type OtpUser
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponse> userIdOTP​(@Valid io.mosip.kernel.core.http.RequestWrapper<io.mosip.kernel.core.authmanager.model.UserOtp> userOtpDto, javax.servlet.http.HttpServletResponse res)
      API to validate OTP with user Id userOtp is of type UserOtp
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.MosipUserDto> validateAdminToken​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse res)
      API to validate token
      io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.MosipUserDto> validateToken​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse res)
      API to validate token
    • Constructor Detail

      • AuthController

        public AuthController()
    • Method Detail

      • sendOTP

        @ResponseFilter
        @PostMapping("/authenticate/sendotp")
        @ResponseStatus(OK)
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponse> sendOTP​(@RequestBody @Valid
                                                                                                                       @Valid io.mosip.kernel.core.http.RequestWrapper<io.mosip.kernel.core.authmanager.model.OtpUser> otpUserDto)
                                                                                                                throws Exception
        API to send OTP otpUser is of type OtpUser
        Returns:
        ResponseEntity with OTP Sent message
        Throws:
        Exception
      • userIdOTP

        @ResponseFilter
        @PostMapping("/authenticate/useridOTP")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponse> userIdOTP​(@RequestBody @Valid
                                                                                                                         @Valid io.mosip.kernel.core.http.RequestWrapper<io.mosip.kernel.core.authmanager.model.UserOtp> userOtpDto,
                                                                                                                         javax.servlet.http.HttpServletResponse res)
                                                                                                                  throws Exception
        API to validate OTP with user Id userOtp is of type UserOtp
        Returns:
        ResponseEntity with Cookie value with Auth token
        Throws:
        Exception
      • clientIdSecretKey

        @ResponseFilter
        @PostMapping("/authenticate/clientidsecretkey")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponse> clientIdSecretKey​(@RequestBody @Valid
                                                                                                                                 @Valid io.mosip.kernel.core.http.RequestWrapper<io.mosip.kernel.core.authmanager.model.ClientSecret> clientSecretDto,
                                                                                                                                 javax.servlet.http.HttpServletResponse res)
                                                                                                                          throws Exception
        API to authenticate using clientId and secretKey clientSecretDto is of type ClientSecretDto
        Returns:
        ResponseEntity with Cookie value with Auth token
        Throws:
        Exception
      • validateToken

        @ResponseFilter
        @PostMapping("/authorize/validateToken")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.MosipUserDto> validateToken​(javax.servlet.http.HttpServletRequest request,
                                                                                                                            javax.servlet.http.HttpServletResponse res)
                                                                                                                     throws AuthManagerException,
                                                                                                                            Exception
        API to validate token
        Returns:
        ResponseEntity with MosipUserDto
        Throws:
        AuthManagerException
        Exception
      • validateAdminToken

        @ResponseFilter
        @GetMapping("/authorize/admin/validateToken")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.MosipUserDto> validateAdminToken​(javax.servlet.http.HttpServletRequest request,
                                                                                                                                 javax.servlet.http.HttpServletResponse res)
        API to validate token
        Returns:
        ResponseEntity with MosipUserDto
        Throws:
        IOException
        io.mosip.kernel.core.util.exception.JsonMappingException
        io.mosip.kernel.core.util.exception.JsonParseException
      • refreshToken

        @ResponseFilter
        @PostMapping("/authorize/refreshToken/{appid}")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponse> refreshToken​(@PathVariable("appid")
                                                                                                                            String appId,
                                                                                                                            @RequestBody
                                                                                                                            io.mosip.kernel.core.authmanager.model.RefreshTokenRequest refreshTokenRequest,
                                                                                                                            javax.servlet.http.HttpServletRequest request,
                                                                                                                            javax.servlet.http.HttpServletResponse res)
                                                                                                                     throws Exception
        API to retry token when auth token expires
        Returns:
        ResponseEntity with MosipUserDto
        Throws:
        Exception
      • invalidateToken

        @ResponseFilter
        @PostMapping("/authorize/invalidateToken")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponse> invalidateToken​(javax.servlet.http.HttpServletRequest request,
                                                                                                                               javax.servlet.http.HttpServletResponse res)
                                                                                                                        throws Exception
        API to invalidate token when both refresh and auth token expires
        Returns:
        ResponseEntity with MosipUserDto
        Throws:
        Exception
      • getAllRoles

        @ResponseFilter
        @GetMapping("/roles/{appid}")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.RolesListDto> getAllRoles​(@PathVariable("appid")
                                                                                                                          String appId)
                                                                                                                   throws Exception
        Throws:
        Exception
      • getListOfUsersDetails

        @ResponseFilter
        @PostMapping("/userdetails/{appid}")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.MosipUserListDto> getListOfUsersDetails​(@RequestBody
                                                                                                                                        io.mosip.kernel.core.http.RequestWrapper<UserDetailsRequestDto> userDetails,
                                                                                                                                        @PathVariable("appid")
                                                                                                                                        String appId)
                                                                                                                                 throws Exception
        Throws:
        Exception
      • getUserDetailsWithSalt

        @ResponseFilter
        @PostMapping("/usersaltdetails/{appid}")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.MosipUserSaltListDto> getUserDetailsWithSalt​(@RequestBody
                                                                                                                                             io.mosip.kernel.core.http.RequestWrapper<UserDetailsRequestDto> userDetails,
                                                                                                                                             @PathVariable("appid")
                                                                                                                                             String appId)
                                                                                                                                      throws Exception
        Throws:
        Exception
      • getRId

        @ResponseFilter
        @GetMapping("rid/{appid}/{userid}")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.RIdDto> getRId​(@PathVariable("appid")
                                                                                                               String appId,
                                                                                                               @PathVariable("userid")
                                                                                                               String userId)
                                                                                                        throws Exception
        This API will fetch RID based on appId and userId.
        Parameters:
        appId - - application Id
        userId - - user Id
        Returns:
        RIdDto
        Throws:
        Exception
      • logoutUser

        @ResponseFilter
        @DeleteMapping("/logout/user")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthResponseDto> logoutUser​(@CookieValue(value="Authorization",required=false)
                                                                                                                            String token,
                                                                                                                            javax.servlet.http.HttpServletResponse res)
        Parameters:
        req - - HttpServletRequest
        res - - HttpServletResponse
        Returns:
        ResponseWrapper
      • getAllAuthTokens

        @ResponseFilter
        @PostMapping("/authenticate/internal/useridPwd")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponseDto> getAllAuthTokens​(@RequestBody @Valid
                                                                                                                                   @Valid io.mosip.kernel.core.http.RequestWrapper<io.mosip.kernel.core.authmanager.model.LoginUserWithClientId> request,
                                                                                                                                   javax.servlet.http.HttpServletResponse res)
                                                                                                                            throws Exception
        Internal API used by syncdata delegate API
        Parameters:
        request -
        res -
        Returns:
        Throws:
        Exception
      • getAllAuthTokensForOTP

        @ResponseFilter
        @PostMapping("/authenticate/internal/userotp")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponseDto> getAllAuthTokensForOTP​(@RequestBody @Valid
                                                                                                                                         @Valid io.mosip.kernel.core.http.RequestWrapper<io.mosip.kernel.core.authmanager.model.UserOtp> request,
                                                                                                                                         javax.servlet.http.HttpServletResponse res)
                                                                                                                                  throws Exception
        Internal API used by syncdata delegate API
        Parameters:
        request -
        res -
        Returns:
        Throws:
        Exception
      • refreshAuthToken

        @ResponseFilter
        @PostMapping("/authorize/internal/refreshToken/{appid}")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.AuthNResponseDto> refreshAuthToken​(@PathVariable("appid")
                                                                                                                                   String appId,
                                                                                                                                   @RequestBody
                                                                                                                                   io.mosip.kernel.core.authmanager.model.RefreshTokenRequest refreshTokenRequest,
                                                                                                                                   javax.servlet.http.HttpServletRequest request,
                                                                                                                                   javax.servlet.http.HttpServletResponse res)
                                                                                                                            throws Exception
        Internal API used by syncdata delegate API
        Parameters:
        appId -
        refreshTokenRequest -
        request -
        res -
        Returns:
        Throws:
        Exception
      • getIndividualId

        @ResponseFilter
        @GetMapping("individualId/{appid}/{userid}")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.IndividualIdDto> getIndividualId​(@PathVariable("appid")
                                                                                                                                 String appId,
                                                                                                                                 @PathVariable("userid")
                                                                                                                                 String userId)
        This API will fetch RID based on appId and userId.
        Parameters:
        appId - - application Id
        userId - - user Id
        Returns:
        IndividualIdDto
        Throws:
        Exception
      • getUsersDetails

        @ResponseFilter
        @GetMapping("/userdetails/{appid}")
        public io.mosip.kernel.core.http.ResponseWrapper<io.mosip.kernel.core.authmanager.model.MosipUserListDto> getUsersDetails​(@PathVariable("appid")
                                                                                                                                  String appId,
                                                                                                                                  @RequestParam(required=false,name="roleName")
                                                                                                                                  String roleName,
                                                                                                                                  @RequestParam(defaultValue="0",required=false,name="pageStart")
                                                                                                                                  int pageStart,
                                                                                                                                  @RequestParam(defaultValue="0",required=false,name="pageFetch")
                                                                                                                                  int pageFetch,
                                                                                                                                  @RequestParam(required=false,name="email")
                                                                                                                                  String email,
                                                                                                                                  @RequestParam(required=false,name="firstName")
                                                                                                                                  String firstName,
                                                                                                                                  @RequestParam(required=false,name="lastName")
                                                                                                                                  String lastName,
                                                                                                                                  @RequestParam(required=false,name="userName")
                                                                                                                                  String userName,
                                                                                                                                  @RequestParam(required=false,name="search")
                                                                                                                                  String search)
                                                                                                                           throws Exception
        This API will fetch all users based on appId and roles for role bases search only pagination will work. with out role can be searched by all. email,firstName,lastName and userName
        Parameters:
        appId -
        roleName -
        Returns:
        Throws:
        Exception