Path: blob/master/test/jdk/javax/security/auth/kerberos/DelegationPermissionHash.java
41152 views
/*1* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import javax.security.auth.kerberos.DelegationPermission;2425/*26* @test27* @bug 812957528* @summary Checks if DelegationPermission.hashCode() works fine29*/30public class DelegationPermissionHash {3132static final String princ1 = "backup/[email protected]";33static final String princ2 = "backup/[email protected]";34static final String ONE_SPACE = " ";35static final String TWO_SPACES = " ";36static final String QUOTE = "\"";3738public static void main(String[] args) {39DelegationPermission one = new DelegationPermission(40QUOTE + princ1 + QUOTE + ONE_SPACE + QUOTE + princ2 + QUOTE);41DelegationPermission two = new DelegationPermission(42QUOTE + princ1 + QUOTE + TWO_SPACES + QUOTE + princ2 + QUOTE);4344System.out.println("one.getName() = " + one.getName());45System.out.println("two.getName() = " + two.getName());4647if (!one.implies(two) || !two.implies(one)) {48throw new RuntimeException("Test failed: "49+ "one and two don't imply each other");50}5152if (!one.equals(two)) {53throw new RuntimeException("Test failed: one is not equal to two");54}5556System.out.println("one.hashCode() = " + one.hashCode());57System.out.println("two.hashCode() = " + two.hashCode());58if (one.hashCode() != two.hashCode()) {59throw new RuntimeException("Test failed: hash codes are not equal");60}6162System.out.println("Test passed");63}64}656667