Android Open Source - android-ssl-bypass Classpath Utils






From Project

Back to project page android-ssl-bypass.

License

The source code is released under:

Copyright (c) 2012, iSEC Partners. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the ...

If you think the Android project android-ssl-bypass listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.isecpartners.android.jdwp.pluginservice;
// w ww  . jav a 2  s. c om
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;

import org.apache.log4j.Logger;

public class ClasspathUtils {

  private static Logger LOGGER = Logger.getLogger(ClasspathUtils.class
      .getName());

  @SuppressWarnings("rawtypes")
  private static final Class[] parameters = new Class[] { URL.class };

  /**
   * Adds the jars in the given directory to classpath
   * 
   * @param directory
   * @throws IOException
   */
  public static void addDirToClasspath(File directory) throws IOException {
    if (directory.exists()) {
      ClasspathUtils.LOGGER.info("adding directory to classpath: "
          + directory.getAbsolutePath());
      File[] files = directory.listFiles();
      for (int i = 0; i < files.length; i++) {
        File file = files[i];
        URI uri = file.toURI();
        String path = uri.getPath();
        if (path.endsWith(".jar")) {
          ClasspathUtils.addURL(file.toURI().toURL());
        }
      }
    } else {
      ClasspathUtils.LOGGER.warn("The directory \"" + directory
          + "\" does not exist!");
    }
  }

  /**
   * Add URL to CLASSPATH
   * 
   * @param u
   *            URL
   * @throws IOException
   *             IOException
   */
  public static void addURL(URL u) throws IOException {
    ClasspathUtils.LOGGER.info("adding to classpath");
    URLClassLoader sysLoader = (URLClassLoader) ClassLoader
        .getSystemClassLoader();
    URL urls[] = sysLoader.getURLs();

    ClasspathUtils.LOGGER.info(urls.length);
    if (ClasspathUtils.isURLInClassPath(urls, u)) {
      ClasspathUtils.LOGGER.info("already in classpath: " + u);
      return;
    }

    Class<URLClassLoader> sysclass = URLClassLoader.class;
    try {
      Method method = sysclass.getDeclaredMethod("addURL",
          ClasspathUtils.parameters);
      method.setAccessible(true);
      method.invoke(sysLoader, new Object[] { u });
    } catch (Throwable t) {
      t.printStackTrace();
      throw new IOException(
          "Error, could not add URL to system classloader");
    }
  }

  public static boolean isURLInClassPath(URL[] urls, URL u) {
    for (int i = 0; i < urls.length; i++) {
      if (urls[i].toString().equalsIgnoreCase(u.toString())) {
        ClasspathUtils.LOGGER.info("URL " + u
            + " is already in the CLASSPATH");
        return true;
      }
    }
    return false;
  }
}




Java Source Code List

com.isec.helperapp.EasySSLSocketFactory.java
com.isec.helperapp.EasyX509TrustManager.java
com.isec.helperapp.MainActivity.java
com.isec.helperapp.TrustAllTrustManager.java
com.isec.ssltest.SSLTestActivity.java
com.isecpartners.android.jdwp.ADBInterface.java
com.isecpartners.android.jdwp.ClassLoaderUtils.java
com.isecpartners.android.jdwp.ClassWrapper.java
com.isecpartners.android.jdwp.CommandLine.java
com.isecpartners.android.jdwp.Constants.java
com.isecpartners.android.jdwp.Control.java
com.isecpartners.android.jdwp.DalvikUtils.java
com.isecpartners.android.jdwp.DexClassLoaderNotFoundException.java
com.isecpartners.android.jdwp.LocationNotFoundException.java
com.isecpartners.android.jdwp.NoLoadClassMethodException.java
com.isecpartners.android.jdwp.NoVMSessionException.java
com.isecpartners.android.jdwp.NotImplementedException.java
com.isecpartners.android.jdwp.ReferenceTypeNotFoundException.java
com.isecpartners.android.jdwp.VirtualMachineEventManager.java
com.isecpartners.android.jdwp.VirtualMachineSession.java
com.isecpartners.android.jdwp.common.Message.java
com.isecpartners.android.jdwp.common.QueueAgentInterface.java
com.isecpartners.android.jdwp.common.QueueAgent.java
com.isecpartners.android.jdwp.connection.AbstractConnection.java
com.isecpartners.android.jdwp.connection.AttachingConnection.java
com.isecpartners.android.jdwp.connection.DVMConnectionProvider.java
com.isecpartners.android.jdwp.connection.DefaultConnectionFactory.java
com.isecpartners.android.jdwp.connection.NoAttachingConnectorException.java
com.isecpartners.android.jdwp.connection.NoListeningConnectorException.java
com.isecpartners.android.jdwp.plugin.JythonConsoleJDIPlugin.java
com.isecpartners.android.jdwp.plugin.SSLBypassJDIPlugin.java
com.isecpartners.android.jdwp.plugin.TestJDIPlugin.java
com.isecpartners.android.jdwp.plugin.TraceMethodsJDIPlugin.java
com.isecpartners.android.jdwp.pluginservice.AbstractJDIPlugin.java
com.isecpartners.android.jdwp.pluginservice.AbstractJythonConsolePlugin.java
com.isecpartners.android.jdwp.pluginservice.AbstractPluginService.java
com.isecpartners.android.jdwp.pluginservice.ClasspathUtils.java
com.isecpartners.android.jdwp.pluginservice.JDIPluginServiceFactory.java
com.isecpartners.android.jdwp.pluginservice.JDIPluginService.java
com.isecpartners.android.jdwp.pluginservice.JDIPlugin.java
com.isecpartners.android.jdwp.pluginservice.JythonPluginServiceFactory.java
com.isecpartners.android.jdwp.pluginservice.JythonPluginService.java
com.isecpartners.android.jdwp.pluginservice.PluginNotFoundException.java
com.isecpartners.android.jdwp.pluginservice.PluginService.java