/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6894072
* @summary always refresh keytab
*/
public class DynamicKeytab {
Context c, s;
throws Exception {
new DynamicKeytab().go();
}
k.writeJAASConf();
// Starts with no keytab
// Test 1: read new key 1 from keytab
connect();
// Test 2: service key cached, find 1 in keytab (now contains 1 and 2)
connect();
// Test 3: re-login. Now find 2 in keytab
connect();
// Test 4: re-login, KDC use 3 this time.
// Put 3 and 4 into keytab but keep the real key back to 3.
connect();
// Test 5: invalid keytab file, should ignore
}
connect();
// Test 6: delete keytab file, identical to revoke all
try {
connect();
throw new Exception("Should not success");
} catch (GSSException gsse) {
// KrbApReq.authenticate(*) if (dkey == null)...
// This should have been Krb5.KRB_AP_ERR_NOKEY
throw new Exception("Not expected failure code: " +
ke.returnCode());
}
}
// Test 7: 3 revoked, should fail (now contains only 5)
// old key is revoked
try {
connect();
throw new Exception("Should not success");
} catch (GSSException gsse) {
throw new Exception("Not expected failure code: " +
ke.returnCode());
}
}
// Test 8: an empty KDC means revoke all
try {
connect();
throw new Exception("Should not success");
} catch (GSSException gsse) {
// KrbApReq.authenticate(*) if (dkey == null)...
// This should have been Krb5.KRB_AP_ERR_NOKEY
throw new Exception("Not expected failure code: " +
ke.returnCode());
}
}
}
}
}