Tabnine Logo
System.getSecurityManager
Code IndexAdd Tabnine to your IDE (free)

How to use
getSecurityManager
method
in
java.lang.System

Best Java code snippets using java.lang.System.getSecurityManager (Showing top 20 results out of 13,032)

origin: spring-projects/spring-framework

protected boolean isSecurityManagerPresent() {
  return (System.getSecurityManager() != null);
}
origin: netty/netty

public DefaultThreadFactory(String poolName, boolean daemon, int priority) {
  this(poolName, daemon, priority, System.getSecurityManager() == null ?
      Thread.currentThread().getThreadGroup() : System.getSecurityManager().getThreadGroup());
}
origin: netty/netty

static ClassLoader getSystemClassLoader() {
  if (System.getSecurityManager() == null) {
    return ClassLoader.getSystemClassLoader();
  } else {
    return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
      @Override
      public ClassLoader run() {
        return ClassLoader.getSystemClassLoader();
      }
    });
  }
}
origin: netty/netty

static ClassLoader getClassLoader(final Class<?> clazz) {
  if (System.getSecurityManager() == null) {
    return clazz.getClassLoader();
  } else {
    return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
      @Override
      public ClassLoader run() {
        return clazz.getClassLoader();
      }
    });
  }
}
origin: apache/incubator-dubbo

public NamedThreadFactory(String prefix, boolean daemon) {
  mPrefix = prefix + "-thread-";
  mDaemon = daemon;
  SecurityManager s = System.getSecurityManager();
  mGroup = (s == null) ? Thread.currentThread().getThreadGroup() : s.getThreadGroup();
}
origin: apache/incubator-dubbo

public NamedThreadFactory(String prefix, boolean daemon) {
  mPrefix = prefix + "-thread-";
  mDaemon = daemon;
  SecurityManager s = System.getSecurityManager();
  mGroup = (s == null) ? Thread.currentThread().getThreadGroup() : s.getThreadGroup();
}
origin: netty/netty

static ClassLoader getContextClassLoader() {
  if (System.getSecurityManager() == null) {
    return Thread.currentThread().getContextClassLoader();
  } else {
    return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
      @Override
      public ClassLoader run() {
        return Thread.currentThread().getContextClassLoader();
      }
    });
  }
}
origin: prestodb/presto

/**
 * Checks whether the user has permission 'ConverterManager.alterPartialConverters'.
 * 
 * @throws SecurityException if the user does not have the permission
 */
private void checkAlterPartialConverters() throws SecurityException {
  SecurityManager sm = System.getSecurityManager();
  if (sm != null) {
    sm.checkPermission(new JodaTimePermission("ConverterManager.alterPartialConverters"));
  }
}
origin: spring-projects/spring-framework

@Override
public Object instantiate(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner,
    final Constructor<?> ctor, Object... args) {
  if (!bd.hasMethodOverrides()) {
    if (System.getSecurityManager() != null) {
      // use own privileged to change accessibility (when security is on)
      AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
        ReflectionUtils.makeAccessible(ctor);
        return null;
      });
    }
    return BeanUtils.instantiateClass(ctor, args);
  }
  else {
    return instantiateWithMethodInjection(bd, beanName, owner, ctor, args);
  }
}
origin: netty/netty

@Override
public void freeDirectBuffer(ByteBuffer buffer) {
  // Try to minimize overhead when there is no SecurityManager present.
  // See https://bugs.openjdk.java.net/browse/JDK-8191053.
  if (System.getSecurityManager() == null) {
    try {
      INVOKE_CLEANER.invoke(PlatformDependent0.UNSAFE, buffer);
    } catch (Throwable cause) {
      PlatformDependent0.throwException(cause);
    }
  } else {
    freeDirectBufferPrivileged(buffer);
  }
}
origin: spring-projects/spring-framework

@Nullable
private Method determineDestroyMethod(String name) {
  try {
    if (System.getSecurityManager() != null) {
      return AccessController.doPrivileged((PrivilegedAction<Method>) () -> findDestroyMethod(name));
    }
    else {
      return findDestroyMethod(name);
    }
  }
  catch (IllegalArgumentException ex) {
    throw new BeanDefinitionValidationException("Could not find unique destroy method on bean with name '" +
        this.beanName + ": " + ex.getMessage());
  }
}
origin: spring-projects/spring-framework

/**
 * Retrieve all candidate methods for the given class, considering
 * the {@link RootBeanDefinition#isNonPublicAccessAllowed()} flag.
 * Called as the starting point for factory method determination.
 */
private Method[] getCandidateMethods(Class<?> factoryClass, RootBeanDefinition mbd) {
  if (System.getSecurityManager() != null) {
    return AccessController.doPrivileged((PrivilegedAction<Method[]>) () ->
        (mbd.isNonPublicAccessAllowed() ?
          ReflectionUtils.getAllDeclaredMethods(factoryClass) : factoryClass.getMethods()));
  }
  else {
    return (mbd.isNonPublicAccessAllowed() ?
        ReflectionUtils.getAllDeclaredMethods(factoryClass) : factoryClass.getMethods());
  }
}
origin: google/guava

public void testExistsThrowsSecurityException() throws IOException, URISyntaxException {
 SecurityManager oldSecurityManager = System.getSecurityManager();
 try {
  doTestExistsThrowsSecurityException();
 } finally {
  System.setSecurityManager(oldSecurityManager);
 }
}
origin: netty/netty

