Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/krb5/auto/CleanState.java
38853 views
/*1* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 671653426* @compile -XDignore.symbol.file CleanState.java27* @run main/othervm -Dsun.net.spi.nameservice.provider.1=ns,mock CleanState28* @summary Krb5LoginModule has not cleaned temp info between authentication attempts29*/30import com.sun.security.auth.module.Krb5LoginModule;31import java.util.HashMap;32import java.util.Map;33import javax.security.auth.Subject;34import javax.security.auth.callback.Callback;35import javax.security.auth.callback.CallbackHandler;36import javax.security.auth.callback.NameCallback;37import javax.security.auth.callback.PasswordCallback;3839public class CleanState {40public static void main(String[] args) throws Exception {41CleanState x = new CleanState();42new OneKDC(null);43x.go();44}4546void go() throws Exception {47Krb5LoginModule krb5 = new Krb5LoginModule();4849final String name = OneKDC.USER;50final char[] password = OneKDC.PASS;51char[] badpassword = "hellokitty".toCharArray();5253Map<String,String> map = new HashMap<>();54map.put("useTicketCache", "false");55map.put("doNotPrompt", "false");56map.put("tryFirstPass", "true");57Map<String,Object> shared = new HashMap<>();58shared.put("javax.security.auth.login.name", name);59shared.put("javax.security.auth.login.password", badpassword);6061krb5.initialize(new Subject(), new CallbackHandler() {62@Override63public void handle(Callback[] callbacks) {64for(Callback callback: callbacks) {65if (callback instanceof NameCallback) {66((NameCallback)callback).setName(name);67}68if (callback instanceof PasswordCallback) {69((PasswordCallback)callback).setPassword(password);70}71}72}73}, shared, map);74krb5.login();75}76}777879