Java Code Examples for java.security.PrivilegedAction

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project android-client_1, under directory /src/org/apache/harmony/javax/security/auth/.

Source file: Subject.java

  31 
vote

@SuppressWarnings("unchecked") private static Object doAs_PrivilegedAction(Subject subject,PrivilegedAction action,final AccessControlContext context){
  AccessControlContext newContext;
  final SubjectDomainCombiner combiner;
  if (subject == null) {
    combiner=null;
  }
 else {
    combiner=new SubjectDomainCombiner(subject);
  }
  PrivilegedAction dccAction=new PrivilegedAction(){
    public Object run(){
      return new AccessControlContext(context,combiner);
    }
  }
;
  newContext=(AccessControlContext)AccessController.doPrivileged(dccAction);
  return AccessController.doPrivileged(action,newContext);
}
 

Example 2

From project Android_1, under directory /org.eclipse.ecf.android/src/org/eclipse/ecf/android/.

Source file: NLS.java

  31 
vote

/** 
 * Initialize the given class with the values from the specified message bundle.
 * @param bundleName fully qualified path of the class name
 * @param clazz the class where the constants will exist
 */
public static void initializeMessages(final String bundleName,final Class clazz){
  if (System.getSecurityManager() == null) {
    load(bundleName,clazz);
    return;
  }
  AccessController.doPrivileged(new PrivilegedAction(){
    public Object run(){
      load(bundleName,clazz);
      return null;
    }
  }
);
}
 

Example 3

From project AsmackService, under directory /src/org/apache/harmony/javax/security/auth/.

Source file: Subject.java

  31 
vote

@SuppressWarnings("unchecked") private static Object doAs_PrivilegedAction(Subject subject,PrivilegedAction action,final AccessControlContext context){
  AccessControlContext newContext;
  final SubjectDomainCombiner combiner;
  if (subject == null) {
    combiner=null;
  }
 else {
    combiner=new SubjectDomainCombiner(subject);
  }
  PrivilegedAction dccAction=new PrivilegedAction(){
    public Object run(){
      return new AccessControlContext(context,combiner);
    }
  }
;
  newContext=(AccessControlContext)AccessController.doPrivileged(dccAction);
  return AccessController.doPrivileged(action,newContext);
}
 

Example 4

From project bpm-console, under directory /server/integration/src/main/java/org/jboss/bpm/console/server/util/.

Source file: ServiceLoader.java

  31 
vote

/** 
 * Use the system property
 */
public static Object loadFromSystemProperty(String propertyName,String defaultFactory){
  Object factory=null;
  ClassLoader loader=Thread.currentThread().getContextClassLoader();
  PrivilegedAction action=new PropertyAccessAction(propertyName);
  String factoryName=(String)AccessController.doPrivileged(action);
  if (factoryName != null) {
    try {
      Class factoryClass=loader.loadClass(factoryName);
      factory=factoryClass.newInstance();
    }
 catch (    Throwable t) {
      throw new IllegalStateException("Failed to load " + propertyName + ": "+ factoryName,t);
    }
  }
  if (factory == null && defaultFactory != null) {
    factory=loadDefault(defaultFactory);
  }
  return factory;
}
 

Example 5

From project clojure, under directory /src/jvm/clojure/lang/.

Source file: RT.java

  31 
vote

static public ClassLoader makeClassLoader(){
  return (ClassLoader)AccessController.doPrivileged(new PrivilegedAction(){
    public Object run(){
      try {
        Var.pushThreadBindings(RT.map(USE_CONTEXT_CLASSLOADER,RT.T));
        return new DynamicClassLoader(baseLoader());
      }
  finally {
        Var.popThreadBindings();
      }
    }
  }
);
}
 

Example 6

From project commons-logging, under directory /src/java/org/apache/commons/logging/impl/.

Source file: LogFactoryImpl.java

  31 
vote

