本文整理汇总了Java中javax.security.auth.x500.X500Principal.hashCode方法的典型用法代码示例。如果您正苦于以下问题:Java X500Principal.hashCode方法的具体用法?Java X500Principal.hashCode怎么用?Java X500Principal.hashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.security.auth.x500.X500Principal
的用法示例。
在下文中一共展示了X500Principal.hashCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.security.auth.x500.X500Principal; //导入方法依赖的package包/类
public static void main(String[] args) {
// test regular equals
X500Principal p1 = new X500Principal(p1String);
X500Principal p2 = new X500Principal(p2String);
printName("Principal 1:", p1String, p1);
printName("Principal 2:", p2String, p2);
if (!p1.equals(p2))
throw new SecurityException("Equals test failed: #1");
X500Principal notEqual = new X500Principal("cn=test2");
if (p1.equals(notEqual))
throw new SecurityException("Equals test failed: #2");
if (p1.equals(null))
throw new SecurityException("Equals test failed: #3");
if (p1.hashCode() != p2.hashCode())
throw new SecurityException("Equals test failed: #4");
// test multiple AVA's in an RDN
X500Principal p3 = new X500Principal(p3String);
X500Principal p4 = new X500Principal(p4String);
printName("Principal 3:", p3String, p3);
printName("Principal 4:", p4String, p4);
if (!p3.equals(p4))
throw new SecurityException("Equals test failed: #5");
if (p1.equals(p3) || p2.equals(p3))
throw new SecurityException("Equals test failed: #6");
if (p3.hashCode() != p4.hashCode())
throw new SecurityException("Equals test failed: #7");
X500Principal p5 = new X500Principal(p5String);
X500Principal p6 = new X500Principal(p6String);
printName("Principal 5:", p5String, p5);
printName("Principal 6:", p6String, p6);
if (!p5.equals(p6))
throw new SecurityException("Equals test failed: #8");
if (p5.hashCode() != p6.hashCode())
throw new SecurityException("Equals test failed: #9");
X500Principal p7 = new X500Principal(p7String);
X500Principal p8 = new X500Principal(p8String);
printName("Principal 7:", p7String, p7);
printName("Principal 8:", p8String, p8);
if (!p7.equals(p8))
throw new SecurityException("Equals test failed: #10");
if (p7.hashCode() != p8.hashCode())
throw new SecurityException("Equals test failed: #11");
System.out.println("Equals test passed");
}