Path: blob/master/test/jdk/com/sun/security/sasl/ntlm/Conformance.java
41154 views
/*1* Copyright (c) 2011, 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*/2223/*24* @test25* @bug 7043847 7043860 7043882 7043938 704395926* @summary NTML impl of SaslServer conformance errors27*/28import java.io.IOException;29import javax.security.sasl.*;30import java.util.*;31import javax.security.auth.callback.Callback;32import javax.security.auth.callback.CallbackHandler;33import javax.security.auth.callback.UnsupportedCallbackException;3435public class Conformance {3637public static void main(String[] args) throws Exception {38try {39Sasl.createSaslClient(new String[] {"NTLM"}, "abc", "ldap",40"server", new HashMap<String, Object>(), null);41} catch (SaslException se) {42System.out.println(se);43}44try {45Sasl.createSaslServer("NTLM", "ldap",46"server", new HashMap<String, Object>(), null);47} catch (SaslException se) {48System.out.println(se);49}50try {51Sasl.createSaslClient(new String[] {"NTLM"}, "abc", "ldap",52"server", null, new CallbackHandler() {53@Override54public void handle(Callback[] callbacks) throws55IOException, UnsupportedCallbackException { }56});57} catch (SaslException se) {58System.out.println(se);59}60try {61SaslServer saslServer =62Sasl.createSaslServer("NTLM", "ldap", "abc", null, new CallbackHandler() {63@Override64public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { }65});66System.err.println("saslServer = " + saslServer);67System.err.println("saslServer.isComplete() = " + saslServer.isComplete());68// IllegalStateException is expected here69saslServer.getNegotiatedProperty("prop");70System.err.println("No IllegalStateException");71} catch (IllegalStateException se) {72System.out.println(se);73}74try {75SaslServer saslServer =76Sasl.createSaslServer("NTLM", "ldap", "abc", null, new CallbackHandler() {77@Override78public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { }79});80System.err.println("saslServer = " + saslServer);81System.err.println("saslServer.isComplete() = " + saslServer.isComplete());82// IllegalStateException is expected here83saslServer.getAuthorizationID();84System.err.println("No IllegalStateException");85} catch (IllegalStateException se) {86System.out.println(se);87}88try {89SaslServer saslServer =90Sasl.createSaslServer("NTLM", "ldap", "abc", null, new CallbackHandler() {91@Override92public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { }93});94System.err.println("saslServer = " + saslServer);95System.err.println("saslServer.isComplete() = " + saslServer.isComplete());96// IllegalStateException is expected here97saslServer.wrap(new byte[0], 0, 0);98System.err.println("No IllegalStateException");99} catch (IllegalStateException se) {100System.out.println(se);101}102}103}104105106