4357N/A/*
4357N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4357N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4357N/A *
4357N/A * This code is free software; you can redistribute it and/or modify it
4357N/A * under the terms of the GNU General Public License version 2 only, as
4357N/A * published by the Free Software Foundation.
4357N/A *
4357N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4357N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4357N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4357N/A * version 2 for more details (a copy is included in the LICENSE file that
4357N/A * accompanied this code).
4357N/A *
4357N/A * You should have received a copy of the GNU General Public License version
4357N/A * 2 along with this work; if not, write to the Free Software Foundation,
4357N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4357N/A *
4357N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4357N/A * or visit www.oracle.com if you need additional information or have any
4357N/A * questions.
4357N/A */
4357N/A
4357N/A/*
4357N/A * @test
4357N/A * @bug 7043847 7043860 7043882 7043938 7043959
4357N/A * @summary NTML impl of SaslServer conformance errors
4357N/A */
4357N/Aimport java.io.IOException;
4357N/Aimport javax.security.sasl.*;
4357N/Aimport java.util.*;
4357N/Aimport javax.security.auth.callback.Callback;
4357N/Aimport javax.security.auth.callback.CallbackHandler;
4357N/Aimport javax.security.auth.callback.UnsupportedCallbackException;
4357N/A
4357N/Apublic class Conformance {
4357N/A
4357N/A public static void main(String[] args) throws Exception {
4357N/A try {
4357N/A Sasl.createSaslClient(new String[] {"NTLM"}, "abc", "ldap",
4357N/A "server", new HashMap<String, Object>(), null);
4357N/A } catch (SaslException se) {
4357N/A System.out.println(se);
4357N/A }
4357N/A try {
4357N/A Sasl.createSaslServer("NTLM", "ldap",
4357N/A "server", new HashMap<String, Object>(), null);
4357N/A } catch (SaslException se) {
4357N/A System.out.println(se);
4357N/A }
4357N/A try {
4357N/A Sasl.createSaslClient(new String[] {"NTLM"}, "abc", "ldap",
4357N/A "server", null, new CallbackHandler() {
4357N/A @Override
4357N/A public void handle(Callback[] callbacks) throws
4357N/A IOException, UnsupportedCallbackException { }
4357N/A });
4357N/A } catch (SaslException se) {
4357N/A System.out.println(se);
4357N/A }
4357N/A try {
4357N/A SaslServer saslServer =
4357N/A Sasl.createSaslServer("NTLM", "ldap", "abc", null, new CallbackHandler() {
4357N/A @Override
4357N/A public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { }
4357N/A });
4357N/A System.err.println("saslServer = " + saslServer);
4357N/A System.err.println("saslServer.isComplete() = " + saslServer.isComplete());
4357N/A // IllegalStateException is expected here
4357N/A saslServer.getNegotiatedProperty("prop");
4357N/A System.err.println("No IllegalStateException");
4357N/A } catch (IllegalStateException se) {
4357N/A System.out.println(se);
4357N/A }
4357N/A try {
4357N/A SaslServer saslServer =
4357N/A Sasl.createSaslServer("NTLM", "ldap", "abc", null, new CallbackHandler() {
4357N/A @Override
4357N/A public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { }
4357N/A });
4357N/A System.err.println("saslServer = " + saslServer);
4357N/A System.err.println("saslServer.isComplete() = " + saslServer.isComplete());
4357N/A // IllegalStateException is expected here
4357N/A saslServer.getAuthorizationID();
4357N/A System.err.println("No IllegalStateException");
4357N/A } catch (IllegalStateException se) {
4357N/A System.out.println(se);
4357N/A }
4357N/A try {
4357N/A SaslServer saslServer =
4357N/A Sasl.createSaslServer("NTLM", "ldap", "abc", null, new CallbackHandler() {
4357N/A @Override
4357N/A public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { }
4357N/A });
4357N/A System.err.println("saslServer = " + saslServer);
4357N/A System.err.println("saslServer.isComplete() = " + saslServer.isComplete());
4357N/A // IllegalStateException is expected here
4357N/A saslServer.wrap(new byte[0], 0, 0);
4357N/A System.err.println("No IllegalStateException");
4357N/A } catch (IllegalStateException se) {
4357N/A System.out.println(se);
4357N/A }
4357N/A }
4357N/A}