/** 
 * Calls LogFactory.directGetContextClassLoader under the control of an AccessController class. This means that java code running under a security manager that forbids access to ClassLoaders will still work if this class is given appropriate privileges, even when the caller doesn't have such privileges. Without using an AccessController, the the entire call stack must have the privilege before the call is allowed.
 * @return the context classloader associated with the current thread,or null if security doesn't allow it.
 * @throws LogConfigurationException if there was some weird error whileattempting to get the context classloader.
 * @throws SecurityException if the current java security policy doesn'tallow this class to access the context classloader.
 */
private static ClassLoader getContextClassLoaderInternal() throws LogConfigurationException {
  return (ClassLoader)AccessController.doPrivileged(new PrivilegedAction(){
    public Object run(){
      return LogFactory.directGetContextClassLoader();
    }
  }
);
}
 

Example 7

From project dnieprov, under directory /src/org/dnieprov/jce/provider/.

Source file: DnieProvider.java

  31 
vote

public DnieProvider(){
  super(PROVIDER_NAME,VERSION,INFO);
  AccessController.doPrivileged(new PrivilegedAction(){
    @Override public Object run(){
      setup();
      return null;
    }
  }
);
}
 

Example 8

From project etherpad, under directory /infrastructure/rhino1_7R1/src/org/mozilla/javascript/.

Source file: PolicySecurityController.java

  31 
vote

public GeneratedClassLoader createClassLoader(final ClassLoader parent,final Object securityDomain){
  return (Loader)AccessController.doPrivileged(new PrivilegedAction(){
    public Object run(){
      return new Loader(parent,(CodeSource)securityDomain);
    }
  }
);
}
 

Example 9

From project formic, under directory /src/java/edu/emory/mathcs/backport/java/util/concurrent/helpers/.

Source file: Utils.java

  31 
vote

SunPerfProvider(){
  perf=(sun.misc.Perf)AccessController.doPrivileged(new PrivilegedAction(){
    public Object run(){
      return sun.misc.Perf.getPerf();
    }
  }
);
  long numerator=1000000000;
  long denominator=perf.highResFrequency();
  long gcd=gcd(numerator,denominator);
  this.multiplier=numerator / gcd;
  this.divisor=denominator / gcd;
}
 

Example 10

From project Gemini-Blueprint, under directory /test-support/src/main/java/org/eclipse/gemini/blueprint/test/.

Source file: AbstractDependencyManagerTests.java

  31 
vote

private String readProperty(final String name){
  if (System.getSecurityManager() != null) {
    return (String)AccessController.doPrivileged(new PrivilegedAction(){
      public Object run(){
        return System.getProperty(name);
      }
    }
);
  }
 else   return System.getProperty(name);
}
 

Example 11

From project api, under directory /weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/.

Source file: TCCLSingletonProvider.java

  29 
vote

private ClassLoader getClassLoader(){
  SecurityManager sm=System.getSecurityManager();
  if (sm != null) {
    return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>(){
      public ClassLoader run(){
        return Thread.currentThread().getContextClassLoader();
      }
    }
);
  }
 else {
    return Thread.currentThread().getContextClassLoader();
  }
}
 

Example 12

From project arquillian-container-gae, under directory /gae-common/src/main/java/org/jboss/arquillian/container/common/.

Source file: AppEngineCommonContainer.java

  29 
vote

public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
  prepareArchive(archive);
  FixedExplodedExporter exporter=new FixedExplodedExporter(archive,AccessController.doPrivileged(new PrivilegedAction<File>(){
    public File run(){
      return new File(System.getProperty("java.io.tmpdir"));
    }
  }
));
  appLocation=exporter.export();
  return doDeploy(archive);
}
 

Example 13

From project arquillian-container-openshift, under directory /openshift-express/src/main/java/org/jboss/arquillian/container/openshift/express/.

Source file: SecurityActions.java

  29 
vote

static List<Method> getMethods(final Class<?> source){
  List<Method> declaredAccessableMethods=AccessController.doPrivileged(new PrivilegedAction<List<Method>>(){
    public List<Method> run(){
      return Arrays.asList(source.getDeclaredMethods());
    }
  }
);
  return declaredAccessableMethods;
}
 

