lib/util/token-util.js
function verifyPermission(appId,uaaCredential) {
	var deferred = Q.defer();

	var cloudControllerUrl = process.env.cloudControllerUrl;
	if (!cloudControllerUrl) {
		var errMsg = "The system variable 'cloudControllerUrl' is missing.";
		ibmlogger.getLogger().error(errMsg);
		deferred.reject({code:Constant.MISSING_CLOUDCONTROLLERURL_ERROR,message:errMsg});
		return;
	}

	if (cloudControllerUrl[cloudControllerUrl.length-1]!='/') {
		cloudControllerUrl += '/';
	}
	cloudControllerUrl += 'v2/apps/'+appId+'/summary';

	var requestOptions = {url: cloudControllerUrl,headers: {'Authorization': uaaCredential}};
	request.get(requestOptions, function(error,response,body){
		if (error || response.statusCode != 200) {
			var errMsg = error?"["+error+"]":"["+response.statusCode+":"+body+"] Access Url '"+requestUrl+"' failed";
			ibmlogger.getLogger().error(errMsg);

			return deferred.reject(false);
		}
		else {
			return deferred.resolve(true);
		}
	});

	return deferred.promise;
}
function verifyPermission(appId,uaaCredential) {
	var deferred = Q.defer();

	var cloudControllerUrl = process.env.cloudControllerUrl;
	if (!cloudControllerUrl) {
		var errMsg = "The system variable 'cloudControllerUrl' is missing.";
		ibmlogger.getLogger().error(errMsg);
		deferred.reject({code:Constant.MISSING_CLOUDCONTROLLERURL_ERROR,message:errMsg});
		return;
	}

	if (cloudControllerUrl[cloudControllerUrl.length-1]!='/') {
		cloudControllerUrl += '/';
	}
	cloudControllerUrl += 'v2/apps/'+appId+'/summary';

	var requestOptions = {url: cloudControllerUrl,headers: {'Authorization': uaaCredential}};
	request.get(requestOptions, function(error,response,body){
		if (error || response.statusCode != 200) {
			var errMsg = error?"["+error+"]":"["+response.statusCode+":"+body+"] Access Url '"+requestUrl+"' failed";
			ibmlogger.getLogger().error(errMsg);

			return deferred.reject(false);
		}
		else {
			return deferred.resolve(true);
		}
	});

	return deferred.promise;
}
function verifyPermission ( appId , uaaCredential ) { var deferred = Q . defer ( ) ; var cloudControllerUrl = process . env . cloudControllerUrl ; if ( ! cloudControllerUrl ) { var errMsg = "The system variable 'cloudControllerUrl' is missing." ; ibmlogger . getLogger ( ) . error ( errMsg ) ; deferred . reject ( { code : Constant . MISSING_CLOUDCONTROLLERURL_ERROR , message : errMsg } ) ; return ; } if ( cloudControllerUrl [ cloudControllerUrl . length - 1 ] != '/' ) { cloudControllerUrl += '/' ; } cloudControllerUrl += 'v2/apps/' + appId + '/summary' ; var requestOptions = { url : cloudControllerUrl , headers : { 'Authorization' : uaaCredential } } ; request . get ( requestOptions , function ( error , response , body ) { if ( error || response . statusCode != 200 ) { var errMsg = error ? "[" + error + "]" : "[" + response . statusCode + ":" + body + "] Access Url '" + requestUrl + "' failed" ; ibmlogger . getLogger ( ) . error ( errMsg ) ; return deferred . reject ( false ) ; } else { return deferred . resolve ( true ) ; } } ) ; return deferred . promise ; }
Check if the given uaa credential has permisstion to access the appid.
@param appId
@param uaaCredential
@returns
Check if the given uaa credential has permisstion to access the appid .