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


Java AccessController.checkPermission方法代码示例

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


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

示例1: main

import java.security.AccessController; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        for (Permission perm : perms) {
            AccessController.checkPermission(perm);
        }

        Permission princPerm = new java.util.PropertyPermission("user.home",
                                                                "read");
        Set<Principal> princSet = new HashSet<>(Arrays.asList(princs));
        Subject subject = new Subject(true, princSet, Collections.emptySet(),
                                      Collections.emptySet());
        PrivilegedAction<Void> pa = () -> {
            AccessController.checkPermission(princPerm);
            return null;
        };
        Subject.doAsPrivileged(subject, pa, null);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:Modules.java

示例2: checkRemoveCallerContext

import java.security.AccessController; //导入方法依赖的package包/类
/**
 * Check if the connector server creator can assume the identity of each
 * principal in the authenticated subject, i.e. check if the connector
 * server creator codebase contains a subject delegation permission for
 * each principal present in the authenticated subject.
 *
 * @return {@code true} if the connector server creator can delegate to all
 * the authenticated principals in the subject. Otherwise, {@code false}.
 */
public static synchronized boolean
    checkRemoveCallerContext(Subject subject) {
    try {
        for (Principal p : getSubjectPrincipals(subject)) {
            final String pname =
                p.getClass().getName() + "." + p.getName();
            final Permission sdp =
                new SubjectDelegationPermission(pname);
            AccessController.checkPermission(sdp);
        }
    } catch (SecurityException e) {
        return false;
    }
    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:SubjectDelegator.java

示例3: main

import java.security.AccessController; //导入方法依赖的package包/类
public static void main(String args[]) throws Throwable {
    // ExtensiblePolicyTest1.policy: policy file grants permission to
    // watch TVChannel 3-6
    // ExtensiblePolicyTest2.policy: policy file grants permission to
    // watch TVChanel 4
    // ExtensiblePolicyTest3.policy: policy file grants permission signed
    // by duke2 to watch TVChanel 5

    TVPermission perm = new TVPermission("channel:5", "watch");
    boolean getException = false;
    String exceptionMessage = null;
    boolean expectException = Boolean.parseBoolean(args[0]);
    try {
        AccessController.checkPermission(perm);
    } catch (SecurityException se) {
        getException = true;
        exceptionMessage = se.getMessage();
    }

    if (expectException ^ getException) {
        throw new RuntimeException("Test Failed: expectException = "
                + expectException + " getException = " + getException
                + "\n" + exceptionMessage);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:ExtensiblePolicyTest.java

示例4: requireCurrent

import java.security.AccessController; //导入方法依赖的package包/类
public static ServletRequestContext requireCurrent() {
    if(System.getSecurityManager() != null) {
        AccessController.checkPermission(GET_CURRENT_REQUEST);
    }
    ServletRequestContext attachments = CURRENT.get();
    if (attachments == null) {
        throw UndertowMessages.MESSAGES.noRequestActive();
    }
    return attachments;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:ServletRequestContext.java

示例5: main

import java.security.AccessController; //导入方法依赖的package包/类
public static void main (String argv[]) throws Exception {
     try {
         AccessController.checkPermission(
                     new BasicPermission("no such permission"){});
     } catch (NullPointerException npe) {
        throw new Exception("Unexpected NullPointerException for security" +
                     " debug option, -Djava.security.debug=failure");
     } catch (AccessControlException ace) {
     }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:FailureDebugOption.java

示例6: main

import java.security.AccessController; //导入方法依赖的package包/类
public static void main(String[] args) {
    try {
        AccessController.checkPermission(new FilePermission(".", "read"));
    } catch (AccessControlException e) {
        throw new RuntimeException("Invalid policy settings!", e);
    }

    instance = new ClientBuilder().withToken(args[0]).login();

    instance.getDispatcher().registerListener(new MCBot());
    instance.getDispatcher().registerListener(CommandListener.INSTANCE);

    // Handle "stop" and any future commands
    Thread consoleThread = new Thread(() -> {
        Scanner scan = new Scanner(System.in);
        while (true) {
            while (scan.hasNextLine()) {
                if (scan.nextLine().equals("stop")) {
                    scan.close();
                    System.exit(0);
                }
            }
            Threads.sleep(100);
        }
    });

    // Make sure shutdown things are run, regardless of where shutdown came from
    // The above System.exit(0) will trigger this hook
    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        CommandRegistrar.INSTANCE.onShutdown();
    }));
    
    consoleThread.start();

    if(args.length > 1)
        new MCBotIRC(args[1]);
}
 
开发者ID:tterrag1098,项目名称:MCBot,代码行数:38,代码来源:MCBot.java

示例7: delegatedContext

import java.security.AccessController; //导入方法依赖的package包/类
public AccessControlContext
    delegatedContext(AccessControlContext authenticatedACC,
                     Subject delegatedSubject,
                     boolean removeCallerContext)
        throws SecurityException {

    if (System.getSecurityManager() != null && authenticatedACC == null) {
        throw new SecurityException("Illegal AccessControlContext: null");
    }

    // Check if the subject delegation permission allows the
    // authenticated subject to assume the identity of each
    // principal in the delegated subject
    //
    Collection<Principal> ps = getSubjectPrincipals(delegatedSubject);
    final Collection<Permission> permissions = new ArrayList<>(ps.size());
    for(Principal p : ps) {
        final String pname = p.getClass().getName() + "." + p.getName();
        permissions.add(new SubjectDelegationPermission(pname));
    }
    PrivilegedAction<Void> action =
        new PrivilegedAction<Void>() {
            public Void run() {
                for (Permission sdp : permissions) {
                    AccessController.checkPermission(sdp);
                }
                return null;
            }
        };
    AccessController.doPrivileged(action, authenticatedACC);

    return getDelegatedAcc(delegatedSubject, removeCallerContext);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:SubjectDelegator.java

示例8: main

import java.security.AccessController; //导入方法依赖的package包/类
public static void main(String args[]) {
    TVPermission perm = new TVPermission("channel:5", "watch");
    try {
        AccessController.checkPermission(perm);
    } catch (SecurityException se) {
        throw new RuntimeException(se);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:ExtensiblePolicyWithJarTest.java

示例9: run

import java.security.AccessController; //导入方法依赖的package包/类
@Override public Void run() {
    AccessController.checkPermission(permission);
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:WildcardPrincipalName.java

示例10: setCurrentRequestContext

import java.security.AccessController; //导入方法依赖的package包/类
public static void setCurrentRequestContext(ServletRequestContext servletRequestContext) {
    if(System.getSecurityManager() != null) {
        AccessController.checkPermission(SET_CURRENT_REQUEST);
    }
    CURRENT.set(servletRequestContext);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:ServletRequestContext.java

示例11: clearCurrentServletAttachments

import java.security.AccessController; //导入方法依赖的package包/类
public static void clearCurrentServletAttachments() {
    if(System.getSecurityManager() != null) {
        AccessController.checkPermission(SET_CURRENT_REQUEST);
    }
    CURRENT.remove();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:ServletRequestContext.java

示例12: current

import java.security.AccessController; //导入方法依赖的package包/类
public static ServletRequestContext current() {
    if(System.getSecurityManager() != null) {
        AccessController.checkPermission(GET_CURRENT_REQUEST);
    }
    return CURRENT.get();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:ServletRequestContext.java

示例13: setSecurityContext

import java.security.AccessController; //导入方法依赖的package包/类
public void setSecurityContext(SecurityContext securityContext) {
    if(System.getSecurityManager() != null) {
        AccessController.checkPermission(SET_SECURITY_CONTEXT);
    }
    this.securityContext = securityContext;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:HttpServerExchange.java


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