Example 14

From project arquillian-container-tomcat, under directory /tomcat-managed-5.5/src/main/java/org/jboss/arquillian/container/tomcat/managed_5_5/.

Source file: TomcatManagedConfiguration.java

  29 
vote

@Override public void validate() throws ConfigurationException {
  super.validate();
  Validate.configurationDirectoryExists(catalinaHome,"Either CATALINA_HOME environment variable or catalinaHome property in Arquillian configuration must be set and point to a valid directory! " + catalinaHome + " is not valid directory!");
  Validate.configurationDirectoryExists(javaHome,"Either JAVA_HOME environment variable or javaHome property in Arquillian configuration must be set and point to a valid directory! " + javaHome + " is not valid directory!");
  Validate.isValidFile(catalinaHome + "/conf/" + serverConfig,"The server configuration file denoted by serverConfig property has to exist! This file: " + catalinaHome + "/conf/"+ serverConfig+ " does not!");
  this.outputToConsole=AccessController.doPrivileged(new PrivilegedAction<Boolean>(){
    @Override public Boolean run(){
      String val=System.getProperty("org.apache.tomcat.writeconsole");
      return val == null || !"false".equals(val);
    }
  }
);
}
 

Example 15

From project arquillian-core, under directory /config/impl-base/src/main/java/org/jboss/arquillian/config/impl/extension/.

Source file: SysPropertyActions.java

  29 
vote

public String getProperty(final String name,final String defaultValue){
  final PrivilegedAction<String> action=new PrivilegedAction<String>(){
    public String run(){
      return System.getProperty(name,defaultValue);
    }
  }
;
  return (String)AccessController.doPrivileged(action);
}
 

Example 16

From project arquillian-extension-android, under directory /android-configuration/src/main/java/org/jboss/arquillian/android/configuration/.

Source file: SecurityActions.java

  29 
vote

static List<Field> getFieldsWithAnnotation(final Class<?> source,final Class<? extends Annotation> annotationClass){
  List<Field> declaredAccessableFields=AccessController.doPrivileged(new PrivilegedAction<List<Field>>(){
    public List<Field> run(){
      List<Field> foundFields=new ArrayList<Field>();
      Class<?> nextSource=source;
      while (nextSource != Object.class) {
        for (        Field field : nextSource.getDeclaredFields()) {
          if (field.isAnnotationPresent(annotationClass)) {
            if (!field.isAccessible()) {
              field.setAccessible(true);
            }
            foundFields.add(field);
          }
        }
        nextSource=nextSource.getSuperclass();
      }
      return foundFields;
    }
  }
);
  return declaredAccessableFields;
}
 

Example 17

From project arquillian-extension-drone, under directory /drone-configuration/src/main/java/org/jboss/arquillian/drone/configuration/.

Source file: SecurityActions.java

  29 
vote

static Map<String,Field> getAccessableFields(final Class<?> source){
  Map<String,Field> declaredAccessableFields=AccessController.doPrivileged(new PrivilegedAction<Map<String,Field>>(){
    public Map<String,Field> run(){
      Map<String,Field> foundFields=new LinkedHashMap<String,Field>();
      for (      Field field : source.getDeclaredFields()) {
        if (Modifier.isFinal(field.getModifiers())) {
          continue;
        }
        if (!field.isAccessible()) {
          field.setAccessible(true);
        }
        foundFields.put(field.getName(),field);
      }
      return foundFields;
    }
  }
);
  return declaredAccessableFields;
}
 

Example 18

From project arquillian-extension-persistence, under directory /impl/src/main/java/org/jboss/arquillian/persistence/core/configuration/.

Source file: SecurityActions.java

  29 
vote

