11/*
2- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -41,23 +41,22 @@ public static void main(String[] args) throws Exception {
4141
4242 // Good ones
4343 type = PrincipalName .KRB_NT_UNKNOWN ;
44- checkName ("a" , type , "R" , "R" , false , "a" );
45- checkName ("a@R2" , type , "R" , "R" , false , "a" );
46- checkName ("a/b" , type , "R" , "R" , false , "a" , "b" );
47- checkName ("a/b@R2" , type , "R" , "R" , false , "a" , "b" );
48- checkName ("a/b/c" , type , "R" , "R" , false , "a" , "b" , "c" );
49- checkName ("a/b/c@R2" , type , "R" , "R" , false , "a" , "b" , "c" );
44+ checkName ("a" , type , "R" , "R" , "a" );
45+ checkName ("a@R2" , type , "R" , "R" , "a" );
46+ checkName ("a/b" , type , "R" , "R" , "a" , "b" );
47+ checkName ("a/b@R2" , type , "R" , "R" , "a" , "b" );
48+ checkName ("a/b/c" , type , "R" , "R" , "a" , "b" , "c" );
49+ checkName ("a/b/c@R2" , type , "R" , "R" , "a" , "b" , "c" );
5050 // Weird ones
51- checkName ("a\\ /b" , type , "R" , "R" , false , "a/b" );
52- checkName ("a\\ /b\\ /c" , type , "R" , "R" , false , "a/b/c" );
53- checkName ("a\\ /b\\ @R2" , type , "R" , "R" , false , "a/b@R2" );
51+ checkName ("a\\ /b" , type , "R" , "R" , "a/b" );
52+ checkName ("a\\ /b\\ /c" , type , "R" , "R" , "a/b/c" );
53+ checkName ("a\\ /b\\ @R2" , type , "R" , "R" , "a/b@R2" );
5454 // Bad ones
55- checkName ("a" , type , "" , null , false );
56- checkName ("a/" , type , "R" , null , false );
57- checkName ("/a" , type , "R" , null , false );
58- checkName ("a//b" , type , "R" , null , false );
59- checkName ("a@" , type , null , null , false );
60- type = PrincipalName .KRB_NT_SRV_HST ;
55+ checkName ("a" , type , "" , null );
56+ checkName ("a/" , type , "R" , null );
57+ checkName ("/a" , type , "R" , null );
58+ checkName ("a//b" , type , "R" , null );
59+ checkName ("a@" , type , null , null );
6160
6261 // Part 2: on realm choices
6362
@@ -78,17 +77,17 @@ public static void main(String[] args) throws Exception {
7877
7978 if (testNoDefaultDomain ) {
8079 type = PrincipalName .KRB_NT_UNKNOWN ;
81- checkName ("a" , type , "R1" , "R1" , false , "a" ); // arg
82- checkName ("a@R1" , type , null , "R1" , false , "a" ); // or r in name
83- checkName ("a@R2" , type , "R1" , "R1" , false , "a" ); // arg over r
84- checkName ("a" , type , null , null , false ); // fail if none
85- checkName ("a/b@R1" , type , null , "R1" , false , "a" , "b" );
80+ checkName ("a" , type , "R1" , "R1" , "a" ); // arg
81+ checkName ("a@R1" , type , null , "R1" , "a" ); // or r in name
82+ checkName ("a@R2" , type , "R1" , "R1" , "a" ); // arg over r
83+ checkName ("a" , type , null , null ); // fail if none
84+ checkName ("a/b@R1" , type , null , "R1" , "a" , "b" );
8685 type = PrincipalName .KRB_NT_SRV_HST ;
8786 // Let's pray "b.h" won't be canonicalized
88- checkName ("a/b.h" , type , "R1" , "R1" , false , "a" , "b.h" ); // arg
89- checkName ("a/b.h@R1" , type , null , "R1" , false , "a" , "b.h" ); // or r in name
90- checkName ("a/b.h@R1" , type , "R2" , "R2" , false , "a" , "b.h" ); // arg over r
91- checkName ("a/b.h" , type , null , null , false ); // fail if none
87+ checkName ("a/b.h" , type , "R1" , "R1" , "a" , "b.h" ); // arg
88+ checkName ("a/b.h@R1" , type , null , "R1" , "a" , "b.h" ); // or r in name
89+ checkName ("a/b.h@R1" , type , "R2" , "R2" , "a" , "b.h" ); // arg over r
90+ checkName ("a/b.h" , type , null , null ); // fail if none
9291 }
9392
9493 // When there is default realm
@@ -97,25 +96,25 @@ public static void main(String[] args) throws Exception {
9796 Config .refresh ();
9897
9998 type = PrincipalName .KRB_NT_UNKNOWN ;
100- checkName ("a" , type , "R1" , "R1" , false , "a" ); // arg
101- checkName ("a@R1" , type , null , "R1" , false , "a" ); // or r in name
102- checkName ("a@R2" , type , "R1" , "R1" , false , "a" ); // arg over r
103- checkName ("a" , type , null , "R" , true , "a" ); // default
104- checkName ("a/b" , type , null , "R" , true , "a" , "b" );
99+ checkName ("a" , type , "R1" , "R1" , "a" ); // arg
100+ checkName ("a@R1" , type , null , "R1" , "a" ); // or r in name
101+ checkName ("a@R2" , type , "R1" , "R1" , "a" ); // arg over r
102+ checkName ("a" , type , null , "R" , "a" ); // default
103+ checkName ("a/b" , type , null , "R" , "a" , "b" );
105104 type = PrincipalName .KRB_NT_SRV_HST ;
106- checkName ("a/b.h3" , type , "R1" , "R1" , false , "a" , "b.h3" ); // arg
107- checkName ("a/b.h@R1" , type , null , "R1" , false , "a" , "b.h" ); // or r in name
108- checkName ("a/b.h3@R2" , type , "R1" , "R1" , false , "a" , "b.h3" ); // arg over r
109- checkName ("a/b.h2" , type , "R1" , "R1" , false , "a" , "b.h2" ); // arg over map
110- checkName ("a/b.h2@R1" , type , null , "R1" , false , "a" , "b.h2" ); // r over map
111- checkName ("a/b.h2" , type , null , "R2" , true , "a" , "b.h2" ); // map
112- checkName ("a/b.h" , type , null , "R" , true , "a" , "b.h" ); // default
105+ checkName ("a/b.h3" , type , "R1" , "R1" , "a" , "b.h3" ); // arg
106+ checkName ("a/b.h@R1" , type , null , "R1" , "a" , "b.h" ); // or r in name
107+ checkName ("a/b.h3@R2" , type , "R1" , "R1" , "a" , "b.h3" ); // arg over r
108+ checkName ("a/b.h2" , type , "R1" , "R1" , "a" , "b.h2" ); // arg over map
109+ checkName ("a/b.h2@R1" , type , null , "R1" , "a" , "b.h2" ); // r over map
110+ checkName ("a/b.h2" , type , null , "R2" , "a" , "b.h2" ); // map
111+ checkName ("a/b.h" , type , null , "R" , "a" , "b.h" ); // default
113112 }
114113
115114 // Check if the creation matches the expected output.
116115 // Note: realm == null means creation failure
117116 static void checkName (String n , int t , String s ,
118- String realm , boolean deduced , String ... parts )
117+ String realm , String ... parts )
119118 throws Exception {
120119 PrincipalName pn = null ;
121120 try {
@@ -132,8 +131,5 @@ static void checkName(String n, int t, String s,
132131 throw new Exception (pn .toString () + " vs "
133132 + Arrays .toString (parts ) + "@" + realm );
134133 }
135- if (deduced != pn .isRealmDeduced ()) {
136- throw new Exception ("pn.realmDeduced is " + pn .isRealmDeduced ());
137- }
138134 }
139135}
0 commit comments