Java Code Examples for org.wso2.carbon.apimgt.impl.utils.APIUtil#getAndSetDefaultKeyManagerConfiguration()

The following examples show how to use org.wso2.carbon.apimgt.impl.utils.APIUtil#getAndSetDefaultKeyManagerConfiguration() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: APIAdminImpl.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Override
public List<KeyManagerConfigurationDTO> getKeyManagerConfigurationsByTenant(String tenantDomain)
        throws APIManagementException {

    KeyMgtRegistrationService.registerDefaultKeyManager(tenantDomain);
    List<KeyManagerConfigurationDTO> keyManagerConfigurationsByTenant =
            apiMgtDAO.getKeyManagerConfigurationsByTenant(tenantDomain);
    Iterator<KeyManagerConfigurationDTO> iterator = keyManagerConfigurationsByTenant.iterator();
    KeyManagerConfigurationDTO defaultKeyManagerConfiguration = null;
    while (iterator.hasNext()) {
        KeyManagerConfigurationDTO keyManagerConfigurationDTO = iterator.next();
        if (APIConstants.KeyManager.DEFAULT_KEY_MANAGER.equals(keyManagerConfigurationDTO.getName())) {
            defaultKeyManagerConfiguration = keyManagerConfigurationDTO;
            iterator.remove();
            break;
        }
    }
    if (defaultKeyManagerConfiguration != null) {
        APIUtil.getAndSetDefaultKeyManagerConfiguration(defaultKeyManagerConfiguration);
        keyManagerConfigurationsByTenant.add(defaultKeyManagerConfiguration);
    }
    return keyManagerConfigurationsByTenant;
}
 
Example 2
Source File: APIAdminImpl.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, List<KeyManagerConfigurationDTO>> getAllKeyManagerConfigurations()
        throws APIManagementException {

    List<KeyManagerConfigurationDTO> keyManagerConfigurations = apiMgtDAO.getKeyManagerConfigurations();
    Map<String, List<KeyManagerConfigurationDTO>> keyManagerConfigurationsByTenant = new HashMap<>();
    for (KeyManagerConfigurationDTO keyManagerConfiguration : keyManagerConfigurations) {
        List<KeyManagerConfigurationDTO> keyManagerConfigurationDTOS;
        if (keyManagerConfigurationsByTenant.containsKey(keyManagerConfiguration.getTenantDomain())) {
            keyManagerConfigurationDTOS =
                    keyManagerConfigurationsByTenant.get(keyManagerConfiguration.getTenantDomain());
        } else {
            keyManagerConfigurationDTOS = new ArrayList<>();
        }
        if (APIConstants.KeyManager.DEFAULT_KEY_MANAGER.equals(keyManagerConfiguration.getName())) {
            APIUtil.getAndSetDefaultKeyManagerConfiguration(keyManagerConfiguration);
        }
        keyManagerConfigurationDTOS.add(keyManagerConfiguration);
        keyManagerConfigurationsByTenant
                .put(keyManagerConfiguration.getTenantDomain(), keyManagerConfigurationDTOS);
    }
    return keyManagerConfigurationsByTenant;
}
 
Example 3
Source File: APIAdminImpl.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Override
public KeyManagerConfigurationDTO getKeyManagerConfigurationById(String tenantDomain, String id)
        throws APIManagementException {

    KeyManagerConfigurationDTO keyManagerConfigurationDTO =
            apiMgtDAO.getKeyManagerConfigurationByID(tenantDomain, id);
    if (keyManagerConfigurationDTO != null &&
            APIConstants.KeyManager.DEFAULT_KEY_MANAGER.equals(keyManagerConfigurationDTO.getName())) {
        APIUtil.getAndSetDefaultKeyManagerConfiguration(keyManagerConfigurationDTO);
    }

    return keyManagerConfigurationDTO;
}
 
Example 4
Source File: APIAdminImpl.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Override
public KeyManagerConfigurationDTO getKeyManagerConfigurationByName(String tenantDomain, String name)
        throws APIManagementException {

    KeyManagerConfigurationDTO keyManagerConfiguration =
            apiMgtDAO.getKeyManagerConfigurationByName(tenantDomain, name);
    if (keyManagerConfiguration != null &&
            APIConstants.KeyManager.DEFAULT_KEY_MANAGER.equals(keyManagerConfiguration.getName())) {
        APIUtil.getAndSetDefaultKeyManagerConfiguration(keyManagerConfiguration);
    }
    return keyManagerConfiguration;
}