|
1 /* |
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 |
|
24 /* |
|
25 * @test |
|
26 * @bug 7043847 7043860 7043882 7043938 7043959 |
|
27 * @summary NTML impl of SaslServer conformance errors |
|
28 */ |
|
29 import java.io.IOException; |
|
30 import javax.security.sasl.*; |
|
31 import java.util.*; |
|
32 import javax.security.auth.callback.Callback; |
|
33 import javax.security.auth.callback.CallbackHandler; |
|
34 import javax.security.auth.callback.UnsupportedCallbackException; |
|
35 |
|
36 public class Conformance { |
|
37 |
|
38 public static void main(String[] args) throws Exception { |
|
39 try { |
|
40 Sasl.createSaslClient(new String[] {"NTLM"}, "abc", "ldap", |
|
41 "server", new HashMap<String, Object>(), null); |
|
42 } catch (SaslException se) { |
|
43 System.out.println(se); |
|
44 } |
|
45 try { |
|
46 Sasl.createSaslServer("NTLM", "ldap", |
|
47 "server", new HashMap<String, Object>(), null); |
|
48 } catch (SaslException se) { |
|
49 System.out.println(se); |
|
50 } |
|
51 try { |
|
52 Sasl.createSaslClient(new String[] {"NTLM"}, "abc", "ldap", |
|
53 "server", null, new CallbackHandler() { |
|
54 @Override |
|
55 public void handle(Callback[] callbacks) throws |
|
56 IOException, UnsupportedCallbackException { } |
|
57 }); |
|
58 } catch (SaslException se) { |
|
59 System.out.println(se); |
|
60 } |
|
61 try { |
|
62 SaslServer saslServer = |
|
63 Sasl.createSaslServer("NTLM", "ldap", "abc", null, new CallbackHandler() { |
|
64 @Override |
|
65 public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { } |
|
66 }); |
|
67 System.err.println("saslServer = " + saslServer); |
|
68 System.err.println("saslServer.isComplete() = " + saslServer.isComplete()); |
|
69 // IllegalStateException is expected here |
|
70 saslServer.getNegotiatedProperty("prop"); |
|
71 System.err.println("No IllegalStateException"); |
|
72 } catch (IllegalStateException se) { |
|
73 System.out.println(se); |
|
74 } |
|
75 try { |
|
76 SaslServer saslServer = |
|
77 Sasl.createSaslServer("NTLM", "ldap", "abc", null, new CallbackHandler() { |
|
78 @Override |
|
79 public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { } |
|
80 }); |
|
81 System.err.println("saslServer = " + saslServer); |
|
82 System.err.println("saslServer.isComplete() = " + saslServer.isComplete()); |
|
83 // IllegalStateException is expected here |
|
84 saslServer.getAuthorizationID(); |
|
85 System.err.println("No IllegalStateException"); |
|
86 } catch (IllegalStateException se) { |
|
87 System.out.println(se); |
|
88 } |
|
89 try { |
|
90 SaslServer saslServer = |
|
91 Sasl.createSaslServer("NTLM", "ldap", "abc", null, new CallbackHandler() { |
|
92 @Override |
|
93 public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { } |
|
94 }); |
|
95 System.err.println("saslServer = " + saslServer); |
|
96 System.err.println("saslServer.isComplete() = " + saslServer.isComplete()); |
|
97 // IllegalStateException is expected here |
|
98 saslServer.wrap(new byte[0], 0, 0); |
|
99 System.err.println("No IllegalStateException"); |
|
100 } catch (IllegalStateException se) { |
|
101 System.out.println(se); |
|
102 } |
|
103 } |
|
104 } |