org.wildfly.security.manager.WildFlySecurityManager.setCurrentContextClassLoaderPrivileged()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.wildfly.security.manager.WildFlySecurityManager.setCurrentContextClassLoaderPrivileged()方法的一些代码示例,展示了WildFlySecurityManager.setCurrentContextClassLoaderPrivileged()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WildFlySecurityManager.setCurrentContextClassLoaderPrivileged()方法的具体详情如下:
包路径:org.wildfly.security.manager.WildFlySecurityManager
类名称:WildFlySecurityManager
方法名:setCurrentContextClassLoaderPrivileged

WildFlySecurityManager.setCurrentContextClassLoaderPrivileged介绍

[英]Set the current thread's context class loader, doing a faster permission check that skips having to execute a privileged action frame.
[中]设置当前线程的上下文类加载器,执行更快的权限检查,从而跳过必须执行特权操作框架的操作。

代码示例

代码示例来源:origin: wildfly/wildfly

@Override
  public void tearDown() {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
  }
};

代码示例来源:origin: wildfly/wildfly

private static byte[] initSecContext(final GSSContext gssContext, final byte[] inputBuf, final int offset, final int len) throws GSSException {
  final ClassLoader old = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(GssapiClient.class);
  try {
    return gssContext.initSecContext(inputBuf, offset, len);
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(old);
  }
}

代码示例来源:origin: wildfly/wildfly

private static byte[] initSecContext(final GSSContext gssContext, final byte[] inputBuf, final int offset, final int len) throws GSSException {
    final ClassLoader old = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(Gs2SaslClient.class);
    try {
      return gssContext.initSecContext(inputBuf, offset, len);
    } finally {
      WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(old);
    }

  }
}

代码示例来源:origin: wildfly/wildfly

@Override
  public Handle setup() {
    final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
    return new Handle() {
      @Override
      public void tearDown() {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
      }
    };
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
  public String getJndiViewInstanceValue() {
    final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
      WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(objectFactoryClassInstance.getClass().getClassLoader());
      return String.valueOf(getReference().getInstance());
    } finally {
      WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl);
    }
  }
});

代码示例来源:origin: wildfly/wildfly

@Override
public String getInstanceClassName() {
  final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
  try {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(objectFactoryClassInstance.getClass().getClassLoader());
    final Object value = getReference().getInstance();
    return value != null ? value.getClass().getName() : ContextListManagedReferenceFactory.DEFAULT_INSTANCE_CLASS_NAME;
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl);
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
  public String getJndiViewInstanceValue() {
    final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
      WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(objectFactoryClassInstance.getClass().getClassLoader());
      return String.valueOf(getReference().getInstance());
    } finally {
      WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

private ClassLoader setClassLoaderTo(final ClassLoader targetClassLoader){
    ClassLoader current = null;
    if(WildFlySecurityManager.isChecking()){
      current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
      WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(targetClassLoader);
    } else {
      current = Thread.currentThread().getContextClassLoader();
      Thread.currentThread().setContextClassLoader(targetClassLoader);
    }
    return current;
  }
}

代码示例来源:origin: wildfly/wildfly

private ClassLoader setClassLoaderTo(final ClassLoader targetClassLoader){
    ClassLoader current = null;
    if(WildFlySecurityManager.isChecking()){
      current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
      WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(targetClassLoader);
    } else {
      current = Thread.currentThread().getContextClassLoader();
      Thread.currentThread().setContextClassLoader(targetClassLoader);
    }
    return current;
  }
}

代码示例来源:origin: wildfly/wildfly

public static Class<?> loadClass(final String className, final Module module) throws ClassNotFoundException {
  final ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
  try {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
    return Class.forName(className, false, module.getClassLoader());
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public List<Long> getRunningExecutions(final String jobName) throws NoSuchJobException, JobSecurityException {
  checkState(jobName);
  final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
  try {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
    return super.getRunningExecutions(jobName);
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public List<JobInstance> getJobInstances(final String jobName, final int start, final int count) throws NoSuchJobException, JobSecurityException {
  checkState(jobName);
  final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
  try {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
    return super.getJobInstances(jobName, start, count);
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public int getJobInstanceCount(final String jobName) throws NoSuchJobException, JobSecurityException {
  checkState(jobName);
  final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
  try {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
    return super.getJobInstanceCount(jobName);
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public ValidatorContext usingContext() {
  final ClassLoader oldTCCL = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
  try {
    // Make sure the deployment's CL is set
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
    return getDelegate().usingContext();
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTCCL);
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public void stop(final StopContext context) {
  final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
  try {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
    ValidatorFactory validatorFactory = deploymentUnit.getAttachment(BeanValidationAttachments.VALIDATOR_FACTORY);
    if (validatorFactory != null) {
      validatorFactory.close();
    }
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl);
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public ResetContextHandle setup() throws IllegalStateException {
  final ClassLoaderResetContextHandle resetContextHandle = new ClassLoaderResetContextHandle(WildFlySecurityManager.getCurrentContextClassLoaderPrivileged());
  WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
  return resetContextHandle;
}

代码示例来源:origin: wildfly/wildfly

private void deactivate() {
  ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
  try {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
    endpoint.deactivate(endpointFactory, activationSpec);
  } catch (ResourceException re) {
    throw EjbLogger.ROOT_LOGGER.failureDuringEndpointDeactivation(this.getComponentName(), re);
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public List<JobExecution> getJobExecutions(final JobInstance instance) throws NoSuchJobInstanceException, JobSecurityException {
  checkState();
  final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
  try {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
    validateJob(instance == null ? null : instance.getJobName());
    return super.getJobExecutions(instance);
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
  }
}

代码示例来源:origin: wildfly/wildfly

private ValidatorFactory initFactory() {
  final ClassLoader oldTCCL = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
  try {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
    return Validation.byDefaultProvider().providerResolver(new WildFlyProviderResolver()).configure()
        .buildValidatorFactory();
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTCCL);
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public void stop(final long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException, JobSecurityException {
  checkState(null, "stop");
  final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
  try {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
    final JobInstance instance = super.getJobInstance(executionId);
    validateJob(instance.getJobName());
    super.stop(executionId);
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
  }
}

相关文章

微信公众号

最新文章

更多