jdk/test/javax/security/auth/spi/Loader.java
author weijun
Fri, 10 Apr 2015 09:15:34 +0800
changeset 29823 9f5f3833d665
permissions -rw-r--r--
8047789: auth.login.LoginContext needs to be updated to work with modules Reviewed-by: mullan, mchung, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29823
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
     1
/*
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
     4
 *
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
     8
 *
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    13
 * accompanied this code).
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    14
 *
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    18
 *
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    21
 * questions.
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    22
 */
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    23
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    24
import javax.security.auth.login.LoginContext;
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    25
import java.io.File;
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    26
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    27
/*
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    28
 * @test
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    29
 * @bug 8047789
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    30
 * @summary auth.login.LoginContext needs to be updated to work with modules
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    31
 * @build FirstLoginModule SecondLoginModule
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    32
 * @run main/othervm Loader
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    33
 */
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    34
public class Loader {
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    35
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    36
    public static void main(String[] args) throws Exception {
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    37
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    38
        System.setProperty("java.security.auth.login.config",
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    39
                new File(System.getProperty("test.src"), "sl.conf").toString());
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    40
        LoginContext lc = new LoginContext("me");
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    41
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    42
        if (SecondLoginModule.isLoaded) {
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    43
            throw new Exception();
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    44
        }
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    45
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    46
        lc.login();
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    47
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    48
        // Although only FirstLoginModule is specified in the JAAS login
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    49
        // config file, LoginContext will first create all LoginModule
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    50
        // implementations that are registered as services, which include
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    51
        // SecondLoginModule.
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    52
        if (!SecondLoginModule.isLoaded) {
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    53
            throw new Exception();
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    54
        }
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    55
    }
9f5f3833d665 8047789: auth.login.LoginContext needs to be updated to work with modules
weijun
parents:
diff changeset
    56
}