From 400cf393e1a7758d7e08093fcb62bfbd1e8881a3 Mon Sep 17 00:00:00 2001 From: Aidan Skinner Date: Wed, 7 Jan 2009 13:32:59 +0000 Subject: QPID-1539: add management/common module. Move SASL and login code there. Make gui depend on management common and OSGify it a bit. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@732330 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/java/management/common/build.xml | 25 +++ .../sasl/CRAMMD5HashedSaslClientFactory.java | 60 ++++++ .../management/common/sasl/ClientSaslFactory.java | 54 ++++++ .../qpid/management/common/sasl/Constants.java | 33 ++++ .../qpid/management/common/sasl/JCAProvider.java | 56 ++++++ .../management/common/sasl/PlainSaslClient.java | 203 ++++++++++++++++++++ .../qpid/management/common/sasl/SaslProvider.java | 35 ++++ .../common/sasl/UserPasswordCallbackHandler.java | 73 ++++++++ .../UsernameHashedPasswordCallbackHandler.java | 108 +++++++++++ .../management/eclipse-plugin/META-INF/MANIFEST.MF | 3 +- .../eclipse-plugin/build-release-common.properties | 2 + .../management/eclipse-plugin/build-release.xml | 13 +- qpid/java/management/eclipse-plugin/build.xml | 2 +- .../org/apache/qpid/management/ui/Constants.java | 4 - .../qpid/management/ui/jmx/JMXServerRegistry.java | 208 ++------------------- .../ui/sasl/CRAMMD5HashedSaslClientFactory.java | 60 ------ .../qpid/management/ui/sasl/ClientSaslFactory.java | 54 ------ .../qpid/management/ui/sasl/JCAProvider.java | 56 ------ .../qpid/management/ui/sasl/PlainSaslClient.java | 203 -------------------- .../qpid/management/ui/sasl/SaslProvider.java | 35 ---- .../ui/sasl/UserPasswordCallbackHandler.java | 73 -------- .../UsernameHashedPasswordCallbackHandler.java | 82 -------- .../main/resources/macosx/Configuration/config.ini | 2 +- .../resources/qpidmanagementcommon/MANIFEST.MF | 11 ++ .../main/resources/unix/configuration/config.ini | 2 +- .../main/resources/win32/configuration/config.ini | 2 +- 26 files changed, 691 insertions(+), 768 deletions(-) create mode 100644 qpid/java/management/common/build.xml create mode 100644 qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/CRAMMD5HashedSaslClientFactory.java create mode 100644 qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/ClientSaslFactory.java create mode 100644 qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/Constants.java create mode 100644 qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/JCAProvider.java create mode 100644 qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/PlainSaslClient.java create mode 100644 qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/SaslProvider.java create mode 100644 qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/UserPasswordCallbackHandler.java create mode 100644 qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/UsernameHashedPasswordCallbackHandler.java delete mode 100644 qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/CRAMMD5HashedSaslClientFactory.java delete mode 100644 qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/ClientSaslFactory.java delete mode 100644 qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/JCAProvider.java delete mode 100644 qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/PlainSaslClient.java delete mode 100644 qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/SaslProvider.java delete mode 100644 qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UserPasswordCallbackHandler.java delete mode 100644 qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UsernameHashedPasswordCallbackHandler.java create mode 100644 qpid/java/management/eclipse-plugin/src/main/resources/qpidmanagementcommon/MANIFEST.MF (limited to 'qpid/java/management') diff --git a/qpid/java/management/common/build.xml b/qpid/java/management/common/build.xml new file mode 100644 index 0000000000..a30aa36578 --- /dev/null +++ b/qpid/java/management/common/build.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/CRAMMD5HashedSaslClientFactory.java b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/CRAMMD5HashedSaslClientFactory.java new file mode 100644 index 0000000000..be4897d6c4 --- /dev/null +++ b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/CRAMMD5HashedSaslClientFactory.java @@ -0,0 +1,60 @@ +/* + * + * 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.management.common.sasl; + +import java.util.Map; + +import javax.security.auth.callback.CallbackHandler; +import javax.security.sasl.Sasl; +import javax.security.sasl.SaslClient; +import javax.security.sasl.SaslClientFactory; +import javax.security.sasl.SaslException; + +public class CRAMMD5HashedSaslClientFactory implements SaslClientFactory +{ + /** The name of this mechanism */ + public static final String MECHANISM = "CRAM-MD5-HASHED"; + + public SaslClient createSaslClient(String[] mechanisms, String authorizationId, String protocol, + String serverName, Map props, CallbackHandler cbh) + throws SaslException + { + for (int i = 0; i < mechanisms.length; i++) + { + if (mechanisms[i].equals(MECHANISM)) + { + if (cbh == null) + { + throw new SaslException("CallbackHandler must not be null"); + } + + String[] mechs = {"CRAM-MD5"}; + return Sasl.createSaslClient(mechs, authorizationId, protocol, serverName, props, cbh); + } + } + return null; + } + + public String[] getMechanismNames(Map props) + { + return new String[]{MECHANISM}; + } +} diff --git a/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/ClientSaslFactory.java b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/ClientSaslFactory.java new file mode 100644 index 0000000000..ee5803a220 --- /dev/null +++ b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/ClientSaslFactory.java @@ -0,0 +1,54 @@ +/* + * + * 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.management.common.sasl; + +import java.util.Map; + +import javax.security.auth.callback.CallbackHandler; +import javax.security.sasl.SaslClient; +import javax.security.sasl.SaslClientFactory; +import javax.security.sasl.SaslException; + +public class ClientSaslFactory implements SaslClientFactory +{ + public SaslClient createSaslClient(String[] mechs, String authorizationId, String protocol, + String serverName, Map props, CallbackHandler cbh) + throws SaslException + { + for (int i = 0; i < mechs.length; i++) + { + if (mechs[i].equals("PLAIN")) + { + return new PlainSaslClient(authorizationId, cbh); + } + } + return null; + } + + /** + * Simple-minded implementation that ignores props + */ + public String[] getMechanismNames(Map props) + { + return new String[]{"PLAIN"}; + } + +} diff --git a/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/Constants.java b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/Constants.java new file mode 100644 index 0000000000..31010baf8b --- /dev/null +++ b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/Constants.java @@ -0,0 +1,33 @@ +/* + * + * 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.management.common.sasl; + +public class Constants +{ + + public final static String MECH_CRAMMD5 = "CRAM-MD5"; + public final static String MECH_PLAIN = "PLAIN"; + public final static String SASL_CRAMMD5 = "SASL/CRAM-MD5"; + public final static String SASL_PLAIN = "SASL/PLAIN"; + +} + diff --git a/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/JCAProvider.java b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/JCAProvider.java new file mode 100644 index 0000000000..f5a3ca8ccc --- /dev/null +++ b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/JCAProvider.java @@ -0,0 +1,56 @@ +/* + * + * 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.management.common.sasl; + +import java.security.Provider; +import java.util.Map; + +import javax.security.sasl.SaslClientFactory; + +public class JCAProvider extends Provider +{ + private static final long serialVersionUID = 1L; + + /** + * Creates the security provider with a map from SASL mechanisms to implementing factories. + * + * @param providerMap The map from SASL mechanims to implementing factory classes. + */ + public JCAProvider(Map> providerMap) + { + super("AMQSASLProvider", 1.0, "A JCA provider that registers all " + + "AMQ SASL providers that want to be registered"); + register(providerMap); + } + + /** + * Registers client factory classes for a map of mechanism names to client factory classes. + * + * @param providerMap The map from SASL mechanims to implementing factory classes. + */ + private void register(Map> providerMap) + { + for (Map.Entry> me : providerMap.entrySet()) + { + put("SaslClientFactory." + me.getKey(), me.getValue().getName()); + } + } +} diff --git a/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/PlainSaslClient.java b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/PlainSaslClient.java new file mode 100644 index 0000000000..806975c32f --- /dev/null +++ b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/PlainSaslClient.java @@ -0,0 +1,203 @@ +/* + * + * 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.management.common.sasl; + +import java.io.*; +import javax.security.auth.callback.*; +import javax.security.sasl.*; + +public class PlainSaslClient implements SaslClient +{ + + private boolean completed; + private CallbackHandler cbh; + private String authorizationID; + private String authenticationID; + private byte password[]; + private static byte SEPARATOR = 0; + + public PlainSaslClient(String authorizationID, CallbackHandler cbh) throws SaslException + { + completed = false; + this.cbh = cbh; + Object[] userInfo = getUserInfo(); + this.authorizationID = authorizationID; + this.authenticationID = (String) userInfo[0]; + this.password = (byte[]) userInfo[1]; + if (authenticationID == null || password == null) + { + throw new SaslException("PLAIN: authenticationID and password must be specified"); + } + } + + public byte[] evaluateChallenge(byte[] challenge) throws SaslException + { + if (completed) + { + throw new IllegalStateException("PLAIN: authentication already " + + "completed"); + } + completed = true; + try + { + byte authzid[] = + authorizationID == null ? null : authorizationID.getBytes("UTF8"); + byte authnid[] = authenticationID.getBytes("UTF8"); + byte response[] = + new byte[ + password.length + + authnid.length + + 2 + // SEPARATOR + (authzid != null ? authzid.length : 0) + ]; + int size = 0; + if (authzid != null) { + System.arraycopy(authzid, 0, response, 0, authzid.length); + size = authzid.length; + } + response[size++] = SEPARATOR; + System.arraycopy(authnid, 0, response, size, authnid.length); + size += authnid.length; + response[size++] = SEPARATOR; + System.arraycopy(password, 0, response, size, password.length); + clearPassword(); + return response; + } catch (UnsupportedEncodingException e) { + throw new SaslException("PLAIN: Cannot get UTF-8 encoding of ids", + e); + } + } + + public String getMechanismName() + { + return "PLAIN"; + } + + public boolean hasInitialResponse() + { + return true; + } + + public boolean isComplete() + { + return completed; + } + + public byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException + { + if (completed) { + throw new IllegalStateException("PLAIN: this mechanism supports " + + "neither integrity nor privacy"); + } else { + throw new IllegalStateException("PLAIN: authentication not " + + "completed"); + } + } + + public byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException + { + if (completed) + { + throw new IllegalStateException("PLAIN: this mechanism supports " + + "neither integrity nor privacy"); + } + else + { + throw new IllegalStateException("PLAIN: authentication not " + + "completed"); + } + } + + public Object getNegotiatedProperty(String propName) + { + if (completed) + { + if (propName.equals(Sasl.QOP)) + { + return "auth"; + } + else + { + return null; + } + } + else + { + throw new IllegalStateException("PLAIN: authentication not " + + "completed"); + } + } + + private void clearPassword() + { + if (password != null) + { + for (int i = 0 ; i < password.length ; i++) + { + password[i] = 0; + } + password = null; + } + } + + public void dispose() throws SaslException + { + clearPassword(); + } + + protected void finalize() + { + clearPassword(); + } + + private Object[] getUserInfo() throws SaslException + { + try + { + final String userPrompt = "PLAIN authentication id: "; + final String pwPrompt = "PLAIN password: "; + NameCallback nameCb = new NameCallback(userPrompt); + PasswordCallback passwordCb = new PasswordCallback(pwPrompt, false); + cbh.handle(new Callback[] { nameCb, passwordCb }); + String userid = nameCb.getName(); + char pwchars[] = passwordCb.getPassword(); + byte pwbytes[]; + if (pwchars != null) + { + pwbytes = (new String(pwchars)).getBytes("UTF8"); + passwordCb.clearPassword(); + } + else + { + pwbytes = null; + } + return (new Object[] { userid, pwbytes }); + } + catch (IOException e) + { + throw new SaslException("Cannot get password", e); + } + catch (UnsupportedCallbackException e) + { + throw new SaslException("Cannot get userid/password", e); + } + } +} diff --git a/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/SaslProvider.java b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/SaslProvider.java new file mode 100644 index 0000000000..1eb44e35df --- /dev/null +++ b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/SaslProvider.java @@ -0,0 +1,35 @@ +/* + * + * 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.management.common.sasl; + +import java.security.Provider; + +public class SaslProvider extends Provider +{ + private static final long serialVersionUID = -6978096016899676466L; + + public SaslProvider() + { + super("SaslClientFactory", 1.0, "SASL PLAIN CLIENT MECHANISM"); + put("SaslClientFactory.PLAIN", "ClientSaslFactory"); + } + +} diff --git a/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/UserPasswordCallbackHandler.java b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/UserPasswordCallbackHandler.java new file mode 100644 index 0000000000..a1634f86d9 --- /dev/null +++ b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/UserPasswordCallbackHandler.java @@ -0,0 +1,73 @@ +/* + * 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.management.common.sasl; + +import java.io.*; +import javax.security.auth.callback.*; + +public class UserPasswordCallbackHandler implements CallbackHandler +{ + private String user; + private char[] pwchars; + + public UserPasswordCallbackHandler(String user, String password) + { + this.user = user; + this.pwchars = password.toCharArray(); + } + + public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException + { + for (int i = 0; i < callbacks.length; i++) + { + if (callbacks[i] instanceof NameCallback) + { + NameCallback ncb = (NameCallback) callbacks[i]; + ncb.setName(user); + } + else if (callbacks[i] instanceof PasswordCallback) + { + PasswordCallback pcb = (PasswordCallback) callbacks[i]; + pcb.setPassword(pwchars); + } + else + { + throw new UnsupportedCallbackException(callbacks[i]); + } + } + } + + private void clearPassword() + { + if (pwchars != null) + { + for (int i = 0 ; i < pwchars.length ; i++) + { + pwchars[i] = 0; + } + pwchars = null; + } + } + + protected void finalize() + { + clearPassword(); + } +} diff --git a/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/UsernameHashedPasswordCallbackHandler.java b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/UsernameHashedPasswordCallbackHandler.java new file mode 100644 index 0000000000..09aba1f3e1 --- /dev/null +++ b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/sasl/UsernameHashedPasswordCallbackHandler.java @@ -0,0 +1,108 @@ +/* + * + * 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.management.common.sasl; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.callback.UnsupportedCallbackException; + + +public class UsernameHashedPasswordCallbackHandler implements CallbackHandler +{ + private String user; + private char[] pwchars; + + public UsernameHashedPasswordCallbackHandler(String user, String password) throws Exception + { + this.user = user; + this.pwchars = getHash(password); + } + + public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException + { + for (int i = 0; i < callbacks.length; i++) + { + if (callbacks[i] instanceof NameCallback) + { + NameCallback ncb = (NameCallback) callbacks[i]; + ncb.setName(user); + } + else if (callbacks[i] instanceof PasswordCallback) + { + PasswordCallback pcb = (PasswordCallback) callbacks[i]; + pcb.setPassword(pwchars); + } + else + { + throw new UnsupportedCallbackException(callbacks[i]); + } + } + } + + + private void clearPassword() + { + if (pwchars != null) + { + for (int i = 0 ; i < pwchars.length ; i++) + { + pwchars[i] = 0; + } + pwchars = null; + } + } + + protected void finalize() + { + clearPassword(); + } + + public static char[] getHash(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException + { + byte[] data = text.getBytes("utf-8"); + + MessageDigest md = MessageDigest.getInstance("MD5"); + + for (byte b : data) + { + md.update(b); + } + + byte[] digest = md.digest(); + + char[] hash = new char[digest.length ]; + + int index = 0; + for (byte b : digest) + { + hash[index++] = (char) b; + } + + return hash; + } +} diff --git a/qpid/java/management/eclipse-plugin/META-INF/MANIFEST.MF b/qpid/java/management/eclipse-plugin/META-INF/MANIFEST.MF index 15fcd8d59a..32d1b7a1b2 100644 --- a/qpid/java/management/eclipse-plugin/META-INF/MANIFEST.MF +++ b/qpid/java/management/eclipse-plugin/META-INF/MANIFEST.MF @@ -10,7 +10,8 @@ Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.ui.forms, - jmxremote.sasl;resolution:=optional + jmxremote.sasl;resolution:=optional, + qpid-management-common Eclipse-LazyStart: true Export-Package: org.apache.qpid.management.ui, org.apache.qpid.management.ui.actions, diff --git a/qpid/java/management/eclipse-plugin/build-release-common.properties b/qpid/java/management/eclipse-plugin/build-release-common.properties index 65ef9be092..29f582bec5 100644 --- a/qpid/java/management/eclipse-plugin/build-release-common.properties +++ b/qpid/java/management/eclipse-plugin/build-release-common.properties @@ -36,3 +36,5 @@ eclipse.ini=src/main/resources/eclipse.ini license.eclipse.txt=src/main/resources/license.eclipse.txt jmxremote.sasl.manifest=src/main/resources/sasl/MANIFEST.MF + +qpidmanagementcommon.manifest=src/main/resources/qpidmanagementcommon/MANIFEST.MF diff --git a/qpid/java/management/eclipse-plugin/build-release.xml b/qpid/java/management/eclipse-plugin/build-release.xml index b116fcb55c..46eca58424 100644 --- a/qpid/java/management/eclipse-plugin/build-release.xml +++ b/qpid/java/management/eclipse-plugin/build-release.xml @@ -33,6 +33,7 @@ + @@ -66,6 +67,16 @@ + + + + + + + + + + @@ -147,6 +158,6 @@ + release-bin-mcplugin-jar,release-bin-qpidmanagementcommon-plugin,release-bin-jmxremote-plugin,release-bin-zip,release-bin-gzip"/> diff --git a/qpid/java/management/eclipse-plugin/build.xml b/qpid/java/management/eclipse-plugin/build.xml index 2c36e79823..1d6144116d 100644 --- a/qpid/java/management/eclipse-plugin/build.xml +++ b/qpid/java/management/eclipse-plugin/build.xml @@ -20,7 +20,7 @@ --> - + diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java index d6f895b64a..5e05375e28 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java @@ -133,8 +133,4 @@ public class Constants public final static String INFO_USERNAME = "Please enter the " + USERNAME; public final static String INFO_PASSWORD = "Please enter the " + PASSWORD; - public final static String MECH_CRAMMD5 = "CRAM-MD5"; - public final static String MECH_PLAIN = "PLAIN"; - public final static String SASL_CRAMMD5 = "SASL/CRAM-MD5"; - public final static String SASL_PLAIN = "SASL/PLAIN"; } diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java index b27661e56c..945c63f19a 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java @@ -20,16 +20,13 @@ */ package org.apache.qpid.management.ui.jmx; -import static org.apache.qpid.management.ui.Constants.*; +import static org.apache.qpid.management.ui.Constants.ALL; -import java.io.IOException; -import java.security.Security; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import javax.management.ListenerNotFoundException; @@ -38,11 +35,8 @@ import javax.management.MBeanServerConnection; import javax.management.Notification; import javax.management.ObjectName; import javax.management.remote.JMXConnector; -import javax.management.remote.JMXConnectorFactory; -import javax.management.remote.JMXServiceURL; -import javax.security.auth.callback.CallbackHandler; -import javax.security.sasl.SaslClientFactory; +import org.apache.qpid.management.common.JMXConnnectionFactory; import org.apache.qpid.management.ui.ApplicationRegistry; import org.apache.qpid.management.ui.ManagedBean; import org.apache.qpid.management.ui.ManagedServer; @@ -51,21 +45,13 @@ import org.apache.qpid.management.ui.model.ManagedAttributeModel; import org.apache.qpid.management.ui.model.NotificationInfoModel; import org.apache.qpid.management.ui.model.NotificationObject; import org.apache.qpid.management.ui.model.OperationDataModel; -import org.apache.qpid.management.ui.sasl.JCAProvider; -import org.apache.qpid.management.ui.sasl.SaslProvider; -import org.apache.qpid.management.ui.sasl.UserPasswordCallbackHandler; -import org.apache.qpid.management.ui.sasl.UsernameHashedPasswordCallbackHandler; public class JMXServerRegistry extends ServerRegistry { - private boolean _connected = false; private ObjectName _serverObjectName = null; - private Map _env = null; - private JMXServiceURL _jmxUrl = null; private JMXConnector _jmxc = null; private MBeanServerConnection _mbsc = null; - private Exception _connectionException = null; private String _securityMechanism = null; private List _usersList; @@ -99,94 +85,20 @@ public class JMXServerRegistry extends ServerRegistry public JMXServerRegistry(ManagedServer server) throws Exception { super(server); + + _jmxc = JMXConnnectionFactory.getJMXConnection( + ApplicationRegistry.timeout, server.getHost(), + server.getPort(), server.getUser(), server.getPassword()); + + _mbsc = _jmxc.getMBeanServerConnection(); - long timeNow; - - //auto-negotiate an RMI or JMXMP (SASL/CRAM-MD5 or SASL/PLAIN) JMX connection to broker - try - { - timeNow = System.currentTimeMillis(); - createJMXconnector("RMI"); - } - catch (IOException rmiIOE) - { - // check if the ioe was raised because we tried connecting to a non RMI-JRMP based JMX server - boolean jrmpServer = !rmiIOE.getMessage().contains("non-JRMP server at remote endpoint"); - - if (jrmpServer) - { - IOException nioe = new IOException(); - nioe.initCause(rmiIOE); - throw nioe; - } - else - { - try - { - //It wasnt an RMI ConnectorServer at the broker end. Try to establish a JMXMP SASL/CRAM-MD5 connection instead. - timeNow = System.currentTimeMillis(); - createJMXconnector("JMXMP_CRAM-MD5"); - } - catch (IOException cramIOE) - { - // check if the IOE was raised because we tried connecting to a SASL/PLAIN server using SASL/CRAM-MD5 - boolean plainProfileServer = cramIOE.getMessage().contains("The server supported profiles [SASL/PLAIN]" + - " do not match the client required profiles [SASL/CRAM-MD5]"); - - if (!plainProfileServer) - { - IOException nioe = new IOException(); - nioe.initCause(cramIOE); - throw nioe; - } - else - { - try - { - // Try to establish a JMXMP SASL/PLAIN connection instead. - timeNow = System.currentTimeMillis(); - createJMXconnector("JMXMP_PLAIN"); - } - catch (IOException plainIOE) - { - /* Out of options now. Check that the IOE was raised because we tried connecting to a server - * which didnt support SASL/PLAIN. If so, signal an unknown profile type. If not, raise the exception. */ - boolean unknownProfile = cramIOE.getMessage().contains("do not match the client required profiles [SASL/PLAIN]"); - - if (unknownProfile) - { - throw new Exception("Unknown JMXMP authentication mechanism, unable to connect."); - } - else - { - IOException nioe = new IOException(); - nioe.initCause(plainIOE); - throw nioe; - } - } - } - } - } - } - - if (_connected) - { - _mbsc = _jmxc.getMBeanServerConnection(); + _clientListener = new ClientListener(server); + _notificationListener = new ClientNotificationListener(server); - _clientListener = new ClientListener(server); - _notificationListener = new ClientNotificationListener(server); + _jmxc.addConnectionNotificationListener(_clientListener, null, null); + _serverObjectName = new ObjectName("JMImplementation:type=MBeanServerDelegate"); + _mbsc.addNotificationListener(_serverObjectName, _clientListener, null, null); - _jmxc.addConnectionNotificationListener(_clientListener, null, null); - _serverObjectName = new ObjectName("JMImplementation:type=MBeanServerDelegate"); - _mbsc.addNotificationListener(_serverObjectName, _clientListener, null, null); - } - else - { - if (System.currentTimeMillis() - timeNow >= ApplicationRegistry.timeout) - throw new Exception("Qpid server connection timed out"); - else - throw new Exception("Qpid server connection failed"); - } } public MBeanServerConnection getServerConnection() @@ -194,106 +106,12 @@ public class JMXServerRegistry extends ServerRegistry return _mbsc; } - private void createJMXconnector(String connectionType) throws IOException, Exception - { - if (connectionType == "RMI") - { - _securityMechanism = MECH_PLAIN; - - _jmxUrl = new JMXServiceURL(getManagedServer().getUrl()); - _env = null; - } - else if (connectionType.contains("JMXMP")) - { - // Check that the JMXMPConnector is available to provide SASL support - final String jmxmpcClass = "javax.management.remote.jmxmp.JMXMPConnector"; - - try - { - Class.forName(jmxmpcClass, false, this.getClass().getClassLoader()); - } - catch (ClassNotFoundException cnfe) - { - throw new Exception("JMXMPConnector class not found, unable to connect to specified server.\n\n" - + "Please add the jmxremote_optional.jar to the jmxremote.sasl plugin folder, or the classpath."); - } - - _jmxUrl = new JMXServiceURL("jmxmp", getManagedServer().getHost(), getManagedServer().getPort()); - _env = new HashMap(); - - /* set the package in which to find the JMXMP ClientProvider.class file loaded by the - * jmxremote.sasl plugin (from the jmxremote_optional.jar) */ - _env.put("jmx.remote.protocol.provider.pkgs", "com.sun.jmx.remote.protocol"); - - if (connectionType == "JMXMP_CRAM-MD5") - { - _securityMechanism = MECH_CRAMMD5; - - Map> map = new HashMap>(); - Class clazz = Class.forName("org.apache.qpid.management.ui.sasl.CRAMMD5HashedSaslClientFactory"); - map.put("CRAM-MD5-HASHED", (Class) clazz); - Security.addProvider(new JCAProvider(map)); - - CallbackHandler handler = new UsernameHashedPasswordCallbackHandler( - getManagedServer().getUser(), - getManagedServer().getPassword()); - _env.put("jmx.remote.profiles", SASL_CRAMMD5); - _env.put("jmx.remote.sasl.callback.handler", handler); - } - else if (connectionType == "JMXMP_PLAIN") - { - _securityMechanism = MECH_PLAIN; - - Security.addProvider(new SaslProvider()); - CallbackHandler handler = new UserPasswordCallbackHandler(getManagedServer().getUser(), getManagedServer().getPassword()); - _env.put("jmx.remote.profiles", SASL_PLAIN); - _env.put("jmx.remote.sasl.callback.handler", handler); - } - else - { - throw new Exception("Unknown authentication mechanism"); - } - } - else - { - throw new Exception("Unknown connection type"); - } - - Thread connectorThread = new Thread(new ConnectorThread()); - connectorThread.start(); - connectorThread.join(ApplicationRegistry.timeout); - - if (_connectionException != null) - { - throw _connectionException; - } - } public String getSecurityMechanism() { return _securityMechanism; } - private class ConnectorThread implements Runnable - { - public void run() - { - try - { - _connected = false; - _connectionException = null; - - _jmxc = JMXConnectorFactory.connect(_jmxUrl, _env); - - _connected = true; - } - catch (Exception ex) - { - _connectionException = ex; - } - } - } - /** * removes all listeners from the mbean server. This is required when user * disconnects the Qpid server connection diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/CRAMMD5HashedSaslClientFactory.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/CRAMMD5HashedSaslClientFactory.java deleted file mode 100644 index 32a0c12344..0000000000 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/CRAMMD5HashedSaslClientFactory.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * 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.management.ui.sasl; - -import java.util.Map; - -import javax.security.auth.callback.CallbackHandler; -import javax.security.sasl.Sasl; -import javax.security.sasl.SaslClient; -import javax.security.sasl.SaslClientFactory; -import javax.security.sasl.SaslException; - -public class CRAMMD5HashedSaslClientFactory implements SaslClientFactory -{ - /** The name of this mechanism */ - public static final String MECHANISM = "CRAM-MD5-HASHED"; - - public SaslClient createSaslClient(String[] mechanisms, String authorizationId, String protocol, - String serverName, Map props, CallbackHandler cbh) - throws SaslException - { - for (int i = 0; i < mechanisms.length; i++) - { - if (mechanisms[i].equals(MECHANISM)) - { - if (cbh == null) - { - throw new SaslException("CallbackHandler must not be null"); - } - - String[] mechs = {"CRAM-MD5"}; - return Sasl.createSaslClient(mechs, authorizationId, protocol, serverName, props, cbh); - } - } - return null; - } - - public String[] getMechanismNames(Map props) - { - return new String[]{MECHANISM}; - } -} diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/ClientSaslFactory.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/ClientSaslFactory.java deleted file mode 100644 index ce9a273eaa..0000000000 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/ClientSaslFactory.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * 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.management.ui.sasl; - -import java.util.Map; - -import javax.security.auth.callback.CallbackHandler; -import javax.security.sasl.SaslClient; -import javax.security.sasl.SaslClientFactory; -import javax.security.sasl.SaslException; - -public class ClientSaslFactory implements SaslClientFactory -{ - public SaslClient createSaslClient(String[] mechs, String authorizationId, String protocol, - String serverName, Map props, CallbackHandler cbh) - throws SaslException - { - for (int i = 0; i < mechs.length; i++) - { - if (mechs[i].equals("PLAIN")) - { - return new PlainSaslClient(authorizationId, cbh); - } - } - return null; - } - - /** - * Simple-minded implementation that ignores props - */ - public String[] getMechanismNames(Map props) - { - return new String[]{"PLAIN"}; - } - -} diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/JCAProvider.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/JCAProvider.java deleted file mode 100644 index d8189f3ac3..0000000000 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/JCAProvider.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * 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.management.ui.sasl; - -import java.security.Provider; -import java.util.Map; - -import javax.security.sasl.SaslClientFactory; - -public class JCAProvider extends Provider -{ - private static final long serialVersionUID = 1L; - - /** - * Creates the security provider with a map from SASL mechanisms to implementing factories. - * - * @param providerMap The map from SASL mechanims to implementing factory classes. - */ - public JCAProvider(Map> providerMap) - { - super("AMQSASLProvider", 1.0, "A JCA provider that registers all " - + "AMQ SASL providers that want to be registered"); - register(providerMap); - } - - /** - * Registers client factory classes for a map of mechanism names to client factory classes. - * - * @param providerMap The map from SASL mechanims to implementing factory classes. - */ - private void register(Map> providerMap) - { - for (Map.Entry> me : providerMap.entrySet()) - { - put("SaslClientFactory." + me.getKey(), me.getValue().getName()); - } - } -} diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/PlainSaslClient.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/PlainSaslClient.java deleted file mode 100644 index 22190f29eb..0000000000 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/PlainSaslClient.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * - * 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.management.ui.sasl; - -import java.io.*; -import javax.security.auth.callback.*; -import javax.security.sasl.*; - -public class PlainSaslClient implements SaslClient -{ - - private boolean completed; - private CallbackHandler cbh; - private String authorizationID; - private String authenticationID; - private byte password[]; - private static byte SEPARATOR = 0; - - public PlainSaslClient(String authorizationID, CallbackHandler cbh) throws SaslException - { - completed = false; - this.cbh = cbh; - Object[] userInfo = getUserInfo(); - this.authorizationID = authorizationID; - this.authenticationID = (String) userInfo[0]; - this.password = (byte[]) userInfo[1]; - if (authenticationID == null || password == null) - { - throw new SaslException("PLAIN: authenticationID and password must be specified"); - } - } - - public byte[] evaluateChallenge(byte[] challenge) throws SaslException - { - if (completed) - { - throw new IllegalStateException("PLAIN: authentication already " + - "completed"); - } - completed = true; - try - { - byte authzid[] = - authorizationID == null ? null : authorizationID.getBytes("UTF8"); - byte authnid[] = authenticationID.getBytes("UTF8"); - byte response[] = - new byte[ - password.length + - authnid.length + - 2 + // SEPARATOR - (authzid != null ? authzid.length : 0) - ]; - int size = 0; - if (authzid != null) { - System.arraycopy(authzid, 0, response, 0, authzid.length); - size = authzid.length; - } - response[size++] = SEPARATOR; - System.arraycopy(authnid, 0, response, size, authnid.length); - size += authnid.length; - response[size++] = SEPARATOR; - System.arraycopy(password, 0, response, size, password.length); - clearPassword(); - return response; - } catch (UnsupportedEncodingException e) { - throw new SaslException("PLAIN: Cannot get UTF-8 encoding of ids", - e); - } - } - - public String getMechanismName() - { - return "PLAIN"; - } - - public boolean hasInitialResponse() - { - return true; - } - - public boolean isComplete() - { - return completed; - } - - public byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException - { - if (completed) { - throw new IllegalStateException("PLAIN: this mechanism supports " + - "neither integrity nor privacy"); - } else { - throw new IllegalStateException("PLAIN: authentication not " + - "completed"); - } - } - - public byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException - { - if (completed) - { - throw new IllegalStateException("PLAIN: this mechanism supports " + - "neither integrity nor privacy"); - } - else - { - throw new IllegalStateException("PLAIN: authentication not " + - "completed"); - } - } - - public Object getNegotiatedProperty(String propName) - { - if (completed) - { - if (propName.equals(Sasl.QOP)) - { - return "auth"; - } - else - { - return null; - } - } - else - { - throw new IllegalStateException("PLAIN: authentication not " + - "completed"); - } - } - - private void clearPassword() - { - if (password != null) - { - for (int i = 0 ; i < password.length ; i++) - { - password[i] = 0; - } - password = null; - } - } - - public void dispose() throws SaslException - { - clearPassword(); - } - - protected void finalize() - { - clearPassword(); - } - - private Object[] getUserInfo() throws SaslException - { - try - { - final String userPrompt = "PLAIN authentication id: "; - final String pwPrompt = "PLAIN password: "; - NameCallback nameCb = new NameCallback(userPrompt); - PasswordCallback passwordCb = new PasswordCallback(pwPrompt, false); - cbh.handle(new Callback[] { nameCb, passwordCb }); - String userid = nameCb.getName(); - char pwchars[] = passwordCb.getPassword(); - byte pwbytes[]; - if (pwchars != null) - { - pwbytes = (new String(pwchars)).getBytes("UTF8"); - passwordCb.clearPassword(); - } - else - { - pwbytes = null; - } - return (new Object[] { userid, pwbytes }); - } - catch (IOException e) - { - throw new SaslException("Cannot get password", e); - } - catch (UnsupportedCallbackException e) - { - throw new SaslException("Cannot get userid/password", e); - } - } -} diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/SaslProvider.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/SaslProvider.java deleted file mode 100644 index 2917de8740..0000000000 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/SaslProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * 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.management.ui.sasl; - -import java.security.Provider; - -public class SaslProvider extends Provider -{ - private static final long serialVersionUID = -6978096016899676466L; - - public SaslProvider() - { - super("SaslClientFactory", 1.0, "SASL PLAIN CLIENT MECHANISM"); - put("SaslClientFactory.PLAIN", "ClientSaslFactory"); - } - -} diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UserPasswordCallbackHandler.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UserPasswordCallbackHandler.java deleted file mode 100644 index 1602229c85..0000000000 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UserPasswordCallbackHandler.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.management.ui.sasl; - -import java.io.*; -import javax.security.auth.callback.*; - -public class UserPasswordCallbackHandler implements CallbackHandler -{ - private String user; - private char[] pwchars; - - public UserPasswordCallbackHandler(String user, String password) - { - this.user = user; - this.pwchars = password.toCharArray(); - } - - public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException - { - for (int i = 0; i < callbacks.length; i++) - { - if (callbacks[i] instanceof NameCallback) - { - NameCallback ncb = (NameCallback) callbacks[i]; - ncb.setName(user); - } - else if (callbacks[i] instanceof PasswordCallback) - { - PasswordCallback pcb = (PasswordCallback) callbacks[i]; - pcb.setPassword(pwchars); - } - else - { - throw new UnsupportedCallbackException(callbacks[i]); - } - } - } - - private void clearPassword() - { - if (pwchars != null) - { - for (int i = 0 ; i < pwchars.length ; i++) - { - pwchars[i] = 0; - } - pwchars = null; - } - } - - protected void finalize() - { - clearPassword(); - } -} diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UsernameHashedPasswordCallbackHandler.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UsernameHashedPasswordCallbackHandler.java deleted file mode 100644 index f4e3d2661e..0000000000 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UsernameHashedPasswordCallbackHandler.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * 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.management.ui.sasl; - -import java.io.IOException; - -import javax.security.auth.callback.Callback; -import javax.security.auth.callback.CallbackHandler; -import javax.security.auth.callback.NameCallback; -import javax.security.auth.callback.PasswordCallback; -import javax.security.auth.callback.UnsupportedCallbackException; - -import org.apache.qpid.management.ui.views.ViewUtility; - -public class UsernameHashedPasswordCallbackHandler implements CallbackHandler -{ - private String user; - private char[] pwchars; - - public UsernameHashedPasswordCallbackHandler(String user, String password) throws Exception - { - this.user = user; - this.pwchars = ViewUtility.getHash(password); - } - - public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException - { - for (int i = 0; i < callbacks.length; i++) - { - if (callbacks[i] instanceof NameCallback) - { - NameCallback ncb = (NameCallback) callbacks[i]; - ncb.setName(user); - } - else if (callbacks[i] instanceof PasswordCallback) - { - PasswordCallback pcb = (PasswordCallback) callbacks[i]; - pcb.setPassword(pwchars); - } - else - { - throw new UnsupportedCallbackException(callbacks[i]); - } - } - } - - - private void clearPassword() - { - if (pwchars != null) - { - for (int i = 0 ; i < pwchars.length ; i++) - { - pwchars[i] = 0; - } - pwchars = null; - } - } - - protected void finalize() - { - clearPassword(); - } -} diff --git a/qpid/java/management/eclipse-plugin/src/main/resources/macosx/Configuration/config.ini b/qpid/java/management/eclipse-plugin/src/main/resources/macosx/Configuration/config.ini index fe1a9fe2c2..de55f949a4 100644 --- a/qpid/java/management/eclipse-plugin/src/main/resources/macosx/Configuration/config.ini +++ b/qpid/java/management/eclipse-plugin/src/main/resources/macosx/Configuration/config.ini @@ -24,7 +24,7 @@ osgi.splashPath=platform\:/base/plugins/org.eclipse.platform eclipse.product=org.apache.qpid.management.ui.product eclipse.application=org.apache.qpid.management.ui.application -osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.core.runtime@start,com.ibm.icu,org.apache.qpid.management.ui,org.eclipse.core.commands,org.eclipse.core.contenttype,org.eclipse.core.expressions,org.eclipse.core.jobs,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.help,org.eclipse.jface,org.eclipse.swt,org.eclipse.swt.carbon.macosx,org.eclipse.ui,org.eclipse.ui.forms,org.eclipse.ui.workbench,org.eclipse.equinox.app,org.eclipse.core.databinding,org.eclipse.jface.databinding,jmxremote.sasl +osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.core.runtime@start,com.ibm.icu,org.apache.qpid.management.ui,org.eclipse.core.commands,org.eclipse.core.contenttype,org.eclipse.core.expressions,org.eclipse.core.jobs,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.help,org.eclipse.jface,org.eclipse.swt,org.eclipse.swt.carbon.macosx,org.eclipse.ui,org.eclipse.ui.forms,org.eclipse.ui.workbench,org.eclipse.equinox.app,org.eclipse.core.databinding,org.eclipse.jface.databinding,jmxremote.sasl,qpid-management-common osgi.bundles.defaultStartLevel=4 eof=eof diff --git a/qpid/java/management/eclipse-plugin/src/main/resources/qpidmanagementcommon/MANIFEST.MF b/qpid/java/management/eclipse-plugin/src/main/resources/qpidmanagementcommon/MANIFEST.MF new file mode 100644 index 0000000000..496dec6129 --- /dev/null +++ b/qpid/java/management/eclipse-plugin/src/main/resources/qpidmanagementcommon/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 1 +Bundle-Name: Qpid management commonPlug-in +Bundle-SymbolicName: qpid-management-common +Bundle-Version: 1.0.0 +Bundle-ClassPath: qpid-management-common-M4.jar +Export-Package: org.apache.qpid.management.common, + org.apache.qpid.management.common.sasl +Bundle-Vendor: +Bundle-Localization: plugin +Require-Bundle: jmxremote.sasl diff --git a/qpid/java/management/eclipse-plugin/src/main/resources/unix/configuration/config.ini b/qpid/java/management/eclipse-plugin/src/main/resources/unix/configuration/config.ini index 5bbf344c17..3c70d9aa0d 100644 --- a/qpid/java/management/eclipse-plugin/src/main/resources/unix/configuration/config.ini +++ b/qpid/java/management/eclipse-plugin/src/main/resources/unix/configuration/config.ini @@ -22,6 +22,6 @@ osgi.splashPath=platform:/base/plugins/org.apache.qpid.management.ui eclipse.product=org.apache.qpid.management.ui.product eclipse.application=org.apache.qpid.management.ui.application -osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.core.runtime@start,com.ibm.icu,org.apache.qpid.management.ui,org.eclipse.core.commands,org.eclipse.core.contenttype,org.eclipse.core.expressions,org.eclipse.core.jobs,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.help,org.eclipse.jface,org.eclipse.swt,org.eclipse.swt.gtk.linux.x86,org.eclipse.ui,org.eclipse.ui.forms,org.eclipse.ui.workbench,jmxremote.sasl +osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.core.runtime@start,com.ibm.icu,org.apache.qpid.management.ui,org.eclipse.core.commands,org.eclipse.core.contenttype,org.eclipse.core.expressions,org.eclipse.core.jobs,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.help,org.eclipse.jface,org.eclipse.swt,org.eclipse.swt.gtk.linux.x86,org.eclipse.ui,org.eclipse.ui.forms,org.eclipse.ui.workbench,jmxremote.sasl,qpid-management-common osgi.bundles.defaultStartLevel=4 eof=eof diff --git a/qpid/java/management/eclipse-plugin/src/main/resources/win32/configuration/config.ini b/qpid/java/management/eclipse-plugin/src/main/resources/win32/configuration/config.ini index e83321e650..aa68db3e4e 100644 --- a/qpid/java/management/eclipse-plugin/src/main/resources/win32/configuration/config.ini +++ b/qpid/java/management/eclipse-plugin/src/main/resources/win32/configuration/config.ini @@ -22,5 +22,5 @@ osgi.splashPath=platform:/base/plugins/org.apache.qpid.management.ui eclipse.product=org.apache.qpid.management.ui.product eclipse.application=org.apache.qpid.management.ui.application -osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.core.runtime@start,com.ibm.icu,org.apache.qpid.management.ui,org.eclipse.core.commands,org.eclipse.core.contenttype,org.eclipse.core.expressions,org.eclipse.core.jobs,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.help,org.eclipse.jface,org.eclipse.swt,org.eclipse.swt.win32.win32.x86,org.eclipse.ui,org.eclipse.ui.forms,jmxremote.sasl,org.eclipse.ui.workbench +osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.core.runtime@start,com.ibm.icu,org.apache.qpid.management.ui,org.eclipse.core.commands,org.eclipse.core.contenttype,org.eclipse.core.expressions,org.eclipse.core.jobs,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.help,org.eclipse.jface,org.eclipse.swt,org.eclipse.swt.win32.win32.x86,org.eclipse.ui,org.eclipse.ui.forms,jmxremote.sasl,org.eclipse.ui.workbench,qpid-management-common osgi.bundles.defaultStartLevel=4 -- cgit v1.2.1