1 /* 2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 6843127 27 * @modules java.base/sun.net.spi.nameservice 28 * java.base/sun.security.util 29 * java.security.jgss/sun.security.krb5 30 * java.security.jgss/sun.security.krb5.internal 31 * java.security.jgss/sun.security.krb5.internal.ccache 32 * java.security.jgss/sun.security.krb5.internal.crypto 33 * java.security.jgss/sun.security.krb5.internal.ktab 34 * @run main/othervm/timeout=300 BadKdc1 35 * @summary krb5 should not try to access unavailable kdc too often 36 */ 37 38 import java.security.Security; 39 40 public class BadKdc1 { 41 42 public static void main(String[] args) 43 throws Exception { 44 45 // 5 sec is default timeout for tryLess 46 if (BadKdc.getRatio() > 2.5) { 47 Security.setProperty("krb5.kdc.bad.policy", 48 "tryLess:1," + BadKdc.toReal(2000)); 49 } else { 50 Security.setProperty("krb5.kdc.bad.policy", "tryLess"); 51 } 52 53 BadKdc.go( 54 "121212222222(32){1,2}1222(32){1,2}", // 1 2 55 // The above line means try kdc1 for 2 seconds then kdc1 56 // for 2 seconds... finally kdc3 for 2 seconds. 57 "1222(32){1,2}1222(32){1,2}", // 1 2 58 // refresh 59 "121212222222(32){1,2}1222(32){1,2}", // 1 2 60 // k3 off k2 on 61 "(122212(22){1,2}|1222323232-)", // 1 62 // k1 on 63 "(12(12){1,2}|122232-)" // empty 64 ); 65 } 66 } 67