<%


var log = new Log();
var userName = session.get("user");
var oauthClient = require('oauthAdminClient.jag');

var i18n = session.get("i18n");

function edit(){
    try{
// handle error 

        var req = <xsd:revokeAuthzForAppsByResoureOwner xmlns:xsd="http://org.apache.axis2/xsd" xmlns:xsd1="http://dto.oauth.identity.carbon.wso2.org/xsd">
                           <xsd:revokeRequestDTO>
                              <xsd1:apps></xsd1:apps>
                              <xsd1:authzUser></xsd1:authzUser>
                              <xsd1:consumerKey></xsd1:consumerKey>
                              <xsd1:consumerSecret></xsd1:consumerSecret>
                           </xsd:revokeRequestDTO>
                        </xsd:revokeAuthzForAppsByResoureOwner>;

        var appName = request.getParameter("appName");
        log.info(appName);
        if(appName != null){
            req.*::revokeRequestDTO.*::apps.setChildren(appName);
            var resp = oauthClient.revoke(req);
            if(resp['return']['error'] === 'false'){
                log.info("Successfully revoked the authorization from the application");
  //              response.sendRedirect("../../my_authorized_apps.jag?s=1&sMsg=revoke_success");
            }else{
                var errorMsg = resp['return']['errorMsg'];
                response.sendRedirect("../../index.jag?e=1&error=" + errorMsg);
            }
        }else{
            response.sendRedirect("../../index.jag?e=1&error=app_name_null");
            return;
        }


    }catch(e){
        log.error(e);
        response.sendRedirect("../../index.jag?e=1&error=" + e);

    }
}

edit();

%>
