本文整理汇总了Java中javax.security.auth.kerberos.DelegationPermission类的典型用法代码示例。如果您正苦于以下问题:Java DelegationPermission类的具体用法?Java DelegationPermission怎么用?Java DelegationPermission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DelegationPermission类属于javax.security.auth.kerberos包,在下文中一共展示了DelegationPermission类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doDelegPermCheck
import javax.security.auth.kerberos.DelegationPermission; //导入依赖的package包/类
private void doDelegPermCheck() throws GSSException {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
String targetStr = targetName.getKrbName();
String tgsStr = Krb5Util.getTGSName(targetName);
StringBuffer buf = new StringBuffer("\"");
buf.append(targetStr).append("\" \"");
buf.append(tgsStr).append('\"');
String krbPrincPair = buf.toString();
SunNativeProvider.debug("Checking DelegationPermission (" +
krbPrincPair + ")");
DelegationPermission perm =
new DelegationPermission(krbPrincPair);
sm.checkPermission(perm);
skipDelegPermCheck = true;
}
}
示例2: doDelegPermCheck
import javax.security.auth.kerberos.DelegationPermission; //导入依赖的package包/类
private void doDelegPermCheck() throws GSSException {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
String targetStr = targetName.getKrbName();
String tgsStr = Krb5Util.getTGSName(targetName);
StringBuilder sb = new StringBuilder("\"");
sb.append(targetStr).append("\" \"");
sb.append(tgsStr).append('\"');
String krbPrincPair = sb.toString();
SunNativeProvider.debug("Checking DelegationPermission (" +
krbPrincPair + ")");
DelegationPermission perm =
new DelegationPermission(krbPrincPair);
sm.checkPermission(perm);
skipDelegPermCheck = true;
}
}
示例3: main
import javax.security.auth.kerberos.DelegationPermission; //导入依赖的package包/类
public static void main(String[] args) {
DelegationPermission one = new DelegationPermission(
QUOTE + princ1 + QUOTE + ONE_SPACE + QUOTE + princ2 + QUOTE);
DelegationPermission two = new DelegationPermission(
QUOTE + princ1 + QUOTE + TWO_SPACES + QUOTE + princ2 + QUOTE);
System.out.println("one.getName() = " + one.getName());
System.out.println("two.getName() = " + two.getName());
if (!one.implies(two) || !two.implies(one)) {
throw new RuntimeException("Test failed: "
+ "one and two don't imply each other");
}
if (!one.equals(two)) {
throw new RuntimeException("Test failed: one is not equal to two");
}
System.out.println("one.hashCode() = " + one.hashCode());
System.out.println("two.hashCode() = " + two.hashCode());
if (one.hashCode() != two.hashCode()) {
throw new RuntimeException("Test failed: hash codes are not equal");
}
System.out.println("Test passed");
}
示例4: testImpliesCollection
import javax.security.auth.kerberos.DelegationPermission; //导入依赖的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")));
}
示例5: getData
import javax.security.auth.kerberos.DelegationPermission; //导入依赖的package包/类
@Override
protected Object[] getData() {
Permission p1 = new DelegationPermission("\"AAA\" \"BBB\"", "action");
Permission p2 = new DelegationPermission("\"AAA\" \"CCC\"");
Permission p3 = new DelegationPermission("\"BBB\" \"CCC\"");
PermissionCollection pc1 = p1.newPermissionCollection();
PermissionCollection pc2 = p1.newPermissionCollection();
pc2.add(p3);
PermissionCollection pc3 = p1.newPermissionCollection();
pc3.add(p1);
pc3.add(p2);
pc3.add(p3);
return new Object[] { pc1, pc2, pc3 };
}
示例6: testFailCtor_2
import javax.security.auth.kerberos.DelegationPermission; //导入依赖的package包/类
public void testFailCtor_2() {
try {
new DelegationPermission("\"AAA\"");
fail("target name should be specifies a pair of kerberos service principals");
} catch (IllegalArgumentException e) {
}
}
示例7: testEquals
import javax.security.auth.kerberos.DelegationPermission; //导入依赖的package包/类
@SuppressWarnings("serial")
public void testEquals() {
DelegationPermission dp1 = new DelegationPermission("\"AAA\" \"BBB\"");
DelegationPermission dp2 = new DelegationPermission("\"AAA\" \"BBB\"");
assertTrue(dp1.equals(dp1));
assertFalse(dp1.equals(new DelegationPermission("\"aaa\" \"bbb\"")));
assertTrue(dp2.equals(dp1));
assertTrue(dp1.equals(dp2));
assertTrue(dp1.hashCode() == dp2.hashCode());
assertFalse(dp1.equals(new BasicPermission("\"AAA\""){}));
}
示例8: testImplies
import javax.security.auth.kerberos.DelegationPermission; //导入依赖的package包/类
public void testImplies() {
DelegationPermission dp1 = new DelegationPermission("\"AAA\" \"BBB\"");
DelegationPermission dp2 = new DelegationPermission("\"BBB\" \"AAA\"");
assertFalse(dp1.implies(dp2));
assertFalse(dp2.implies(dp1));
assertTrue(dp1.implies(dp1));
assertFalse(dp1.implies(new ServicePermission("aaa", "accept")));
assertFalse(dp1.implies(null));
}
示例9: testElements
import javax.security.auth.kerberos.DelegationPermission; //导入依赖的package包/类
public void testElements() throws Exception {
Permission p = new DelegationPermission("\"AAA\" \"BBB\"");
PermissionCollection pc = p.newPermissionCollection();
try {
pc.elements().nextElement();
fail("expected NoSuchElementException");
} catch (NoSuchElementException e) {
}
Enumeration<Permission> en = pc.elements();
assertNotNull(en);
assertFalse(en.hasMoreElements());
Permission sp1 = new DelegationPermission("\"DDD\" \"BBB\"");
Permission sp2 = new DelegationPermission("\"CCC\" \"BBB\"");
pc.add(sp1);
en = pc.elements();
assertTrue(en.hasMoreElements());
assertTrue(sp1.equals(en.nextElement()));
assertFalse(en.hasMoreElements());
pc.add(sp2);
en = pc.elements();
Collection<Permission> c = new ArrayList<Permission>();
while (en.hasMoreElements()) {
c.add(en.nextElement());
}
assertFalse(en.hasMoreElements());
assertEquals(2, c.size());
assertTrue(c.contains(sp1) && c.contains(sp2));
}
示例10: testEquals
import javax.security.auth.kerberos.DelegationPermission; //导入依赖的package包/类
public void testEquals() {
ServicePermission sp = new ServicePermission("host/[email protected]", "accept");
ServicePermission sp1 = new ServicePermission("host/[email protected]", "initiate");
ServicePermission sp2 = new ServicePermission("host/[email protected]", "initiate, accept");
assertTrue(sp.equals(sp));
assertTrue(sp.hashCode() == sp.hashCode());
assertFalse(sp.equals(sp1));
assertFalse(sp.hashCode() == sp1.hashCode());
assertFalse(sp.equals(sp2));
assertFalse(sp1.equals(sp2));
assertTrue(sp2.equals(sp2));
assertFalse(sp.equals(new DelegationPermission("\"AAA\" \"BBB\"", "action")));
assertFalse(sp.equals(null));
}
示例11: getOnosPermission
import javax.security.auth.kerberos.DelegationPermission; //导入依赖的package包/类
public static org.onosproject.security.Permission getOnosPermission(Permission permission) {
if (permission instanceof AppPermission) {
return new org.onosproject.security.Permission(AppPermission.class.getName(), permission.getName(), "");
} else if (permission instanceof FilePermission) {
return new org.onosproject.security.Permission(
FilePermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof SerializablePermission) {
return new org.onosproject.security.Permission(
SerializablePermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof NetPermission) {
return new org.onosproject.security.Permission(
NetPermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof RuntimePermission) {
return new org.onosproject.security.Permission(
RuntimePermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof SocketPermission) {
return new org.onosproject.security.Permission(
SocketPermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof SQLPermission) {
return new org.onosproject.security.Permission(
SQLPermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof PropertyPermission) {
return new org.onosproject.security.Permission(
PropertyPermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof LoggingPermission) {
return new org.onosproject.security.Permission(
LoggingPermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof SSLPermission) {
return new org.onosproject.security.Permission(
SSLPermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof AuthPermission) {
return new org.onosproject.security.Permission(
AuthPermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof PrivateCredentialPermission) {
return new org.onosproject.security.Permission(
PrivateCredentialPermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof DelegationPermission) {
return new org.onosproject.security.Permission(
DelegationPermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof javax.security.auth.kerberos.ServicePermission) {
return new org.onosproject.security.Permission(
javax.security.auth.kerberos.ServicePermission.class.getName(), permission.getName(),
permission.getActions());
} else if (permission instanceof AudioPermission) {
return new org.onosproject.security.Permission(
AudioPermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof AdaptPermission) {
return new org.onosproject.security.Permission(
AdaptPermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof BundlePermission) {
return new org.onosproject.security.Permission(
BundlePermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof CapabilityPermission) {
return new org.onosproject.security.Permission(
CapabilityPermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof PackagePermission) {
return new org.onosproject.security.Permission(
PackagePermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof ServicePermission) {
return new org.onosproject.security.Permission(
ServicePermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof AdminPermission) {
return new org.onosproject.security.Permission(
AdminPermission.class.getName(), permission.getName(), permission.getActions());
} else if (permission instanceof ConfigurationPermission) {
return new org.onosproject.security.Permission(
ConfigurationPermission.class.getName(), permission.getName(), permission.getActions());
}
return null;
}
示例12: getPermission
import javax.security.auth.kerberos.DelegationPermission; //导入依赖的package包/类
private static Permission getPermission(org.onosproject.security.Permission permission) {
String classname = permission.getClassName();
String name = permission.getName();
String actions = permission.getActions();
if (classname == null || name == null) {
return null;
}
classname = classname.trim();
name = name.trim();
actions = actions.trim();
if (AppPermission.class.getName().equals(classname)) {
return new AppPermission(name);
} else if (FilePermission.class.getName().equals(classname)) {
return new FilePermission(name, actions);
} else if (SerializablePermission.class.getName().equals(classname)) {
return new SerializablePermission(name, actions);
} else if (NetPermission.class.getName().equals(classname)) {
return new NetPermission(name, actions);
} else if (RuntimePermission.class.getName().equals(classname)) {
return new RuntimePermission(name, actions);
} else if (SocketPermission.class.getName().equals(classname)) {
return new SocketPermission(name, actions);
} else if (SQLPermission.class.getName().equals(classname)) {
return new SQLPermission(name, actions);
} else if (PropertyPermission.class.getName().equals(classname)) {
return new PropertyPermission(name, actions);
} else if (LoggingPermission.class.getName().equals(classname)) {
return new LoggingPermission(name, actions);
} else if (SSLPermission.class.getName().equals(classname)) {
return new SSLPermission(name, actions);
} else if (AuthPermission.class.getName().equals(classname)) {
return new AuthPermission(name, actions);
} else if (PrivateCredentialPermission.class.getName().equals(classname)) {
return new PrivateCredentialPermission(name, actions);
} else if (DelegationPermission.class.getName().equals(classname)) {
return new DelegationPermission(name, actions);
} else if (javax.security.auth.kerberos.ServicePermission.class.getName().equals(classname)) {
return new javax.security.auth.kerberos.ServicePermission(name, actions);
} else if (AudioPermission.class.getName().equals(classname)) {
return new AudioPermission(name, actions);
} else if (AdaptPermission.class.getName().equals(classname)) {
return new AdaptPermission(name, actions);
} else if (BundlePermission.class.getName().equals(classname)) {
return new BundlePermission(name, actions);
} else if (CapabilityPermission.class.getName().equals(classname)) {
return new CapabilityPermission(name, actions);
} else if (PackagePermission.class.getName().equals(classname)) {
return new PackagePermission(name, actions);
} else if (ServicePermission.class.getName().equals(classname)) {
return new ServicePermission(name, actions);
} else if (AdminPermission.class.getName().equals(classname)) {
return new AdminPermission(name, actions);
} else if (ConfigurationPermission.class.getName().equals(classname)) {
return new ConfigurationPermission(name, actions);
} else if (ReflectPermission.class.getName().equals(classname)) {
return new ReflectPermission(name, actions);
}
//AllPermission, SecurityPermission, UnresolvedPermission
//AWTPermission, ReflectPermission not allowed
return null;
}
示例13: main
import javax.security.auth.kerberos.DelegationPermission; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
int testFail = 0;
DelegationPermission perm = new DelegationPermission(FOO + " " + TGT);
PermissionCollection perms = perm.newPermissionCollection();
// test 1
System.out.println
("test 1: add throws IllegalArgException for wrong perm type");
try {
perms.add(new SecurityPermission("createAccessControlContext"));
System.err.println("Expected IllegalArgumentException");
testFail++;
} catch (IllegalArgumentException iae) {}
// test 2
System.out.println("test 2: implies returns false for wrong perm type");
if (perms.implies(new SecurityPermission("getPolicy"))) {
System.err.println("Expected false, returned true");
testFail++;
}
// test 3
System.out.println("test 3: implies returns true for match on name");
perms.add(new DelegationPermission(FOO + " " + TGT));
if (!perms.implies(new DelegationPermission(FOO + " " + TGT))) {
System.err.println("Expected true, returned false");
testFail++;
}
// test 4
System.out.println
("test 4: implies returns false for non-match on name");
if (perms.implies(new DelegationPermission(BAR + " " + TGT))) {
System.err.println("Expected false, returned true");
testFail++;
}
// test 5
System.out.println("test 5: elements returns correct number of perms");
int numPerms = 0;
Enumeration<Permission> e = perms.elements();
while (e.hasMoreElements()) {
numPerms++;
System.out.println(e.nextElement());
}
if (numPerms != 1) {
System.err.println("Expected 1, got " + numPerms);
testFail++;
}
if (testFail > 0) {
throw new Exception(testFail + " test(s) failed");
}
}