1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* 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 {
41
41
42
42
// Good ones
43
43
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" );
50
50
// 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" );
54
54
// 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 );
61
60
62
61
// Part 2: on realm choices
63
62
@@ -78,17 +77,17 @@ public static void main(String[] args) throws Exception {
78
77
79
78
if (testNoDefaultDomain ) {
80
79
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" );
86
85
type = PrincipalName .KRB_NT_SRV_HST ;
87
86
// 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
92
91
}
93
92
94
93
// When there is default realm
@@ -97,25 +96,25 @@ public static void main(String[] args) throws Exception {
97
96
Config .refresh ();
98
97
99
98
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" );
105
104
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
113
112
}
114
113
115
114
// Check if the creation matches the expected output.
116
115
// Note: realm == null means creation failure
117
116
static void checkName (String n , int t , String s ,
118
- String realm , boolean deduced , String ... parts )
117
+ String realm , String ... parts )
119
118
throws Exception {
120
119
PrincipalName pn = null ;
121
120
try {
@@ -132,8 +131,5 @@ static void checkName(String n, int t, String s,
132
131
throw new Exception (pn .toString () + " vs "
133
132
+ Arrays .toString (parts ) + "@" + realm );
134
133
}
135
- if (deduced != pn .isRealmDeduced ()) {
136
- throw new Exception ("pn.realmDeduced is " + pn .isRealmDeduced ());
137
- }
138
134
}
139
135
}
0 commit comments