diff options
| author | Gordon Sim <gsim@apache.org> | 2011-03-01 16:11:19 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2011-03-01 16:11:19 +0000 |
| commit | 5c6cce69413878bacaee0cc74ede7a1a808f95e6 (patch) | |
| tree | d66383006e51c14303205c43aa36f7de081f3974 /java/client/src | |
| parent | 713e72f64313bdae644db65f6bf28fdc0aa101b7 (diff) | |
| download | qpid-python-5c6cce69413878bacaee0cc74ede7a1a808f95e6.tar.gz | |
QPID-2979: Added SASL client plugin for ANONYMOUS; added call to register available plugins for 0-10 codepath.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1075871 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client/src')
4 files changed, 111 insertions, 0 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index b0bd8f8e97..891819c227 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -69,6 +69,12 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec org.apache.qpid.transport.Connection _qpidConnection; private ConnectionException exception = null; + static + { + // Register any configured SASL client factories. + org.apache.qpid.client.security.DynamicSaslRegistrar.registerSaslProviders(); + } + //--- constructor public AMQConnectionDelegate_0_10(AMQConnection conn) { diff --git a/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.properties b/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.properties index 1bff43142b..b903208927 100644 --- a/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.properties +++ b/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.properties @@ -18,3 +18,4 @@ # AMQPLAIN=org.apache.qpid.client.security.amqplain.AmqPlainSaslClientFactory CRAM-MD5-HASHED=org.apache.qpid.client.security.crammd5hashed.CRAMMD5HashedSaslClientFactory +ANONYMOUS=org.apache.qpid.client.security.anonymous.AnonymousSaslClientFactory diff --git a/java/client/src/main/java/org/apache/qpid/client/security/anonymous/AnonymousSaslClient.java b/java/client/src/main/java/org/apache/qpid/client/security/anonymous/AnonymousSaslClient.java new file mode 100644 index 0000000000..0f56b2ef6c --- /dev/null +++ b/java/client/src/main/java/org/apache/qpid/client/security/anonymous/AnonymousSaslClient.java @@ -0,0 +1,52 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.client.security.anonymous; + +import javax.security.sasl.SaslClient; +import javax.security.sasl.SaslException; + +public class AnonymousSaslClient implements SaslClient +{ + public String getMechanismName() { + return "ANONYMOUS"; + } + public boolean hasInitialResponse() { + return true; + } + public byte[] evaluateChallenge(byte[] challenge) throws SaslException { + return new byte[0]; + } + public boolean isComplete() { + return true; + } + public byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException + { + throw new IllegalStateException("No security layer supported"); + } + public byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException + { + throw new IllegalStateException("No security layer supported"); + } + public Object getNegotiatedProperty(String propName) { + return null; + } + public void dispose() throws SaslException {} +} diff --git a/java/client/src/main/java/org/apache/qpid/client/security/anonymous/AnonymousSaslClientFactory.java b/java/client/src/main/java/org/apache/qpid/client/security/anonymous/AnonymousSaslClientFactory.java new file mode 100644 index 0000000000..de698f87c6 --- /dev/null +++ b/java/client/src/main/java/org/apache/qpid/client/security/anonymous/AnonymousSaslClientFactory.java @@ -0,0 +1,52 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.client.security.anonymous; + +import java.util.Arrays; +import java.util.Map; + +import javax.security.sasl.Sasl; +import javax.security.sasl.SaslClient; +import javax.security.sasl.SaslClientFactory; +import javax.security.sasl.SaslException; +import javax.security.auth.callback.CallbackHandler; + +public class AnonymousSaslClientFactory implements SaslClientFactory +{ + public SaslClient createSaslClient(String[] mechanisms, String authId, + String protocol, String server, + Map props, CallbackHandler cbh) throws SaslException + { + if (Arrays.asList(mechanisms).contains("ANONYMOUS")) { + return new AnonymousSaslClient(); + } else { + return null; + } + } + public String[] getMechanismNames(Map props) + { + if (props == null || props.isEmpty()) { + return new String[]{"ANONYMOUS"}; + } else { + return new String[0]; + } + } +} |
