Search in sources :

Example 11 with CodeSource

use of java.security.CodeSource in project pinpoint by naver.

the class AbstractPinpointPluginTestSuite method resolveTestClassLocation.

private String resolveTestClassLocation(Class<?> testClass) {
    CodeSource codeSource = testClass.getProtectionDomain().getCodeSource();
    URL testClassLocation = codeSource.getLocation();
    return toPathString(testClassLocation);
}
Also used : CodeSource(java.security.CodeSource) URL(java.net.URL)

Example 12 with CodeSource

use of java.security.CodeSource in project pinpoint by naver.

the class DependencyGraph method currentWorkingDir.

private String currentWorkingDir() {
    CodeSource codeSource = this.getClass().getProtectionDomain().getCodeSource();
    URL location = codeSource.getLocation();
    String dir = location.getPath();
    return dir;
}
Also used : CodeSource(java.security.CodeSource) URL(java.net.URL)

Example 13 with CodeSource

use of java.security.CodeSource in project pinpoint by naver.

the class JarProfilerPluginClassInjectorTest method getSampleJar.

private URL getSampleJar(Class clazz) {
    final CodeSource codeSource = clazz.getProtectionDomain().getCodeSource();
    final URL location = codeSource.getLocation();
    logger.debug("url:{}", location);
    return location;
}
Also used : CodeSource(java.security.CodeSource) URL(java.net.URL)

Example 14 with CodeSource

use of java.security.CodeSource in project pinpoint by naver.

the class AgentDirBaseClassPathResolverTest method getClassLocation.

private static String getClassLocation(Class<?> clazz) {
    CodeSource codeSource = clazz.getProtectionDomain().getCodeSource();
    URL location = codeSource.getLocation();
    logger.debug("codeSource.getLocation:{}", location);
    File file = FileUtils.toFile(location);
    return file.getPath();
}
Also used : CodeSource(java.security.CodeSource) JarFile(java.util.jar.JarFile) File(java.io.File) URL(java.net.URL)

Example 15 with CodeSource

use of java.security.CodeSource in project powermock by powermock.

the class AgentInitialization method getPathToJarFileContainingThisClass.

private String getPathToJarFileContainingThisClass() {
    CodeSource codeSource = AgentInitialization.class.getProtectionDomain().getCodeSource();
    if (codeSource == null) {
        return null;
    }
    // URI is needed to deal with spaces and non-ASCII characters
    URI jarFileURI;
    try {
        jarFileURI = codeSource.getLocation().toURI();
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }
    return new File(jarFileURI).getPath();
}
Also used : URISyntaxException(java.net.URISyntaxException) CodeSource(java.security.CodeSource) URI(java.net.URI) File(java.io.File)

Aggregations

CodeSource (java.security.CodeSource)85 URL (java.net.URL)43 ProtectionDomain (java.security.ProtectionDomain)29 File (java.io.File)24 IOException (java.io.IOException)16 Certificate (java.security.cert.Certificate)14 URISyntaxException (java.net.URISyntaxException)10 Permissions (java.security.Permissions)10 Policy (java.security.Policy)10 JarFile (java.util.jar.JarFile)10 PermissionCollection (java.security.PermissionCollection)9 URI (java.net.URI)8 FilePermission (java.io.FilePermission)7 MalformedURLException (java.net.MalformedURLException)5 AccessControlContext (java.security.AccessControlContext)5 URLClassLoader (java.net.URLClassLoader)4 GroovyClassLoader (groovy.lang.GroovyClassLoader)3 JarURLConnection (java.net.JarURLConnection)3 SocketPermission (java.net.SocketPermission)3 Path (java.nio.file.Path)3