当前位置: 首页>>代码示例>>Java>>正文


Java SecurityUtils类代码示例

本文整理汇总了Java中org.apache.harmony.security.fortress.SecurityUtils的典型用法代码示例。如果您正苦于以下问题:Java SecurityUtils类的具体用法?Java SecurityUtils怎么用?Java SecurityUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SecurityUtils类属于org.apache.harmony.security.fortress包,在下文中一共展示了SecurityUtils类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getContext

import org.apache.harmony.security.fortress.SecurityUtils; //导入依赖的package包/类
/**
 * Returns the {@code AccessControlContext} for the current {@code Thread}
 * including the inherited access control context of the thread that spawned
 * the current thread (recursively).
 * <p>
 * The returned context may be used to perform access checks at a later
 * point in time, possibly by another thread.
 *
 * @return the {@code AccessControlContext} for the current {@code Thread}
 * @see Thread#currentThread
 */
public static AccessControlContext getContext() {

    // duplicates (if any) will be removed in ACC constructor
    ProtectionDomain[] stack = getStackDomains();

    Thread currentThread = Thread.currentThread();
    if (currentThread == null || AccessController.contexts == null) {
        // Big boo time. No need to check anything ?
        return new AccessControlContext(stack);
    }

    List<AccessControlContext> threadContexts = contextsForThread();

    // if we're in a doPrivileged method, use its context.
    AccessControlContext that = threadContexts.isEmpty()
            ? SecurityUtils.getContext(currentThread)
            : threadContexts.get(threadContexts.size() - 1);

    if (that != null && that.combiner != null) {
        ProtectionDomain[] assigned = null;
        if (that.context != null && that.context.length != 0) {
            assigned = new ProtectionDomain[that.context.length];
            System.arraycopy(that.context, 0, assigned, 0, assigned.length);
        }
        ProtectionDomain[] protectionDomains = that.combiner.combine(stack, assigned);
        if (protectionDomains == null) {
            protectionDomains = new ProtectionDomain[0];
        }
        return new AccessControlContext(protectionDomains, that.combiner);
    }

    return new AccessControlContext(stack, that);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:45,代码来源:AccessController.java

示例2: getContext

import org.apache.harmony.security.fortress.SecurityUtils; //导入依赖的package包/类
/**
 * @com.intel.drl.spec_ref 
 */
public static AccessControlContext getContext() {

    // duplicates (if any) will be removed in ACC constructor
    ProtectionDomain[] stack = getStackDomains();
    
    Thread currThread = Thread.currentThread();
    if (currThread == null || contexts == null) {
        // Big boo time. No need to check anything ? 
        return new AccessControlContext(stack);
    }

    ArrayList<AccessControlContext> threadContexts;
    synchronized (contexts) {
        threadContexts = contexts.get(currThread);
    }
    
    AccessControlContext that;
    if ((threadContexts == null) || (threadContexts.size() == 0)) {
        // We were not in doPrivileged method, so
        // have inherited context here
        that = SecurityUtils.getContext(currThread);
    } else {
        // We were in doPrivileged method, so
        // Use context passed to the doPrivileged()
        that = threadContexts.get(threadContexts.size() - 1);
    }

    if (that != null && that.combiner != null) {
        ProtectionDomain[] assigned = null;
        if (that.context != null && that.context.length != 0) {
                assigned = new ProtectionDomain[that.context.length];
                System.arraycopy(that.context, 0, assigned, 0,
                        assigned.length);
        }
        ProtectionDomain[] allpds = that.combiner.combine(stack, assigned);
        if (allpds == null) {
            allpds = new ProtectionDomain[0];
        }
        return new AccessControlContext(allpds, that.combiner);
    }

    return new AccessControlContext(stack, that);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:47,代码来源:AccessController.java

示例3: Thread

import org.apache.harmony.security.fortress.SecurityUtils; //导入依赖的package包/类
/**
    * Creates a new thread object for the thread attached to VM.     
    * The first attached thread is the main thread.
    *
    * @param group determines the thread group to place the thread in
    * @param name thread's name
    * @param nativeAddr address of the attached native thread
    * @param stackeSize size of the thread's stack
    * @param priority thread's priority
    * @param daemon true if the thread is daemon, false otherwise
    */
   Thread(ThreadGroup group, String name, long nativeAddr,
       long stackSize, int priority, boolean daemon) {

       ClassLoader contextLoader = null;
       
       if (group == null) {
           if (systemThreadGroup == null) {
               // This is main thread.
               systemThreadGroup = new ThreadGroup();
               mainThreadGroup = new ThreadGroup(systemThreadGroup, "main");
               group = mainThreadGroup;
           } else {
               group = mainThreadGroup;
           }
       }

       this.group = group;
       this.stackSize = stackSize;
       this.priority = priority;
       this.daemon = daemon;
       this.threadId = getNextThreadId();
       this.name = (name != null) ? name : THREAD + threadId; 
       // Each thread created from JNI has bootstrap class loader as
       // its context class loader. The only exception is the main thread
       // which has system class loader as its context class loader.
       this.contextClassLoader = contextLoader;
       this.target = null;
       // The thread is actually running.
       this.isAlive = true;
       this.started = true;

       ThreadWeakRef newRef = new ThreadWeakRef(this);
       newRef.setNativeAddr(nativeAddr);

       SecurityUtils.putContext(this, AccessController.getContext());
       // adding the thread to the thread group should be the last action
       group.add(this);

Thread parent = currentThread();
       if (parent != null && parent.inheritableValues != null) {
           inheritableValues = new ThreadLocal.Values(parent.inheritableValues);
       } 

   }
 
开发者ID:shannah,项目名称:cn1,代码行数:56,代码来源:Thread.java


注:本文中的org.apache.harmony.security.fortress.SecurityUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。