static List<Field> getAccessibleFields(final Class<?> source){
  List<Field> declaredAccessableFields=AccessController.doPrivileged(new PrivilegedAction<List<Field>>(){
    public List<Field> run(){
      List<Field> foundFields=new ArrayList<Field>();
      for (      Field field : source.getDeclaredFields()) {
        if (Modifier.isFinal(field.getModifiers())) {
          continue;
        }
        if (!field.isAccessible()) {
          field.setAccessible(true);
        }
        foundFields.add(field);
      }
      return foundFields;
    }
  }
);
  return declaredAccessableFields;
}
 

Example 19

From project arquillian-extension-seam2, under directory /src/main/java/org/jboss/arquillian/seam2/configuration/.

Source file: SecurityActions.java

  29 
vote

static List<Field> getAccessibleFields(final Class<?> source){
  List<Field> declaredAccessableFields=AccessController.doPrivileged(new PrivilegedAction<List<Field>>(){
    public List<Field> run(){
      List<Field> foundFields=new ArrayList<Field>();
      for (      Field field : source.getDeclaredFields()) {
        if (Modifier.isFinal(field.getModifiers())) {
          continue;
        }
        if (!field.isAccessible()) {
          field.setAccessible(true);
        }
        foundFields.add(field);
      }
      return foundFields;
    }
  }
);
  return declaredAccessableFields;
}
 

Example 20

From project arquillian-extension-spring, under directory /arquillian-service-integration-spring/src/main/java/org/jboss/arquillian/spring/integration/container/.

Source file: SecurityActions.java

  29 
vote

/** 
 * <p>Retrieves current thread class loader.</p>
 * @return the class loader
 */
private static ClassLoader getThreadContextClassLoader(){
  return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>(){
    public ClassLoader run(){
      return Thread.currentThread().getContextClassLoader();
    }
  }
);
}
 

Example 21

From project arquillian-extension-warp, under directory /impl/src/main/java/org/jboss/arquillian/warp/impl/server/test/.

Source file: SecurityActions.java

  29 
vote

static List<Field> getFieldsWithAnnotation(final Class<?> source,final Class<? extends Annotation> annotationClass){
  List<Field> declaredAccessableFields=AccessController.doPrivileged(new PrivilegedAction<List<Field>>(){
    public List<Field> run(){
      List<Field> foundFields=new ArrayList<Field>();
      Class<?> nextSource=source;
      while (nextSource != Object.class) {
        for (        Field field : nextSource.getDeclaredFields()) {
          if (field.isAnnotationPresent(annotationClass)) {
            if (!field.isAccessible()) {
              field.setAccessible(true);
            }
            foundFields.add(field);
          }
        }
        nextSource=nextSource.getSuperclass();
      }
      return foundFields;
    }
  }
);
  return declaredAccessableFields;
}
 

Example 22

From project arquillian-graphene, under directory /graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/configuration/.

Source file: SecurityActions.java

  29 
vote

static Map<String,Field> getAccessableFields(final Class<?> source){
  Map<String,Field> declaredAccessableFields=AccessController.doPrivileged(new PrivilegedAction<Map<String,Field>>(){
    public Map<String,Field> run(){
      Map<String,Field> foundFields=new LinkedHashMap<String,Field>();
      for (      Field field : source.getDeclaredFields()) {
        if (Modifier.isFinal(field.getModifiers())) {
          continue;
        }
        if (!field.isAccessible()) {
          field.setAccessible(true);
        }
        foundFields.put(field.getName(),field);
      }
      return foundFields;
    }
  }
);
  return declaredAccessableFields;
}
 

Example 23

From project arquillian-showcase, under directory /extensions/autodiscover/src/main/java/org/jboss/arquillian/showcase/extension/autodiscover/.

Source file: ReflectionHelper.java

  29 
vote

public static List<Field> getFieldsWithAnnotation(final Class<?> source,final Class<? extends Annotation> annotationClass){
  List<Field> declaredAccessableFields=AccessController.doPrivileged(new PrivilegedAction<List<Field>>(){
    public List<Field> run(){
      List<Field> foundFields=new ArrayList<Field>();
      Class<?> nextSource=source;
      while (nextSource != Object.class) {
        for (        Field field : nextSource.getDeclaredFields()) {
          if (field.isAnnotationPresent(annotationClass)) {
            if (!field.isAccessible()) {
              field.setAccessible(true);
            }
            foundFields.add(field);
          }
        }
        nextSource=nextSource.getSuperclass();
      }
      return foundFields;
    }
  }
);
  return declaredAccessableFields;
}
 

