use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerConfigurationDTO in project carbon-apimgt by wso2.
the class APIAdminImpl method deleteKeyManagerConfigurationById.
@Override
public void deleteKeyManagerConfigurationById(String organization, KeyManagerConfigurationDTO kmConfig) throws APIManagementException {
if (kmConfig != null) {
if (!APIConstants.KeyManager.DEFAULT_KEY_MANAGER.equals(kmConfig.getName())) {
deleteIdentityProvider(organization, kmConfig);
apiMgtDAO.deleteKeyManagerConfigurationById(kmConfig.getUuid(), organization);
new KeyMgtNotificationSender().notify(kmConfig, APIConstants.KeyManager.KeyManagerEvent.ACTION_DELETE);
} else {
throw new APIManagementException(APIConstants.KeyManager.DEFAULT_KEY_MANAGER + " couldn't delete", ExceptionCodes.INTERNAL_ERROR);
}
}
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerConfigurationDTO in project carbon-apimgt by wso2.
the class ApplicationRegistrationSimpleWorkflowExecutorTest method init.
@Before
public void init() throws APIManagementException {
PowerMockito.mockStatic(ApiMgtDAO.class);
PowerMockito.mockStatic(KeyManagerHolder.class);
apiMgtDAO = Mockito.mock(ApiMgtDAO.class);
keyManager = Mockito.mock(KeyManager.class);
application = new Application("test", new Subscriber("testUser"));
oAuthAppRequest = new OAuthAppRequest();
oAuthApplicationInfo = new OAuthApplicationInfo();
oAuthAppRequest.setOAuthApplicationInfo(oAuthApplicationInfo);
workflowDTO = new ApplicationRegistrationWorkflowDTO();
workflowDTO.setWorkflowReference("1");
workflowDTO.setApplication(application);
workflowDTO.setAppInfoDTO(oAuthAppRequest);
workflowDTO.setKeyManager("default");
KeyManagerConfigurationDTO kmConfigDTO = new KeyManagerConfigurationDTO();
kmConfigDTO.setOrganization("carbon.super");
kmConfigDTO.setName("default");
PowerMockito.when(apiMgtDAO.getKeyManagerConfigurationByUUID("default")).thenReturn(kmConfigDTO);
PowerMockito.when(ApiMgtDAO.getInstance()).thenReturn(apiMgtDAO);
PowerMockito.when(KeyManagerHolder.getKeyManagerInstance("carbon.super", "default")).thenReturn(keyManager);
KeyManagerConfiguration keyManagerConfiguration = new KeyManagerConfiguration();
Mockito.when(keyManager.getKeyManagerConfiguration()).thenReturn(keyManagerConfiguration);
applicationRegistrationSimpleWorkflowExecutor = new ApplicationRegistrationSimpleWorkflowExecutor();
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerConfigurationDTO in project carbon-apimgt by wso2.
the class KeymanagersApiServiceImpl method keymanagersGet.
public Response keymanagersGet(String xWSO2Tenant, MessageContext messageContext) {
xWSO2Tenant = SubscriptionValidationDataUtil.validateTenantDomain(xWSO2Tenant, messageContext);
try {
APIAdmin apiAdmin = new APIAdminImpl();
List<KeyManagerConfigurationDTO> keyManagerConfigurations = apiAdmin.getKeyManagerConfigurationsByOrganization(xWSO2Tenant);
List<KeyManagerDTO> keyManagerDTOList = new ArrayList<>();
for (KeyManagerConfigurationDTO keyManagerConfiguration : keyManagerConfigurations) {
keyManagerDTOList.add(toKeyManagerDTO(xWSO2Tenant, keyManagerConfiguration));
}
return Response.ok(keyManagerDTOList).build();
} catch (APIManagementException e) {
RestApiUtil.handleInternalServerError("Error while retrieving key manager configurations", e, log);
}
return null;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerConfigurationDTO in project carbon-apimgt by wso2.
the class KeyManagerMappingUtil method toKeyManagerListDto.
public static KeyManagerListDTO toKeyManagerListDto(List<KeyManagerConfigurationDTO> keyManagerConfigurations) {
KeyManagerListDTO keyManagerListDTO = new KeyManagerListDTO();
List<KeyManagerInfoDTO> keyManagerInfoDTOList = new ArrayList<>();
for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) {
keyManagerInfoDTOList.add(fromKeyManagerConfigurationDtoToKeyManagerInfoDto(keyManagerConfigurationDTO));
}
keyManagerListDTO.setList(keyManagerInfoDTOList);
keyManagerListDTO.setCount(keyManagerInfoDTOList.size());
return keyManagerListDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerConfigurationDTO in project carbon-apimgt by wso2.
the class KeyManagerMappingUtil method fromKeyManagerConfigurationDtoToKeyManagerInfoDto.
private static KeyManagerInfoDTO fromKeyManagerConfigurationDtoToKeyManagerInfoDto(KeyManagerConfigurationDTO configurationDto) {
KeyManagerInfoDTO keyManagerInfoDTO = new KeyManagerInfoDTO();
keyManagerInfoDTO.setName(configurationDto.getName());
keyManagerInfoDTO.setDisplayName(configurationDto.getDisplayName());
keyManagerInfoDTO.setDescription(configurationDto.getDescription());
keyManagerInfoDTO.setId(configurationDto.getUuid());
keyManagerInfoDTO.setEnabled(configurationDto.isEnabled());
keyManagerInfoDTO.setType(configurationDto.getType());
return keyManagerInfoDTO;
}
Aggregations