@Override
public void freeDirectBuffer(ByteBuffer buffer) {
  if (!buffer.isDirect()) {
    return;
  }
  if (System.getSecurityManager() == null) {
    try {
      freeDirectBuffer0(buffer);
    } catch (Throwable cause) {
      PlatformDependent0.throwException(cause);
    }
  } else {
    freeDirectBufferPrivileged(buffer);
  }
}
origin: spring-projects/spring-framework

private Object instantiate(
    String beanName, RootBeanDefinition mbd, Constructor constructorToUse, Object[] argsToUse) {
  try {
    InstantiationStrategy strategy = this.beanFactory.getInstantiationStrategy();
    if (System.getSecurityManager() != null) {
      return AccessController.doPrivileged((PrivilegedAction<Object>) () ->
          strategy.instantiate(mbd, beanName, this.beanFactory, constructorToUse, argsToUse),
          this.beanFactory.getAccessControlContext());
    }
    else {
      return strategy.instantiate(mbd, beanName, this.beanFactory, constructorToUse, argsToUse);
    }
  }
  catch (Throwable ex) {
    throw new BeanCreationException(mbd.getResourceDescription(), beanName,
        "Bean instantiation via constructor failed", ex);
  }
}
origin: spring-projects/spring-framework

private Object instantiate(String beanName, RootBeanDefinition mbd,
    @Nullable Object factoryBean, Method factoryMethod, Object[] args) {
  try {
    if (System.getSecurityManager() != null) {
      return AccessController.doPrivileged((PrivilegedAction<Object>) () ->
          this.beanFactory.getInstantiationStrategy().instantiate(
              mbd, beanName, this.beanFactory, factoryBean, factoryMethod, args),
          this.beanFactory.getAccessControlContext());
    }
    else {
      return this.beanFactory.getInstantiationStrategy().instantiate(
          mbd, beanName, this.beanFactory, factoryBean, factoryMethod, args);
    }
  }
  catch (Throwable ex) {
    throw new BeanCreationException(mbd.getResourceDescription(), beanName,
        "Bean instantiation via factory method failed", ex);
  }
}
origin: spring-projects/spring-framework

public CallbacksSecurityTests() {
  // setup security
  if (System.getSecurityManager() == null) {
    Policy policy = Policy.getPolicy();
    URL policyURL = getClass()
        .getResource(
            "/org/springframework/beans/factory/support/security/policy.all");
    System.setProperty("java.security.policy", policyURL.toString());
    System.setProperty("policy.allowSystemProperty", "true");
    policy.refresh();
    System.setSecurityManager(new SecurityManager());
  }
}
origin: spring-projects/spring-framework

@Before
public void setUp() {
  originalSecurityManager = System.getSecurityManager();
  env = StandardEnvironmentTests.getModifiableSystemEnvironment();
  env.put(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "p1");
}
origin: google/guava

/**
 * Tests that the use of a {@link FinalizableReferenceQueue} does not subsequently prevent the
 * loader of that class from being garbage-collected.
 */
public void testUnloadableWithoutSecurityManager() throws Exception {
 if (isJdk9OrHigher()) {
  return;
 }
 SecurityManager oldSecurityManager = System.getSecurityManager();
 try {
  System.setSecurityManager(null);
  doTestUnloadable();
 } finally {
  System.setSecurityManager(oldSecurityManager);
 }
}
origin: google/guava

public void testUnloadableInStaticFieldIfClosed() throws Exception {
 if (isJdk9OrHigher()) {
  return;
 }
 Policy oldPolicy = Policy.getPolicy();
 SecurityManager oldSecurityManager = System.getSecurityManager();
 try {
  Policy.setPolicy(new PermissivePolicy());
  System.setSecurityManager(new SecurityManager());
  WeakReference<ClassLoader> loaderRef = doTestUnloadableInStaticFieldIfClosed();
  GcFinalization.awaitClear(loaderRef);
 } finally {
  System.setSecurityManager(oldSecurityManager);
  Policy.setPolicy(oldPolicy);
 }
}
java.langSystemgetSecurityManager

Javadoc

Returns null. Android does not use SecurityManager. This method is only provided for source compatibility.

Popular methods of System

  • currentTimeMillis
    Returns the current time in milliseconds. Note that while the unit of time of the return value is a
  • getProperty
    Returns the value of a particular system property. The defaultValue will be returned if no such prop
  • arraycopy
  • exit
  • setProperty
    Sets the value of a particular system property.
  • nanoTime
    Returns the current timestamp of the most precise timer available on the local system, in nanosecond
  • getenv
    Returns the value of the environment variable with the given name, or null if no such variable exist
  • getProperties
    Returns the system properties. Note that this is not a copy, so that changes made to the returned Pr
  • identityHashCode
    Returns an integer hash code for the parameter. The hash code returned is the same one that would be
  • gc
    Indicates to the VM that it would be a good time to run the garbage collector. Note that this is a h
  • lineSeparator
    Returns the system's line separator. On Android, this is "\n". The value comes from the value of the
  • clearProperty
    Removes a specific system property.
  • lineSeparator,
  • clearProperty,
  • setOut,
  • setErr,
  • console,
  • loadLibrary,
  • load,
  • setSecurityManager,
  • mapLibraryName

Popular in Java

  • Finding current android device location
  • addToBackStack (FragmentTransaction)
  • getSystemService (Context)
  • setContentView (Activity)
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • JPanel (javax.swing)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now