Example 24

From project arquillian_deprecated, under directory /containers/openejb-embedded-3.1/src/main/java/org/jboss/arquillian/container/openejb/embedded_3_1/.

Source file: OpenEJBTestEnricher.java

  29 
vote

/** 
 * {@inheritDoc}
 * @see org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher#enrich(org.jboss.arquillian.spi.Context,java.lang.Object)
 */
@Override public void enrich(Object testCase){
  super.enrich(testCase);
  final Class<? extends Annotation> inject=(Class<? extends Annotation>)Inject.class;
  List<Field> fieldsWithInject=this.getFieldsWithAnnotation(testCase.getClass(),inject);
  for (  final Field field : fieldsWithInject) {
    if (!field.isAccessible()) {
      AccessController.doPrivileged(new PrivilegedAction<Void>(){
        public Void run(){
          field.setAccessible(true);
          return null;
        }
      }
);
    }
    try {
      final Object resolvedVaue;
      final ArquillianContext arquillianContext=this.getArquillianContext();
      final Class<?> type=field.getType();
      if (field.isAnnotationPresent(Properties.class)) {
        final Properties properties=field.getAnnotation(Properties.class);
        resolvedVaue=arquillianContext.get(type,properties);
      }
 else       if (field.isAnnotationPresent(Property.class)) {
        final Property property=field.getAnnotation(Property.class);
        final Properties properties=new PropertiesImpl(new Property[]{property});
        resolvedVaue=arquillianContext.get(type,properties);
      }
 else {
        resolvedVaue=arquillianContext.get(type);
      }
      field.set(testCase,resolvedVaue);
    }
 catch (    final IllegalAccessException e) {
      throw new RuntimeException("Could not inject into " + field.getName() + " of test case: "+ testCase,e);
    }
  }
}
 

Example 25

From project aviator, under directory /src/test/java/com/googlecode/aviator/code/asm/.

Source file: ASMCodeGeneratorUnitTest.java

  29 
vote

@Before public void setUp(){
  final AviatorClassLoader classloader=AccessController.doPrivileged(new PrivilegedAction<AviatorClassLoader>(){
    public AviatorClassLoader run(){
      return new AviatorClassLoader(Thread.currentThread().getContextClassLoader());
    }
  }
);
  this.codeGenerator=new ASMCodeGenerator(classloader,System.out,true);
  this.codeGenerator.start();
}
 

Example 26

From project blueprint-namespaces, under directory /blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/.

Source file: AggregateConverter.java

  29 
vote

public boolean canConvert(final Object fromValue,final ReifiedType toType){
  if (fromValue == null) {
    return true;
  }
  if (isAssignable(fromValue,toType)) {
    return true;
  }
  boolean canConvert=false;
  AccessControlContext acc=blueprintContainer.getAccessControlContext();
  if (acc == null) {
    canConvert=canConvertWithConverters(fromValue,toType);
  }
 else {
    canConvert=AccessController.doPrivileged(new PrivilegedAction<Boolean>(){
      public Boolean run(){
        return canConvertWithConverters(fromValue,toType);
      }
    }
,acc);
  }
  if (canConvert) {
    return true;
  }
  try {
    convert(fromValue,toType);
    return true;
  }
 catch (  Exception e) {
    return false;
  }
}
 

Example 27

From project capedwarf-green, under directory /common/src/main/java/org/jboss/capedwarf/common/serialization/.

Source file: SerializatorFactory.java

  29 
vote

static ClassLoader getClassLoader(final Class<?> clazz){
  SecurityManager sm=System.getSecurityManager();
  if (sm == null)   return clazz.getClassLoader();
 else   return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>(){
    public ClassLoader run(){
      return clazz.getClassLoader();
    }
  }
);
}
 

