2727 * @summary More krb5 tests
2828 * @library ../../../../java/security/testlibrary/ /test/lib
2929 * @compile -XDignore.symbol.file ReplayCacheTestProc.java
30- * @run main/othervm/timeout=300 -Dsun.net.spi.nameservice.provider.1=ns,mock ReplayCacheTestProc
30+ * @run main/othervm/timeout=300 -Dsun.net.spi.nameservice.provider.1=ns,mock
31+ * -Dtest.libs=J ReplayCacheTestProc
32+ * @run main/othervm/timeout=300 -Dsun.net.spi.nameservice.provider.1=ns,mock
33+ * -Dtest.libs=N ReplayCacheTestProc
3134 */
3235
3336import java .io .*;
4346import java .util .regex .Matcher ;
4447import java .util .regex .Pattern ;
4548
49+ import jdk .test .lib .Asserts ;
4650import jdk .test .lib .Platform ;
4751import sun .security .jgss .GSSUtil ;
4852import sun .security .krb5 .internal .rcache .AuthTime ;
5155 * This test runs multiple acceptor Procs to mimic AP-REQ replays.
5256 * These system properties are supported:
5357 *
54- * - test.libs on what types of acceptors to use
58+ * - test.libs on what types of acceptors to use. Cannot be null.
5559 * Format: CSV of (J|N|N<suffix>=<libname>|J<suffix>=<launcher>)
56- * Default: J,N on Solaris and Linux where N is available, or J
5760 * Example: J,N,N14=/krb5-1.14/lib/libgssapi_krb5.so,J8=/java8/bin/java
5861 *
5962 * - test.runs on manual runs. If empty, a iterate through all pattern
@@ -117,6 +120,16 @@ public static void main0(String[] args) throws Exception {
117120 uid = -1 ;
118121 }
119122
123+ // User-provided libs
124+ String userLibs = System .getProperty ("test.libs" );
125+ Asserts .assertNotNull (userLibs , "test.libs property must be provided" );
126+ libs = userLibs .split ("," );
127+ if (Arrays .asList (libs ).contains ("N" ) && !isNativeLibAvailable ()) {
128+ // Skip test when native GSS libs are not available in running platform
129+ System .out .println ("Native mode not available - skipped" );
130+ return ;
131+ }
132+
120133 KDC kdc = KDC .create (OneKDC .REALM , HOST , 0 , true );
121134 for (int i =0 ; i <nc ; i ++) {
122135 kdc .addPrincipal (client (i ), OneKDC .PASS );
@@ -129,25 +142,6 @@ public static void main0(String[] args) throws Exception {
129142 kdc .writeKtab (OneKDC .KTAB );
130143 KDC .saveConfig (OneKDC .KRB5_CONF , kdc );
131144
132- // User-provided libs
133- String userLibs = System .getProperty ("test.libs" );
134-
135- if (userLibs != null ) {
136- libs = userLibs .split ("," );
137- } else {
138- if (Platform .isOSX () || Platform .isWindows ()) {
139- // macOS uses Heimdal and Windows has no native lib
140- libs = new String []{"J" };
141- } else {
142- if (acceptor ("N" , "sanity" ).waitFor () != 0 ) {
143- Proc .d ("Native mode sanity check failed, only java" );
144- libs = new String []{"J" };
145- } else {
146- libs = new String []{"J" , "N" };
147- }
148- }
149- }
150-
151145 pi = Proc .create ("ReplayCacheTestProc" ).debug ("C" )
152146 .args ("initiator" )
153147 .start ();
@@ -323,6 +317,13 @@ public static void main(String[] args) throws Exception {
323317 }
324318 }
325319
320+ // returns true if native lib is available in running platform
321+ // macOS uses Heimdal and Windows has no native lib
322+ private static boolean isNativeLibAvailable () throws Exception {
323+ return !Platform .isOSX () && !Platform .isWindows ()
324+ && acceptor ("N" , "sanity" ).waitFor () == 0 ;
325+ }
326+
326327 // returns the client name
327328 private static String client (int p ) {
328329 return "client" + p ;
0 commit comments