Search in sources :

Example 1 with ApplicationKeyListDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationKeyListDTO in project carbon-apimgt by wso2.

the class ApplicationsApiServiceImpl method applicationsApplicationIdOauthKeysGet.

@Override
public Response applicationsApplicationIdOauthKeysGet(String applicationId, String xWso2Tenant, MessageContext messageContext) throws APIManagementException {
    String organization = RestApiUtil.getValidatedOrganization(messageContext);
    Set<APIKey> applicationKeys = getApplicationKeys(applicationId, organization);
    List<ApplicationKeyDTO> keyDTOList = new ArrayList<>();
    ApplicationKeyListDTO applicationKeyListDTO = new ApplicationKeyListDTO();
    applicationKeyListDTO.setCount(0);
    if (applicationKeys != null) {
        for (APIKey apiKey : applicationKeys) {
            ApplicationKeyDTO appKeyDTO = ApplicationKeyMappingUtil.fromApplicationKeyToDTO(apiKey);
            keyDTOList.add(appKeyDTO);
        }
        applicationKeyListDTO.setList(keyDTOList);
        applicationKeyListDTO.setCount(keyDTOList.size());
    }
    return Response.ok().entity(applicationKeyListDTO).build();
}
Also used : APIKey(org.wso2.carbon.apimgt.api.model.APIKey) ApplicationKeyDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationKeyDTO) ArrayList(java.util.ArrayList) ApplicationKeyListDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationKeyListDTO)

Example 2 with ApplicationKeyListDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationKeyListDTO in project carbon-apimgt by wso2.

the class ApplicationsApiServiceImpl method applicationsApplicationIdKeysGet.

/**
 * Retrieve all keys of an application
 *
 * @param applicationId Application Id
 * @return Application Key Information list
 */
@Override
public Response applicationsApplicationIdKeysGet(String applicationId, MessageContext messageContext) {
    Set<APIKey> applicationKeys = getApplicationKeys(applicationId);
    List<ApplicationKeyDTO> keyDTOList = new ArrayList<>();
    ApplicationKeyListDTO applicationKeyListDTO = new ApplicationKeyListDTO();
    applicationKeyListDTO.setCount(0);
    if (applicationKeys != null) {
        for (APIKey apiKey : applicationKeys) {
            ApplicationKeyDTO appKeyDTO = ApplicationKeyMappingUtil.fromApplicationKeyToDTO(apiKey);
            keyDTOList.add(appKeyDTO);
        }
        applicationKeyListDTO.setList(keyDTOList);
        applicationKeyListDTO.setCount(keyDTOList.size());
    }
    return Response.ok().entity(applicationKeyListDTO).build();
}
Also used : APIKey(org.wso2.carbon.apimgt.api.model.APIKey) ApplicationKeyDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationKeyDTO) ArrayList(java.util.ArrayList) ApplicationKeyListDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationKeyListDTO)

Aggregations

ArrayList (java.util.ArrayList)2 APIKey (org.wso2.carbon.apimgt.api.model.APIKey)2 ApplicationKeyDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationKeyDTO)2 ApplicationKeyListDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.ApplicationKeyListDTO)2