Search in sources :

Example 81 with OAuth

use of org.wso2.carbon.apimgt.rest.integration.tests.store.auth.OAuth in project carbon-apimgt by wso2.

the class APIUtil method isMapExistingAuthAppsEnabled.

/**
 * Used to check whether Provisioning Out-of-Band OAuth Clients feature is enabled
 *
 * @return true if feature is enabled
 */
public static boolean isMapExistingAuthAppsEnabled() {
    APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
    String mappingEnabled = config.getFirstProperty(APIConstants.API_STORE_MAP_EXISTING_AUTH_APPS);
    if (mappingEnabled == null) {
        return false;
    }
    return Boolean.parseBoolean(mappingEnabled);
}
Also used : APIManagerConfiguration(org.wso2.carbon.apimgt.impl.APIManagerConfiguration)

Example 82 with OAuth

use of org.wso2.carbon.apimgt.rest.integration.tests.store.auth.OAuth in project airavata by apache.

the class OAuthAppRegisteringClient method registerApplication.

public OAuthConsumerAppDTO registerApplication(String appName, String consumerId, String consumerSecret) throws AiravataSecurityException {
    try {
        OAuthConsumerAppDTO consumerAppDTO = new OAuthConsumerAppDTO();
        consumerAppDTO.setApplicationName(appName);
        // consumer key and secret is set by the application.
        consumerAppDTO.setOauthConsumerKey(consumerId);
        consumerAppDTO.setOauthConsumerSecret(consumerSecret);
        // consumerAppDTO.setUsername(adminUserName);
        // initialize trust store for SSL handshake
        TrustStoreManager trustStoreManager = new TrustStoreManager();
        trustStoreManager.initializeTrustStoreManager(Properties.TRUST_STORE_PATH, Properties.TRUST_STORE_PASSWORD);
        stub.registerOAuthApplicationData(consumerAppDTO);
        // After registration application is retrieve
        return stub.getOAuthApplicationDataByAppName(appName);
    } catch (AxisFault axisFault) {
        axisFault.printStackTrace();
        throw new AiravataSecurityException("Error in registering the OAuth application.");
    } catch (RemoteException e) {
        e.printStackTrace();
        throw new AiravataSecurityException("Error in registering the OAuth application.");
    } catch (OAuthAdminServiceException e) {
        e.printStackTrace();
        throw new AiravataSecurityException("Error in registering the OAuth application.");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) OAuthAdminServiceException(org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceException) OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) TrustStoreManager(org.apache.airavata.security.util.TrustStoreManager) RemoteException(java.rmi.RemoteException) AiravataSecurityException(org.apache.airavata.security.AiravataSecurityException)

Aggregations

APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)26 HashMap (java.util.HashMap)18 ArrayList (java.util.ArrayList)14 Test (org.junit.Test)14 OAuthApplicationInfo (org.wso2.carbon.apimgt.api.model.OAuthApplicationInfo)13 Map (java.util.Map)11 JSONObject (org.json.simple.JSONObject)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 OAuthApplicationInfo (org.wso2.carbon.apimgt.core.models.OAuthApplicationInfo)9 JsonObject (com.google.gson.JsonObject)8 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)8 KeyManagementException (org.wso2.carbon.apimgt.core.exception.KeyManagementException)8 TokenResponse (org.wso2.carbon.apimgt.gateway.mediators.oauth.client.TokenResponse)8 LinkedHashMap (java.util.LinkedHashMap)6 Test (org.testng.annotations.Test)6 IOException (java.io.IOException)5 ParseException (org.json.simple.parser.ParseException)5 OAuthAppRequest (org.wso2.carbon.apimgt.api.model.OAuthAppRequest)5 MultiEnvironmentOverview (org.wso2.carbon.apimgt.core.configuration.models.MultiEnvironmentOverview)5 APIMAppConfigurations (org.wso2.carbon.apimgt.rest.api.authenticator.configuration.models.APIMAppConfigurations)5