本文整理汇总了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;
}
}
}
示例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;
}
}
}
示例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
}
}
}
示例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;
}
}
}
示例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")));
}
示例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){
}
}
示例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")));
}