Search in sources :

Example 6 with ApplicationInfo

use of org.wso2.carbon.apimgt.api.model.ApplicationInfo in project carbon-apimgt by wso2.

the class ApplicationUtils method createOauthAppRequest.

/**
 * This method will parse json String and set properties in  OAuthApplicationInfo object.
 * Further it will initiate new OauthAppRequest  object and set applicationInfo object as its own property.
 * @param clientName client Name.
 * @param clientId The ID of the client
 * @param callbackURL This is the call back URL of the application
 * @param tokenScope The token scope
 * @param clientDetails The client details
 * @param tenantDomain
 * @param keyManagerName
 * @return appRequest object of OauthAppRequest.
 * @throws APIManagementException
 */
public static OAuthAppRequest createOauthAppRequest(String clientName, String clientId, String callbackURL, String tokenScope, String clientDetails, String tokenType, String tenantDomain, String keyManagerName) throws APIManagementException {
    // initiate OauthAppRequest object.
    OAuthAppRequest appRequest = new OAuthAppRequest();
    OAuthApplicationInfo authApplicationInfo = new OAuthApplicationInfo();
    authApplicationInfo.setClientName(clientName);
    authApplicationInfo.setCallBackURL(callbackURL);
    authApplicationInfo.addParameter("tokenScope", tokenScope);
    authApplicationInfo.setClientId(clientId);
    authApplicationInfo.setTokenType(tokenType);
    if (clientDetails != null) {
        // parse json string and set applicationInfo parameters.
        KeyManager keyManagerInstance = KeyManagerHolder.getKeyManagerInstance(tenantDomain, keyManagerName);
        if (keyManagerInstance != null) {
            authApplicationInfo = keyManagerInstance.buildFromJSON(authApplicationInfo, clientDetails);
        }
        if (log.isDebugEnabled()) {
            log.debug("Additional json parameters when building OauthAppRequest =  " + clientDetails);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("No additional json parameters when building OauthAppRequest");
        }
    }
    // set applicationInfo object
    appRequest.setOAuthApplicationInfo(authApplicationInfo);
    return appRequest;
}
Also used : OAuthAppRequest(org.wso2.carbon.apimgt.api.model.OAuthAppRequest) OAuthApplicationInfo(org.wso2.carbon.apimgt.api.model.OAuthApplicationInfo) KeyManager(org.wso2.carbon.apimgt.api.model.KeyManager)

Aggregations

OAuthApplicationInfo (org.wso2.carbon.apimgt.api.model.OAuthApplicationInfo)5 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)3 HashMap (java.util.HashMap)2 OAuthAppRequest (org.wso2.carbon.apimgt.api.model.OAuthAppRequest)2 OAuthConsumerAppDTO (org.wso2.carbon.identity.oauth.dto.OAuthConsumerAppDTO)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 JSONObject (org.json.simple.JSONObject)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 KeyManagerConfigurationDTO (org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO)1 AccessTokenInfo (org.wso2.carbon.apimgt.api.model.AccessTokenInfo)1 ApplicationInfo (org.wso2.carbon.apimgt.api.model.ApplicationInfo)1 ApplicationKeysDTO (org.wso2.carbon.apimgt.api.model.ApplicationKeysDTO)1 KeyManager (org.wso2.carbon.apimgt.api.model.KeyManager)1 KeyManagerConnectorConfiguration (org.wso2.carbon.apimgt.api.model.KeyManagerConnectorConfiguration)1 ApplicationRegistrationWorkflowDTO (org.wso2.carbon.apimgt.impl.dto.ApplicationRegistrationWorkflowDTO)1