1 /* 2 * Copyright (c) 2017, 2018, 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 8186576 8194486 27 * @summary KerberosTicket does not properly handle renewable tickets 28 * at the end of their lifetime 29 * @library /test/lib 30 * @compile -XDignore.symbol.file NullRenewUntil.java 31 * @run main jdk.test.lib.FileInstaller TestHosts TestHosts 32 * @run main/othervm -Djdk.net.hosts.file=TestHosts 33 * -Dtest.set.null.renew NullRenewUntil 34 */ 35 36 import jdk.test.lib.Asserts; 37 import sun.security.krb5.Config; 38 39 import javax.security.auth.kerberos.KerberosTicket; 40 41 public class NullRenewUntil { 42 main(String[] args)43 public static void main(String[] args) throws Exception { 44 45 OneKDC kdc = new OneKDC(null); 46 47 KDC.saveConfig(OneKDC.KRB5_CONF, kdc, 48 "ticket_lifetime = 10s", 49 "renew_lifetime = 11s"); 50 Config.refresh(); 51 52 KerberosTicket ticket = Context 53 .fromUserPass(OneKDC.USER, OneKDC.PASS, false).s() 54 .getPrivateCredentials(KerberosTicket.class).iterator().next(); 55 56 System.out.println(ticket); 57 Asserts.assertTrue(ticket.getRenewTill() != null, ticket.toString()); 58 59 Thread.sleep(2000); 60 61 ticket.refresh(); 62 System.out.println(ticket); 63 Asserts.assertTrue(ticket.getRenewTill() == null, ticket.toString()); 64 65 Thread.sleep(2000); 66 ticket.refresh(); 67 System.out.println(ticket); 68 } 69 } 70