import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;


class Main
{
   public static void main(String[] args)
   {
      System.out.println("calling Introspect");

      final String tokenFilename = args[0]==null ? "token.base64" : args[0];

      final String USER = "02cc260f-9837-4907-b2cb-a1a2d764fb15";
      final String PWD  = "AJMi3qrB6AHRp_6y55tEwU-IpJ8uZ6X4QXeQ3W4la6dc-BlkzAY1OQpAE9hb1W7-VfYl4208FUtjE2Cl3hUYLkQ";
      final String IEP = "https://iam-escape.cloud.cnaf.infn.it/introspect";

      try
      {
         final String TOKEN = new String(Files.readAllBytes(Paths.get(tokenFilename)));

         IntrospectResponse ir = new IntrospectResponse(USER+":"+PWD, IEP, TOKEN);

         System.out.println("active: " +  ir.active );
         System.out.println("scope : " +  ir.scope );
         if(ir.active)
            System.out.println("IR: " + ir.getPathFromStorageReadScope());
      }
      catch(IOException e)
      {
         System.out.println( "EXCPT: " + e.getMessage() );
         e.printStackTrace();
      }
      catch(Exception e)
      {
         System.out.println( "EXCPT: " + e.getMessage() );
         e.printStackTrace();
      }



   }
}
