diff --git a/client-management-service-impl/src/main/java/io/mosip/esignet/services/ClientManagementServiceImpl.java b/client-management-service-impl/src/main/java/io/mosip/esignet/services/ClientManagementServiceImpl.java index 844d026b7..4e0fb34db 100644 --- a/client-management-service-impl/src/main/java/io/mosip/esignet/services/ClientManagementServiceImpl.java +++ b/client-management-service-impl/src/main/java/io/mosip/esignet/services/ClientManagementServiceImpl.java @@ -201,7 +201,7 @@ public io.mosip.esignet.core.dto.ClientDetail getClientDetails(String clientId) @CacheEvict(value = Constants.CLIENT_DETAIL_CACHE, key = "#clientDetailCreateRequestV2.getClientId()") @Override - public ClientDetailResponse createOAuthClient(ClientDetailCreateRequestV2 clientDetailCreateRequestV2) throws EsignetException { + public ClientDetailResponse createOauthClient(ClientDetailCreateRequestV2 clientDetailCreateRequestV2) throws EsignetException { Optional result = clientDetailRepository.findById(clientDetailCreateRequestV2.getClientId()); if (result.isPresent()) { log.error("Duplicate Client Id : {}", ErrorConstants.DUPLICATE_CLIENT_ID); @@ -224,14 +224,14 @@ public ClientDetailResponse createOAuthClient(ClientDetailCreateRequestV2 client } auditWrapper.logAudit(AuditHelper.getClaimValue(SecurityContextHolder.getContext(), claimName), - Action.OAUTH_CLIENT_CREATE, ActionStatus.SUCCESS, AuditHelper.buildAuditDto(clientDetailCreateRequestV2.getClientId()), null); + Action.OIDC_CLIENT_CREATE, ActionStatus.SUCCESS, AuditHelper.buildAuditDto(clientDetailCreateRequestV2.getClientId()), null); return getClientDetailResponse(clientDetail); } @CacheEvict(value = Constants.CLIENT_DETAIL_CACHE, key = "#clientId") @Override - public ClientDetailResponse updateOAuthClient(String clientId, ClientDetailUpdateRequestV2 clientDetailUpdateRequestV2) throws EsignetException { + public ClientDetailResponse updateOauthClient(String clientId, ClientDetailUpdateRequestV2 clientDetailUpdateRequestV2) throws EsignetException { Optional result = clientDetailRepository.findById(clientId); if (!result.isPresent()) { log.error("Invalid Client Id : {}", ErrorConstants.INVALID_CLIENT_ID); @@ -249,7 +249,7 @@ public ClientDetailResponse updateOAuthClient(String clientId, ClientDetailUpdat clientDetail = clientDetailRepository.save(clientDetail); auditWrapper.logAudit(AuditHelper.getClaimValue(SecurityContextHolder.getContext(), claimName), - Action.OAUTH_CLIENT_UPDATE, ActionStatus.SUCCESS, AuditHelper.buildAuditDto(clientId), null); + Action.OIDC_CLIENT_UPDATE, ActionStatus.SUCCESS, AuditHelper.buildAuditDto(clientId), null); return getClientDetailResponse(clientDetail); } diff --git a/client-management-service-impl/src/test/java/io/mosip/esignet/ClientManagementServiceTest.java b/client-management-service-impl/src/test/java/io/mosip/esignet/ClientManagementServiceTest.java index 1458eeb61..30939df50 100644 --- a/client-management-service-impl/src/test/java/io/mosip/esignet/ClientManagementServiceTest.java +++ b/client-management-service-impl/src/test/java/io/mosip/esignet/ClientManagementServiceTest.java @@ -116,7 +116,7 @@ public void createClientV2_withValidDetail_thenPass() throws Exception { entity.setId("mock_id_v1"); entity.setStatus("active"); Mockito.when(clientDetailRepository.save(Mockito.any(ClientDetail.class))).thenReturn(entity); - ClientDetailResponse clientDetailResponse = clientManagementService.createOAuthClient(clientCreateV2ReqDto); + ClientDetailResponse clientDetailResponse = clientManagementService.createOauthClient(clientCreateV2ReqDto); Assert.assertNotNull(clientDetailResponse); Assert.assertTrue(clientDetailResponse.getClientId().equals("mock_id_v1")); Assert.assertTrue(clientDetailResponse.getStatus().equals("active")); @@ -128,7 +128,7 @@ public void createClientV2_withExistingClientId_thenFail() { ClientDetailCreateRequestV2 clientCreateV2ReqDto = new ClientDetailCreateRequestV2(); clientCreateV2ReqDto.setClientId("client_id_v1"); try { - clientManagementService.createOAuthClient(clientCreateV2ReqDto); + clientManagementService.createOauthClient(clientCreateV2ReqDto); } catch (EsignetException ex) { Assert.assertEquals(ex.getErrorCode(), ErrorConstants.DUPLICATE_CLIENT_ID); } @@ -180,7 +180,7 @@ public void updateClient_withValidClientId_thenPass() throws EsignetException { public void updateClientV2_withNonExistingClientId_thenFail() { Mockito.when(clientDetailRepository.findById("client_id_v1")).thenReturn(Optional.empty()); try { - clientManagementService.updateOAuthClient("client_id_v1", null); + clientManagementService.updateOauthClient("client_id_v1", null); } catch (EsignetException ex) { Assert.assertEquals(ex.getErrorCode(), ErrorConstants.INVALID_CLIENT_ID); } @@ -213,7 +213,7 @@ public void updateClientV2_withValidClientId_thenPass() throws EsignetException entity.setId("client_id_v1"); entity.setStatus("inactive"); Mockito.when(clientDetailRepository.save(Mockito.any(ClientDetail.class))).thenReturn(entity); - ClientDetailResponse clientDetailResponse = clientManagementService.updateOAuthClient("client_id_v1", updateV2Request); + ClientDetailResponse clientDetailResponse = clientManagementService.updateOauthClient("client_id_v1", updateV2Request); Assert.assertNotNull(clientDetailResponse); Assert.assertTrue(clientDetailResponse.getClientId().equals("client_id_v1")); Assert.assertTrue(clientDetailResponse.getStatus().equals("inactive")); @@ -268,4 +268,4 @@ public static JWK generateJWK_RSA() { return null; } -} \ No newline at end of file +} diff --git a/esignet-core/src/main/java/io/mosip/esignet/core/spi/ClientManagementService.java b/esignet-core/src/main/java/io/mosip/esignet/core/spi/ClientManagementService.java index caf27ad07..f8c30f171 100644 --- a/esignet-core/src/main/java/io/mosip/esignet/core/spi/ClientManagementService.java +++ b/esignet-core/src/main/java/io/mosip/esignet/core/spi/ClientManagementService.java @@ -45,7 +45,7 @@ public interface ClientManagementService { * @return * @throws EsignetException */ - ClientDetailResponse createOAuthClient(ClientDetailCreateRequestV2 clientDetailCreateRequestV2) throws EsignetException; + ClientDetailResponse createOauthClient(ClientDetailCreateRequestV2 clientDetailCreateRequestV2) throws EsignetException; /** * API to update registered relying party client version 2 @@ -59,6 +59,6 @@ public interface ClientManagementService { * @return * @throws EsignetException */ - ClientDetailResponse updateOAuthClient(String clientId, ClientDetailUpdateRequestV2 clientDetailUpdateRequestV2) throws EsignetException; + ClientDetailResponse updateOauthClient(String clientId, ClientDetailUpdateRequestV2 clientDetailUpdateRequestV2) throws EsignetException; } diff --git a/esignet-service/src/main/java/io/mosip/esignet/controllers/ClientManagementController.java b/esignet-service/src/main/java/io/mosip/esignet/controllers/ClientManagementController.java index 0fa2303a7..514b1c8f7 100644 --- a/esignet-service/src/main/java/io/mosip/esignet/controllers/ClientManagementController.java +++ b/esignet-service/src/main/java/io/mosip/esignet/controllers/ClientManagementController.java @@ -37,7 +37,7 @@ public class ClientManagementController { /** * @deprecated * This method is no longer acceptable to create oidc client - *

Use {@link ClientManagementController#createOAuthClient(RequestWrapper)}

+ *

Use {@link ClientManagementController#createClientV2(RequestWrapper)}

* * @param requestWrapper * @return @@ -63,7 +63,7 @@ public ResponseWrapper createClient( /** * @deprecated * This method is no longer acceptable to update oidc client - *

Use {@link ClientManagementController#updateOAuthClient(String, RequestWrapper)}

+ *

Use {@link ClientManagementController#updateClientV2(String, RequestWrapper)}

* * @param requestWrapper * @return @@ -87,13 +87,13 @@ public ResponseWrapper updateClient(@Valid @PathVariable(" } @PostMapping(value = "/client-mgmt/oauth-client", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseWrapper createOAuthClient(@Valid @RequestBody RequestWrapper requestWrapper) throws Exception { + public ResponseWrapper createOauthClient(@Valid @RequestBody RequestWrapper requestWrapper) throws Exception { ResponseWrapper response = new ResponseWrapper(); try { - response.setResponse(clientManagementService.createOAuthClient(requestWrapper.getRequest())); + response.setResponse(clientManagementService.createOauthClient(requestWrapper.getRequest())); } catch (EsignetException ex) { auditWrapper.logAudit(AuditHelper.getClaimValue(SecurityContextHolder.getContext(), claimName), - Action.OAUTH_CLIENT_CREATE, ActionStatus.ERROR, AuditHelper.buildAuditDto(requestWrapper.getRequest().getClientId()), ex); + Action.OIDC_CLIENT_CREATE, ActionStatus.ERROR, AuditHelper.buildAuditDto(requestWrapper.getRequest().getClientId()), ex); throw ex; } response.setResponseTime(IdentityProviderUtil.getUTCDateTime()); @@ -102,14 +102,14 @@ public ResponseWrapper createOAuthClient(@Valid @RequestBo @PutMapping(value = "/client-mgmt/oauth-client/{client_id}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseWrapper updateOAuthClient(@Valid @PathVariable("client_id") String clientId, + public ResponseWrapper updateOauthClient(@Valid @PathVariable("client_id") String clientId, @Valid @RequestBody RequestWrapper requestWrapper) throws Exception { ResponseWrapper response = new ResponseWrapper(); try { - response.setResponse(clientManagementService.updateOAuthClient(clientId, requestWrapper.getRequest())); + response.setResponse(clientManagementService.updateOauthClient(clientId, requestWrapper.getRequest())); } catch (EsignetException ex) { auditWrapper.logAudit(AuditHelper.getClaimValue(SecurityContextHolder.getContext(), claimName), - Action.OAUTH_CLIENT_UPDATE, ActionStatus.ERROR, AuditHelper.buildAuditDto(clientId), ex); + Action.OIDC_CLIENT_UPDATE, ActionStatus.ERROR, AuditHelper.buildAuditDto(clientId), ex); throw ex; } response.setResponseTime(IdentityProviderUtil.getUTCDateTime()); diff --git a/esignet-service/src/main/resources/application-dev.properties b/esignet-service/src/main/resources/application-dev.properties index 7d0301734..373624233 100644 --- a/esignet-service/src/main/resources/application-dev.properties +++ b/esignet-service/src/main/resources/application-dev.properties @@ -140,9 +140,9 @@ mosip.esignet.cache.expire-in-seconds={'clientdetails' : 86400, 'preauth': 180, 'linked': 60 , 'linkedcode': ${mosip.esignet.link-code-expire-in-secs}, 'linkedauth' : ${mosip.esignet.authentication-expire-in-secs}, 'consented': 120 } ## ------------------------------------------ Discovery openid-configuration ------------------------------------------- mosipbox.public.url=http://localhost:8088 -mosip.esignet.discovery.issuer-id=${mosipbox.public.url} +mosip.esignet.discovery.issuer-id=${mosipbox.public.url}${server.servlet.path} -mosip.esignet.oauth.key-values={'issuer': '${mosip.esignet.discovery.issuer-id}' ,\ +mosip.esignet.oauth.key-values={'issuer': '${mosipbox.public.url}' ,\ \ 'authorization_endpoint': '${mosipbox.public.url}${server.servlet.path}/authorize' , \ \ 'token_endpoint': '${mosipbox.public.url}${server.servlet.path}/oauth/token' , \ \ 'jwks_uri' : '${mosipbox.public.url}${server.servlet.path}/oauth/jwks.json' , \ @@ -153,7 +153,7 @@ mosip.esignet.oauth.key-values={'issuer': '${mosip.esignet.discovery.issuer-id}' \ 'grant_types_supported' : ${mosip.esignet.supported.grant.types},\ \ 'response_types_supported' : ${mosip.esignet.supported.response.types}} -mosip.esignet.discovery.key-values={'issuer': '${mosip.esignet.discovery.issuer-id}' ,\ +mosip.esignet.discovery.key-values={'issuer': '${mosipbox.public.url}' ,\ \ 'authorization_endpoint': '${mosipbox.public.url}${server.servlet.path}/authorize' , \ \ 'token_endpoint': '${mosipbox.public.url}${server.servlet.path}/oauth/token' ,\ \ 'userinfo_endpoint' : '${mosipbox.public.url}${server.servlet.path}/oidc/userinfo' ,\ diff --git a/esignet-service/src/main/resources/application-local.properties b/esignet-service/src/main/resources/application-local.properties index 9bd40b09d..9f67f471b 100644 --- a/esignet-service/src/main/resources/application-local.properties +++ b/esignet-service/src/main/resources/application-local.properties @@ -146,9 +146,9 @@ mosip.esignet.cache.expire-in-seconds={'clientdetails' : 86400, 'preauth': 180, ## ------------------------------------------ Discovery openid-configuration ------------------------------------------- mosipbox.public.url=http://localhost:8088 -mosip.esignet.discovery.issuer-id=${mosipbox.public.url} +mosip.esignet.discovery.issuer-id=${mosipbox.public.url}${server.servlet.path} -mosip.esignet.oauth.key-values={'issuer': '${mosip.esignet.discovery.issuer-id}' ,\ +mosip.esignet.oauth.key-values={'issuer': '${mosipbox.public.url}' ,\ \ 'authorization_endpoint': '${mosipbox.public.url}${server.servlet.path}/authorize' , \ \ 'token_endpoint': '${mosipbox.public.url}${server.servlet.path}/oauth/token' , \ \ 'jwks_uri' : '${mosipbox.public.url}${server.servlet.path}/oauth/jwks.json' , \ @@ -159,7 +159,7 @@ mosip.esignet.oauth.key-values={'issuer': '${mosip.esignet.discovery.issuer-id}' \ 'grant_types_supported' : ${mosip.esignet.supported.grant.types},\ \ 'response_types_supported' : ${mosip.esignet.supported.response.types}} -mosip.esignet.discovery.key-values={'issuer': '${mosip.esignet.discovery.issuer-id}' ,\ +mosip.esignet.discovery.key-values={'issuer': '${mosipbox.public.url}' ,\ \ 'authorization_endpoint': '${mosipbox.public.url}${server.servlet.path}/authorize' , \ \ 'token_endpoint': '${mosipbox.public.url}${server.servlet.path}/oauth/token' ,\ \ 'userinfo_endpoint' : '${mosipbox.public.url}${server.servlet.path}/oidc/userinfo' ,\