Example 28

From project ceylon-module-resolver, under directory /impl/src/main/java/com/redhat/ceylon/cmr/impl/.

Source file: SecurityActions.java

  29 
vote

static String getProperty(final String key){
  final SecurityManager sm=System.getSecurityManager();
  if (sm != null) {
    return AccessController.doPrivileged(new PrivilegedAction<String>(){
      public String run(){
        return System.getProperty(key);
      }
    }
);
  }
 else {
    return System.getProperty(key);
  }
}
 

Example 29

From project ceylon-runtime, under directory /bootstrap/src/main/java/ceylon/modules/bootstrap/loader/.

Source file: BootstrapModuleLoader.java

  29 
vote

/** 
 * Get Ceylon repository.
 * @return the ceylon repository
 */
protected static String getCeylonRepository(){
  return AccessController.doPrivileged(new PrivilegedAction<String>(){
    public String run(){
      final String defaultCeylonRepository=System.getProperty("user.home") + File.separator + ".ceylon"+ File.separator+ "repo";
      return System.getProperty("ceylon.repo",defaultCeylonRepository);
    }
  }
);
}
 

Example 30

From project core_5, under directory /exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/.

Source file: HibernateServiceImpl.java

  29 
vote

public HibernateServiceImpl(InitParams initParams,CacheService cacheService){
  threadLocal_=new ThreadLocal<Session>();
  PropertiesParam param=initParams.getPropertiesParam("hibernate.properties");
  conf_=SecurityHelper.doPrivilegedAction(new PrivilegedAction<HibernateConfigurationImpl>(){
    public HibernateConfigurationImpl run(){
      return new HibernateConfigurationImpl();
    }
  }
);
  Iterator<?> properties=param.getPropertyIterator();
  while (properties.hasNext()) {
    Property p=(Property)properties.next();
    conf_.setProperty(p.getName(),p.getValue());
  }
  String connectionURL=conf_.getProperty("hibernate.connection.url");
  if (connectionURL != null) {
    connectionURL=connectionURL.replace("${java.io.tmpdir}",PrivilegedSystemHelper.getProperty("java.io.tmpdir"));
    conf_.setProperty("hibernate.connection.url",connectionURL);
  }
}
 

Example 31

From project cxf-dosgi, under directory /dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/.

Source file: ClientServiceFactory.java

  29 
vote

public Object getService(final Bundle requestingBundle,final ServiceRegistration sreg){
  String interfaceName=sd.getInterfaces() != null && sd.getInterfaces().size() > 0 ? (String)sd.getInterfaces().toArray()[0] : null;
  LOG.fine("getService() from serviceFactory for " + interfaceName);
  try {
    Object proxy=AccessController.doPrivileged(new PrivilegedAction<Object>(){
      public Object run(){
        return handler.createProxy(sreg.getReference(),dswContext,requestingBundle.getBundleContext(),iClass,sd);
      }
    }
);
synchronized (this) {
      ++serviceCounter;
    }
    return proxy;
  }
 catch (  IntentUnsatifiedException iue) {
    LOG.info("Did not create proxy for " + interfaceName + " because intent "+ iue.getIntent()+ " could not be satisfied");
  }
catch (  Exception ex) {
    LOG.log(Level.WARNING,"Problem creating a remote proxy for " + interfaceName + " from CXF FindHook: ",ex);
  }
  return null;
}
 

Example 32

From project dcm4che, under directory /dcm4che-conf/dcm4che-conf-ldap/src/main/java/org/dcm4che/conf/ldap/.

Source file: ResourceManager.java

  29 
vote

private static ClassLoader getContextClassLoader(){
  return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>(){
    public ClassLoader run(){
      return Thread.currentThread().getContextClassLoader();
    }
  }
);
}
 

Example 33

From project dragon, under directory /hadoop-dragon-core/src/main/java/org/apache/hadoop/realtime/app/rm/launcher/.

