author | ihse |
Tue, 09 May 2017 12:57:30 +0200 | |
changeset 45028 | b0ea3c0bfb81 |
parent 32756 | acd1d25bbc77 |
permissions | -rw-r--r-- |
45028
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
1 |
/* |
32756
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
2 |
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
4 |
* |
45028
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
7 |
* published by the Free Software Foundation. |
32756
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
8 |
* |
45028
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
13 |
* accompanied this code). |
32756
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
14 |
* |
45028
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
32756
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
18 |
* |
45028
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
32756
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
32756
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
21 |
* questions. |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
22 |
*/ |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
23 |
|
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
24 |
import javax.security.auth.login.LoginContext; |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
25 |
|
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
26 |
/** |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
27 |
* @test |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
28 |
* @bug 8050461 |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
29 |
* @summary Test should throw Configuration error if configuration file contains |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
30 |
* syntax error |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
31 |
* @build SampleLoginModule JAASConfigSyntaxTest |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
32 |
* @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutApplication.config JAASConfigSyntaxTest |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
33 |
* @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutBraces.config JAASConfigSyntaxTest |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
34 |
* @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutFlag.config JAASConfigSyntaxTest |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
35 |
* @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutLoginModule.config JAASConfigSyntaxTest |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
36 |
* @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutSemiColen.config JAASConfigSyntaxTest |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
37 |
*/ |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
38 |
public class JAASConfigSyntaxTest { |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
39 |
|
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
40 |
private static final String TEST_NAME = "JAASConfigSyntaxTest"; |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
41 |
|
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
42 |
public static void main(String[] args) throws Exception { |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
43 |
try { |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
44 |
LoginContext lc = new LoginContext(TEST_NAME); |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
45 |
lc.login(); |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
46 |
throw new RuntimeException("Test Case Failed, did not get " |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
47 |
+ "expected exception"); |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
48 |
} catch (Exception ex) { |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
49 |
if (ex.getMessage().contains("java.io.IOException: " |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
50 |
+ "Configuration Error:")) { |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
51 |
System.out.println("Test case passed"); |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
52 |
} else { |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
53 |
throw new RuntimeException(ex); |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
54 |
} |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
55 |
} |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
56 |
} |
acd1d25bbc77
8050461: Tests for syntax checking of JAAS configuration file
amjiang
parents:
diff
changeset
|
57 |
} |