Skip to content

Commit

Permalink
ES-328 (mosip#434)
Browse files Browse the repository at this point in the history
* ES-4 (mosip#432)

Co-authored-by: ase-101 <>

* ES-328

---------

Co-authored-by: ase-101 <>
  • Loading branch information
ase-101 committed Jan 23, 2024
1 parent 1f312f4 commit 34f6ba9
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClientDetail> result = clientDetailRepository.findById(clientDetailCreateRequestV2.getClientId());
if (result.isPresent()) {
log.error("Duplicate Client Id : {}", ErrorConstants.DUPLICATE_CLIENT_ID);
Expand All @@ -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<ClientDetail> result = clientDetailRepository.findById(clientId);
if (!result.isPresent()) {
log.error("Invalid Client Id : {}", ErrorConstants.INVALID_CLIENT_ID);
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -268,4 +268,4 @@ public static JWK generateJWK_RSA() {
return null;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class ClientManagementController {
/**
* @deprecated
* This method is no longer acceptable to create oidc client
* <p> Use {@link ClientManagementController#createOAuthClient(RequestWrapper<ClientDetailCreateRequest>)} </p>
* <p> Use {@link ClientManagementController#createClientV2(RequestWrapper<ClientDetailCreateRequest>)} </p>
*
* @param requestWrapper
* @return
Expand All @@ -63,7 +63,7 @@ public ResponseWrapper<ClientDetailResponse> createClient(
/**
* @deprecated
* This method is no longer acceptable to update oidc client
* <p> Use {@link ClientManagementController#updateOAuthClient(String, RequestWrapper<ClientDetailUpdateRequest>)} </p>
* <p> Use {@link ClientManagementController#updateClientV2(String, RequestWrapper<ClientDetailUpdateRequest>)} </p>
*
* @param requestWrapper
* @return
Expand All @@ -87,13 +87,13 @@ public ResponseWrapper<ClientDetailResponse> updateClient(@Valid @PathVariable("
}

@PostMapping(value = "/client-mgmt/oauth-client", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<ClientDetailResponse> createOAuthClient(@Valid @RequestBody RequestWrapper<ClientDetailCreateRequestV2> requestWrapper) throws Exception {
public ResponseWrapper<ClientDetailResponse> createOauthClient(@Valid @RequestBody RequestWrapper<ClientDetailCreateRequestV2> requestWrapper) throws Exception {
ResponseWrapper response = new ResponseWrapper<ClientDetailResponse>();
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());
Expand All @@ -102,14 +102,14 @@ public ResponseWrapper<ClientDetailResponse> createOAuthClient(@Valid @RequestBo


@PutMapping(value = "/client-mgmt/oauth-client/{client_id}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<ClientDetailResponse> updateOAuthClient(@Valid @PathVariable("client_id") String clientId,
public ResponseWrapper<ClientDetailResponse> updateOauthClient(@Valid @PathVariable("client_id") String clientId,
@Valid @RequestBody RequestWrapper<ClientDetailUpdateRequestV2> requestWrapper) throws Exception {
ResponseWrapper response = new ResponseWrapper<ClientDetailResponse>();
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());
Expand Down
6 changes: 3 additions & 3 deletions esignet-service/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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' , \
Expand All @@ -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' ,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' , \
Expand All @@ -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' ,\
Expand Down

0 comments on commit 34f6ba9

Please sign in to comment.