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


Java DomainCombiner类代码示例

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


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

示例1: main

import java.security.DomainCombiner; //导入依赖的package包/类
public static void main(String[]args) throws Exception {
    final DomainCombiner dc = new DomainCombiner() {
        @Override
        public ProtectionDomain[] combine(ProtectionDomain[] currentDomains, ProtectionDomain[] assignedDomains) {
            return currentDomains; // basically a no-op
        }
    };

    // Get an instance of the saved ACC
    AccessControlContext saved = AccessController.getContext();
    // Simulate the stack ACC with a DomainCombiner attached
    AccessControlContext stack = new AccessControlContext(AccessController.getContext(), dc);

    // Now try to run JavaSecurityAccess.doIntersectionPrivilege() and assert
    // whether the DomainCombiner from the stack ACC is preserved
    boolean ret = SharedSecrets.getJavaSecurityAccess().doIntersectionPrivilege(new PrivilegedAction<Boolean>() {
        @Override
        public Boolean run() {
            return dc == AccessController.getContext().getDomainCombiner();
        }
    }, stack, saved);

    if (!ret) {
        System.exit(1);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:PreserveCombinerTest.java

示例2: getCallerPrincipal

import java.security.DomainCombiner; //导入依赖的package包/类
@Override
public Principal getCallerPrincipal() {
    Principal principal = sessionContext.getCallerPrincipal();
    if (principal.getName().equalsIgnoreCase(ANONYMOUS)) {
        AccessControlContext accessControlContext = AccessController.getContext();
        DomainCombiner dc = accessControlContext.getDomainCombiner();
        if (dc instanceof SubjectDomainCombiner) {
            SubjectDomainCombiner sdc = (SubjectDomainCombiner) dc;
            Set<Principal> principals = sdc.getSubject().getPrincipals();
            if (principals != null && principals.size() > 0) {
                return principals.iterator().next();
            }
        }
    }
    return principal;
}
 
开发者ID:psnc-dl,项目名称:darceo,代码行数:17,代码来源:UserContextBean.java

示例3: getSubject

import java.security.DomainCombiner; //导入依赖的package包/类
/**
 * Returns the {@code Subject} that was last associated with the {@code
 * context} provided as argument.
 *
 * @param context
 *            the {@code context} that was associated with the
 *            {@code Subject}.
 * @return the {@code Subject} that was last associated with the {@code
 *         context} provided as argument.
 */
public static Subject getSubject(final AccessControlContext context) {
    checkPermission(_SUBJECT);
    if (context == null) {
        throw new NullPointerException("auth.09"); //$NON-NLS-1$
    }
    PrivilegedAction<DomainCombiner> action = new PrivilegedAction<DomainCombiner>() {
        public DomainCombiner run() {
            return context.getDomainCombiner();
        }
    };
    DomainCombiner combiner = AccessController.doPrivileged(action);

    if ((combiner == null) || !(combiner instanceof SubjectDomainCombiner)) {
        return null;
    }
    return ((SubjectDomainCombiner) combiner).getSubject();
}
 
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:28,代码来源:Subject.java

示例4: getSubject

import java.security.DomainCombiner; //导入依赖的package包/类
/**
 * Returns the {@code Subject} that was last associated with the {@code
 * context} provided as argument.
 *
 * @param context
 *            the {@code context} that was associated with the
 *            {@code Subject}.
 * @return the {@code Subject} that was last associated with the {@code
 *         context} provided as argument.
 */
public static Subject getSubject(final AccessControlContext context) {
    checkPermission(_SUBJECT);
    if (context == null) {
        throw new NullPointerException("AccessControlContext cannot be null");
    }
    PrivilegedAction<DomainCombiner> action = new PrivilegedAction<DomainCombiner>() {
        public DomainCombiner run() {
            return context.getDomainCombiner();
        }
    };
    DomainCombiner combiner = AccessController.doPrivileged(action);

    if ((combiner == null) || !(combiner instanceof SubjectDomainCombiner)) {
        return null;
    }
    return ((SubjectDomainCombiner) combiner).getSubject();
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:28,代码来源:Subject.java

示例5: getSubject

import java.security.DomainCombiner; //导入依赖的package包/类
/**
 * Returns the {@code Subject} that was last associated with the
 * {@code context} provided as argument.
 * 
 * @param context
 *            the {@code context} that was associated with the
 *            {@code Subject}.
 * @return the {@code Subject} that was last associated with the
 *         {@code context} provided as argument.
 */
public static Subject getSubject(final AccessControlContext context) {
	checkPermission(_SUBJECT);
	if (context == null) {
		throw new NullPointerException("auth.09"); //$NON-NLS-1$
	}
	PrivilegedAction<DomainCombiner> action = new PrivilegedAction<DomainCombiner>() {
		public DomainCombiner run() {
			return context.getDomainCombiner();
		}
	};
	DomainCombiner combiner = AccessController.doPrivileged(action);

	if ((combiner == null) || !(combiner instanceof SubjectDomainCombiner)) {
		return null;
	}
	return ((SubjectDomainCombiner) combiner).getSubject();
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:28,代码来源:Subject.java

示例6: getSubject

import java.security.DomainCombiner; //导入依赖的package包/类
/**
 * Returns the {@code Subject} that was last associated with the {@code
 * context} provided as argument.
 *
 * @param context
 *            the {@code context} that was associated with the
 *            {@code Subject}.
 * @return the {@code Subject} that was last associated with the {@code
 *         context} provided as argument.
 */
public static Subject getSubject(final AccessControlContext context) {
    checkPermission(_SUBJECT);
    if (context == null) {
        throw new NullPointerException(Messages.getString("auth.09")); //$NON-NLS-1$
    }
    PrivilegedAction<DomainCombiner> action = new PrivilegedAction<DomainCombiner>() {
        public DomainCombiner run() {
            return context.getDomainCombiner();
        }
    };
    DomainCombiner combiner = AccessController.doPrivileged(action);

    if ((combiner == null) || !(combiner instanceof SubjectDomainCombiner)) {
        return null;
    }
    return ((SubjectDomainCombiner) combiner).getSubject();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:28,代码来源:Subject.java

示例7: testContextUsage_0

import java.security.DomainCombiner; //导入依赖的package包/类
/**
 * Tests context usage.
 * Case 0: If no Config provided by user, then LoginContext uses 
 * its own context to invoke LoginModule's methods.
 */
public void testContextUsage_0() throws Exception {
    Subject dummySubj = new Subject();
    final DomainCombiner dc = new SubjectDomainCombiner(dummySubj);
    AccessControlContext acc = new AccessControlContext(AccessController
            .getContext(), dc);
    PrivilegedExceptionAction<Void> action = new PrivilegedExceptionAction<Void>() {
        public Void run() throws Exception {
            implTestContextUsage(true, dc);
            return null;
        }
    };
    AccessController.doPrivileged(action, acc);
    // additional cleanup to make it PerfTests compatible
    clear();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:LoginContext1Test.java

示例8: testContextUsage_1

import java.security.DomainCombiner; //导入依赖的package包/类
/**
 * Tests context usage.
 * Case 1: If Config was provided by user, then LoginContext 
 * uses stored user's context and performs all call to LoginModule's 
 * methods in that context.
 */
public void testContextUsage_1() throws Exception {
    Subject dummySubj = new Subject();
    final DomainCombiner dc = new SubjectDomainCombiner(dummySubj);
    AccessControlContext acc = new AccessControlContext(AccessController
            .getContext(), dc);
    PrivilegedExceptionAction<Void> action = new PrivilegedExceptionAction<Void>() {
        public Void run() throws Exception {
            implTestContextUsage(false, dc);
            return null;
        }
    };
    AccessController.doPrivileged(action, acc);
    // additional cleanup to make it PerfTests compatible
    clear();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:LoginContext1Test.java

示例9: getSubject

import java.security.DomainCombiner; //导入依赖的package包/类
public static Subject getSubject(final AccessControlContext context) {
    checkPermission(_SUBJECT);
    if (context == null) {
        throw new NullPointerException(Messages.getString("auth.09")); //$NON-NLS-1$
    }
    PrivilegedAction<DomainCombiner> action = new PrivilegedAction<DomainCombiner>() {
        public DomainCombiner run() {
            return context.getDomainCombiner();
        }
    };
    DomainCombiner combiner = AccessController.doPrivileged(action);

    if ((combiner == null) || !(combiner instanceof SubjectDomainCombiner)) {
        return null;
    }
    return ((SubjectDomainCombiner) combiner).getSubject();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:18,代码来源:Subject.java

示例10: getSubject

import java.security.DomainCombiner; //导入依赖的package包/类
/**
 * Get the {@code Subject} associated with the provided
 * {@code AccessControlContext}.
 *
 * <p> The {@code AccessControlContext} may contain many
 * Subjects (from nested {@code doAs} calls).
 * In this situation, the most recent {@code Subject} associated
 * with the {@code AccessControlContext} is returned.
 *
 * <p>
 *
 * @param  acc the {@code AccessControlContext} from which to retrieve
 *          the {@code Subject}.
 *
 * @return  the {@code Subject} associated with the provided
 *          {@code AccessControlContext}, or {@code null}
 *          if no {@code Subject} is associated
 *          with the provided {@code AccessControlContext}.
 *
 * @exception SecurityException if the caller does not have permission
 *          to get the {@code Subject}. <p>
 *
 * @exception NullPointerException if the provided
 *          {@code AccessControlContext} is {@code null}.
 */
public static Subject getSubject(final AccessControlContext acc) {

    java.lang.SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(AuthPermissionHolder.GET_SUBJECT_PERMISSION);
    }

    if (acc == null) {
        throw new NullPointerException(ResourcesMgr.getString
            ("invalid.null.AccessControlContext.provided"));
    }

    // return the Subject from the DomainCombiner of the provided context
    return AccessController.doPrivileged
        (new java.security.PrivilegedAction<Subject>() {
        public Subject run() {
            DomainCombiner dc = acc.getDomainCombiner();
            if (!(dc instanceof SubjectDomainCombiner))
                return null;
            SubjectDomainCombiner sdc = (SubjectDomainCombiner)dc;
            return sdc.getSubject();
        }
    });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:50,代码来源:Subject.java

示例11: getSubject

import java.security.DomainCombiner; //导入依赖的package包/类
/**
 * Get the {@code Subject} associated with the provided
 * {@code AccessControlContext}.
 *
 * <p> The {@code AccessControlContext} may contain many
 * Subjects (from nested {@code doAs} calls).
 * In this situation, the most recent {@code Subject} associated
 * with the {@code AccessControlContext} is returned.
 *
 * @param  acc the {@code AccessControlContext} from which to retrieve
 *          the {@code Subject}.
 *
 * @return  the {@code Subject} associated with the provided
 *          {@code AccessControlContext}, or {@code null}
 *          if no {@code Subject} is associated
 *          with the provided {@code AccessControlContext}.
 *
 * @throws SecurityException if a security manager is installed and the
 *          caller does not have an
 *          {@link AuthPermission#AuthPermission(String)
 *          AuthPermission("getSubject")} permission to get the
 *          {@code Subject}.
 *
 * @throws NullPointerException if the provided
 *          {@code AccessControlContext} is {@code null}.
 */
public static Subject getSubject(final AccessControlContext acc) {

    java.lang.SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(AuthPermissionHolder.GET_SUBJECT_PERMISSION);
    }

    Objects.requireNonNull(acc, ResourcesMgr.getString
            ("invalid.null.AccessControlContext.provided"));

    // return the Subject from the DomainCombiner of the provided context
    return AccessController.doPrivileged
        (new java.security.PrivilegedAction<>() {
        public Subject run() {
            DomainCombiner dc = acc.getDomainCombiner();
            if (!(dc instanceof SubjectDomainCombiner)) {
                return null;
            }
            SubjectDomainCombiner sdc = (SubjectDomainCombiner)dc;
            return sdc.getSubject();
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:50,代码来源:Subject.java

示例12: CustomCombiner

import java.security.DomainCombiner; //导入依赖的package包/类
public CustomCombiner(DomainCombiner domainCombiner, Subject subject) {
  super(subject);
  this.combiner = domainCombiner;
  this.subject = subject;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:6,代码来源:SecurityUtil.java

示例13: getSubject

import java.security.DomainCombiner; //导入依赖的package包/类
/**
 * Get the <code>Subject</code> associated with the provided
 * <code>AccessControlContext</code>.
 *
 * <p> The <code>AccessControlContext</code> may contain many
 * Subjects (from nested <code>doAs</code> calls).
 * In this situation, the most recent <code>Subject</code> associated
 * with the <code>AccessControlContext</code> is returned.
 *
 * <p>
 *
 * @param  acc the <code>AccessControlContext</code> from which to retrieve
 *          the <code>Subject</code>.
 *
 * @return  the <code>Subject</code> associated with the provided
 *          <code>AccessControlContext</code>, or <code>null</code>
 *          if no <code>Subject</code> is associated
 *          with the provided <code>AccessControlContext</code>.
 *
 * @exception SecurityException if the caller does not have permission
 *          to get the <code>Subject</code>. <p>
 *
 * @exception NullPointerException if the provided
 *          <code>AccessControlContext</code> is <code>null</code>.
 */
public static Subject getSubject(final AccessControlContext acc) {

    java.lang.SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(AuthPermissionHolder.GET_SUBJECT_PERMISSION);
    }

    if (acc == null) {
        throw new NullPointerException(ResourcesMgr.getString
            ("invalid.null.AccessControlContext.provided"));
    }

    // return the Subject from the DomainCombiner of the provided context
    return AccessController.doPrivileged
        (new java.security.PrivilegedAction<Subject>() {
        public Subject run() {
            DomainCombiner dc = acc.getDomainCombiner();
            if (!(dc instanceof SubjectDomainCombiner))
                return null;
            SubjectDomainCombiner sdc = (SubjectDomainCombiner)dc;
            return sdc.getSubject();
        }
    });
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:50,代码来源:Subject.java

示例14: GetPropertyWithPermission

import java.security.DomainCombiner; //导入依赖的package包/类
private int GetPropertyWithPermission()
    {
        log.info("\n\nTrying to get a system property with a required permission.");
        DomainCombiner newDomainCombiner = new MyDomainCombiner();
        AccessControlContext newContext = new AccessControlContext(AccessController.getContext(), newDomainCombiner);
        
/*        log.info("Dummy current domains before:");
        for (int i = 0; i < dummyCurrentDomains.length; i++) {
            for (int j = 0; j < dummyCurrentDomains[i].length; j++) {
                log.info("dummyCurrentDomains[" + i + "][" + j + "]: " + dummyCurrentDomains[i][j]);    
            }            
        }

        log.info("Dummy assigned domains before:");
        for (int i = 0; i < dummyAssignedDomains.length; i++) {
            for (int j = 0; j < dummyAssignedDomains[i].length; j++) {
                log.info("dummyAssignedDomains[" + i + "][" + j + "]: " + dummyAssignedDomains[i][j]);    
            }            
        }
*/        
        AccessTestClass atc = (AccessTestClass)AccessController.doPrivileged(new PrivilegedAction() {
            public Object run()
            {
//                return  (this.getClass().getProtectionDomain());
                return new AccessTestClass(propertyName);
            }            
        }, newContext);        
        log.info(""+atc);
/*        log.info("Dummy current domains after:");
        for (int i = 0; i < dummyCurrentDomains.length; i++) {
            for (int j = 0; j < dummyCurrentDomains[i].length; j++) {
                log.info("dummyCurrentDomains[" + i + "][" + j + "]: " + dummyCurrentDomains[i][j]);    
            }            
        }

        log.info("Dummy assigned domains after:");
        for (int i = 0; i < dummyAssignedDomains.length; i++) {
            for (int j = 0; j < dummyAssignedDomains[i].length; j++) {
                log.info("dummyAssignedDomains[" + i + "][" + j + "]: " + dummyAssignedDomains[i][j]);    
            }            
        }
*/
        
        if (newContext.getDomainCombiner() == null)
        {
                return fail("second");
        }
        
        try
        {
            log.info(atc.getSystemProperty());
            return Result.PASS;
        }
        catch (AccessControlException e)
        {
            e.printStackTrace();
            return Result.FAIL;
        }        
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:60,代码来源:F_AccessControllerTest_03.java

示例15: getSubject

import java.security.DomainCombiner; //导入依赖的package包/类
/**
 * <p>Returns the subject associated with the given {@link
 * AccessControlContext}.</p>
 *
 * <p>All this method does is retrieve the Subject object from the supplied
 * context's {@link DomainCombiner}, if any, and if it is an instance of
 * a {@link SubjectDomainCombiner}.
 *
 * @param context The context to retrieve the subject from.
 * @return The subject assoctiated with the context, or <code>null</code>
 *  if there is none.
 * @throws NullPointerException If <i>subject</i> is null.
 * @throws SecurityException If the caller does not have permission to get
 *  the subject (<code>"getSubject"</code> target of {@link AuthPermission}.
 */
public static Subject getSubject (final AccessControlContext context)
{
  final SecurityManager sm = System.getSecurityManager();
  if (sm != null)
    {
      sm.checkPermission (new AuthPermission ("getSubject"));
    }
  DomainCombiner dc = context.getDomainCombiner();
  if (!(dc instanceof SubjectDomainCombiner))
    {
      return null;
    }
  return ((SubjectDomainCombiner) dc).getSubject();
}
 
开发者ID:vilie,项目名称:javify,代码行数:30,代码来源:Subject.java


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