Path: blob/master/test/jdk/javax/security/auth/login/JAASConfigSyntaxCheck/SampleLoginModule.java
51695 views
/*1* Copyright (c) 2007, 2015, 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*/2223import static java.lang.System.out;24import java.util.Map;25import javax.security.auth.Subject;26import javax.security.auth.callback.CallbackHandler;27import javax.security.auth.login.LoginException;28import javax.security.auth.spi.LoginModule;2930/**31* Login module which passes all the time32*/3334public class SampleLoginModule implements LoginModule {3536private final String name;3738public SampleLoginModule() {39name = this.getClass().getName();40}4142@Override43public void initialize(Subject subject, CallbackHandler callbackHandler,44Map<String, ?> sharedState, Map<String, ?> options) {45}4647@Override48public boolean login() throws LoginException {49out.println(name + " Login method of AbstractLoginModule is called ");50out.println(name + ":login:PASS");51return true;52}5354@Override55public boolean commit() throws LoginException {56out.println("Commit of AbstractLoginModule is called");57out.println(name + ":commit:PASS");58return true;5960}6162@Override63public boolean abort() throws LoginException {64out.println("Abourt is called in AbstractLoginModule");65out.println(name + ":abort:PASS");66return true;67}6869@Override70public boolean logout() throws LoginException {71out.println("logout is called in AbstractLoginModule");72out.println(name + ":logout:PASS");73return true;74}75}767778