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;
}
Aggregations