Source file: ContainerLauncherImpl.java

  29 
vote

protected ContainerManager getCMProxy(ContainerId containerID,final String containerManagerBindAddr,ContainerToken containerToken) throws IOException {
  UserGroupInformation user=UserGroupInformation.getCurrentUser();
  if (UserGroupInformation.isSecurityEnabled()) {
    Token<ContainerTokenIdentifier> token=new Token<ContainerTokenIdentifier>(containerToken.getIdentifier().array(),containerToken.getPassword().array(),new Text(containerToken.getKind()),new Text(containerToken.getService()));
    user=UserGroupInformation.createRemoteUser(containerID.toString());
    user.addToken(token);
  }
  ContainerManager proxy=user.doAs(new PrivilegedAction<ContainerManager>(){
    @Override public ContainerManager run(){
      return (ContainerManager)rpc.getProxy(ContainerManager.class,NetUtils.createSocketAddr(containerManagerBindAddr),getConfig());
    }
  }
);
  return proxy;
}
 

Example 34

From project Extensions2Services, under directory /eu.wwuk.eclipse.extsvcs.core/src/eu/wwuk/eclipse/extsvcs/core/internal/.

Source file: BundleDelegatingClassLoader.java

  29 
vote

/** 
 * Factory method for creating a class loader over the given bundle and with a given class loader as fall-back. In case the bundle cannot find a class or locate a resource, the given class loader will be used as fall back.
 * @param bundle bundle used for class loading and resource acquisition
 * @param bridge class loader used as fall back in case the bundle cannotload a class or find a resource. Can be <code>null</code>
 * @return class loader adapter over the given bundle and class loader
 */
public static BundleDelegatingClassLoader createBundleClassLoaderFor(final Bundle bundle,final ClassLoader bridge){
  return AccessController.doPrivileged(new PrivilegedAction<BundleDelegatingClassLoader>(){
    public BundleDelegatingClassLoader run(){
      return new BundleDelegatingClassLoader(bundle,bridge);
    }
  }
);
}
 

Example 35

From project gatein-naming, under directory /src/main/java/org/gatein/naming/.

Source file: InitialContextFactoryBuilder.java

  29 
vote

private ClassLoader getContextClassLoader(){
  return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>(){
    public ClassLoader run(){
      return Thread.currentThread().getContextClassLoader();
    }
  }
);
}
 

Example 36

From project gatein-sso, under directory /agent/src/main/java/org/gatein/sso/agent/filter/.

Source file: PicketlinkSTSIntegrationFilter.java

  29 
vote

/** 
 * JBoss specific way for obtaining a Subject. TODO: is JBoss specific way needed? subject should be available in ConversationState
 * @return subject
 */
protected Subject getCurrentSubject(){
  SecurityContext securityContext=AccessController.doPrivileged(new PrivilegedAction<SecurityContext>(){
    public SecurityContext run(){
      return SecurityContextAssociation.getSecurityContext();
    }
  }
);
  return securityContext.getSubjectInfo().getAuthenticatedSubject();
}
 

Example 37

From project gemini.web.gemini-web-container, under directory /org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/.

Source file: BundleDelegatingClassLoader.java

  29 
vote

/** 
 * Factory method for creating a class loader over the given bundle and with a given class loader as fall-back. In case the bundle cannot find a class or locate a resource, the given class loader will be used as fall back.
 * @param bundle bundle used for class loading and resource acquisition
 * @param bridge class loader used as fall back in case the bundle cannot load a class or find a resource. Can be<code>null</code>
 * @return class loader adapter over the given bundle and class loader
 */
public static BundleDelegatingClassLoader createBundleClassLoaderFor(final Bundle bundle,final ClassLoader bridge){
  return AccessController.doPrivileged(new PrivilegedAction<BundleDelegatingClassLoader>(){
    @Override public BundleDelegatingClassLoader run(){
      return new BundleDelegatingClassLoader(bundle,bridge);
    }
  }
);
}