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


Java ServicePermission类代码示例

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


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

示例1: checkInitCredPermission

import javax.security.auth.kerberos.ServicePermission; //导入依赖的package包/类
public static void checkInitCredPermission(Krb5NameElement name) {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        String realm = (name.getKrb5PrincipalName()).getRealmAsString();
        String tgsPrincipal =
            new String("krbtgt/" + realm + '@' + realm);
        ServicePermission perm =
            new ServicePermission(tgsPrincipal, "initiate");
        try {
            sm.checkPermission(perm);
        } catch (SecurityException e) {
            if (DEBUG) {
                System.out.println("Permission to initiate" +
                    "kerberos init credential" + e.getMessage());
            }
            throw e;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:Krb5MechFactory.java

示例2: checkAcceptCredPermission

import javax.security.auth.kerberos.ServicePermission; //导入依赖的package包/类
public static void checkAcceptCredPermission(Krb5NameElement name,
                                       GSSNameSpi originalName) {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null && name != null) {
        ServicePermission perm = new ServicePermission
            (name.getKrb5PrincipalName().getName(), "accept");
        try {
            sm.checkPermission(perm);
        } catch (SecurityException e) {
            if (originalName == null) {
                // Don't disclose the name of the principal
                e = new SecurityException("No permission to acquire "
                                  + "Kerberos accept credential");
                // Don't call e.initCause() with caught exception
            }
            throw e;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:Krb5MechFactory.java

示例3: checkPermission

import javax.security.auth.kerberos.ServicePermission; //导入依赖的package包/类
@Override
public void checkPermission(Permission perm) {
    if (!(perm instanceof ServicePermission)) {
        return;
    }
    ServicePermission sp = (ServicePermission)perm;
    if (!sp.getActions().equals("accept")) {
        return;
    }
    // We only care about accept ServicePermission in this test
    try {
        super.checkPermission(sp);
    } catch (SecurityException se) {
        if (perms.containsKey(sp)) {
            perms.put(sp, "checked");
        } else {
            throw se;   // We didn't expect this is needed
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:AcceptPermissions.java

示例4: checkAcceptCredPermission

import javax.security.auth.kerberos.ServicePermission; //导入依赖的package包/类
public static void checkAcceptCredPermission(Krb5NameElement name,
                                       GSSNameSpi originalName) {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        ServicePermission perm = new ServicePermission
            (name.getKrb5PrincipalName().getName(), "accept");
        try {
            sm.checkPermission(perm);
        } catch (SecurityException e) {
            if (originalName == null) {
                // Don't disclose the name of the principal
                e = new SecurityException("No permission to acquire "
                                  + "Kerberos accept credential");
                // Don't call e.initCause() with caught exception
            }
            throw e;
        }
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:20,代码来源:Krb5MechFactory.java

示例5: testImpliesCollection

import javax.security.auth.kerberos.ServicePermission; //导入依赖的package包/类
public void testImpliesCollection(){
    
    Permission ap = new AllPermission();
    Permission p = new DelegationPermission("\"AAA\" \"BBB\"");
    PermissionCollection pc = p.newPermissionCollection();
    assertFalse(pc.implies(ap));
    assertFalse(pc.implies(p));
    pc.add(p);
    assertTrue(pc.implies(p));
    assertFalse(pc.implies(null));
    DelegationPermission dp1 = new DelegationPermission("\"AAA\" \"BBB\"");
    assertTrue(dp1.implies(dp1));
    DelegationPermission dp2 = new DelegationPermission("\"BBB\" \"AAA\"");
    assertFalse(dp1.implies(dp2));
    assertFalse(dp1.implies(null));
    assertFalse(dp1.implies(new ServicePermission("aaa", "accept")));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:DelegationPermissionTest.java

示例6: testCtor

import javax.security.auth.kerberos.ServicePermission; //导入依赖的package包/类
/**
 * @tests javax.security.auth.kerberos.ServicePermission#ServicePermission(
 *        java.lang.String,java.lang.String)
 */
public void testCtor() {
    ServicePermission sp = new ServicePermission("krbtgt/[email protected]", "initiate");
    ServicePermission sp1 = new ServicePermission("host/[email protected]", "accept");
    assertEquals("krbtgt/[email protected]",sp.getName());
    assertEquals("initiate",sp.getActions());
    assertEquals("host/[email protected]",sp1.getName());
    assertEquals("accept",sp1.getActions());
    ServicePermission sp2 = new ServicePermission("host/[email protected]", "accept, initiate");
    assertEquals("initiate,accept", sp2.getActions());

    try {
        // Regression for HARMONY-769
        // checks exception order: action parameter is verified first
        new ServicePermission(null, "initiate accept");
        fail("No expected IllegalArgumentException"); 
    } catch(IllegalArgumentException e){
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:ServicePermissionTest.java

示例7: testImpliesCollection

import javax.security.auth.kerberos.ServicePermission; //导入依赖的package包/类
public void testImpliesCollection(){
    
    Permission ap = new AllPermission();
    Permission p = new ServicePermission("AAA", "accept");
    PermissionCollection pc = p.newPermissionCollection();
    assertFalse(pc.implies(ap));
    assertFalse(pc.implies(p));
    pc.add(p);
    assertTrue(pc.implies(p));
    assertFalse(pc.implies(null));
    assertFalse(pc.implies(new ServicePermission("BBB", "initiate")));
    assertFalse(pc.implies(new ServicePermission("CCC", "accept")));
    pc.add(new ServicePermission("*", "accept, initiate"));
    assertTrue(pc.implies(new ServicePermission("*", "accept")));
    assertTrue(pc.implies(new ServicePermission("*", "initiate")));
    assertTrue(pc.implies(new ServicePermission("BBB", "initiate")));
    assertTrue(pc.implies(new ServicePermission("CCC", "accept")));

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


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