1386N/A/*
3579N/A * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
1386N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1386N/A *
1386N/A * This code is free software; you can redistribute it and/or modify it
1386N/A * under the terms of the GNU General Public License version 2 only, as
1386N/A * published by the Free Software Foundation.
1386N/A *
1386N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1386N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1386N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1386N/A * version 2 for more details (a copy is included in the LICENSE file that
1386N/A * accompanied this code).
1386N/A *
1386N/A * You should have received a copy of the GNU General Public License version
1386N/A * 2 along with this work; if not, write to the Free Software Foundation,
1386N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1386N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1386N/A */
1386N/A
1386N/A/*
1386N/A * @test
1386N/A * @bug 6857802
3579N/A * @run main/othervm LifeTimeInSeconds
1386N/A * @summary GSS getRemainingInitLifetime method returns milliseconds not seconds
1386N/A */
1386N/Aimport org.ietf.jgss.GSSCredential;
1386N/Aimport org.ietf.jgss.GSSManager;
1386N/A
1386N/Apublic class LifeTimeInSeconds {
1386N/A public static void main(String[] args) throws Exception {
1386N/A new OneKDC(null).writeJAASConf();
1386N/A System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
1386N/A
1386N/A GSSManager gm = GSSManager.getInstance();
1386N/A GSSCredential cred = gm.createCredential(GSSCredential.INITIATE_AND_ACCEPT);
1386N/A int time = cred.getRemainingLifetime();
1386N/A int time2 = cred.getRemainingInitLifetime(null);
1386N/A // The test KDC issues a TGT with a default lifetime of 11 hours
1386N/A int elevenhrs = 11*3600;
1386N/A if (time > elevenhrs+60 || time < elevenhrs-60) {
1386N/A throw new Exception("getRemainingLifetime returns wrong value.");
1386N/A }
1386N/A if (time2 > elevenhrs+60 || time2 < elevenhrs-60) {
1386N/A throw new Exception("getRemainingInitLifetime returns wrong value.");
1386N/A }
1386N/A }
1386N/A}