diff --git a/.gitignore b/.gitignore index 41d629a..8a55485 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/thermostat-1.0.4.tar.gz +SOURCES/thermostat-1.2.0.tar.gz diff --git a/.thermostat1-thermostat.metadata b/.thermostat1-thermostat.metadata index 7d15419..98b67d0 100644 --- a/.thermostat1-thermostat.metadata +++ b/.thermostat1-thermostat.metadata @@ -1 +1 @@ -6c42c87ab6d341cd9350b033529b9a96ca2f2caa SOURCES/thermostat-1.0.4.tar.gz +fd548407d3abbf34df9e8d0c58f8f4a36f80743c SOURCES/thermostat-1.2.0.tar.gz diff --git a/SOURCES/agent_remove_rmi.patch b/SOURCES/agent_remove_rmi.patch deleted file mode 100644 index 2b0595a..0000000 --- a/SOURCES/agent_remove_rmi.patch +++ /dev/null @@ -1,4169 +0,0 @@ -diff -urN thermostat-1.0.4.old/agent/core/pom.xml thermostat-1.0.4/agent/core/pom.xml ---- thermostat-1.0.4.old/agent/core/pom.xml 2014-12-05 14:25:31.346043250 -0500 -+++ thermostat-1.0.4/agent/core/pom.xml 2014-12-05 14:26:44.814483946 -0500 -@@ -75,11 +75,6 @@ - - - com.redhat.thermostat -- thermostat-agent-proxy-common -- ${project.version} -- -- -- com.redhat.thermostat - thermostat-launcher - ${project.version} - -diff -urN thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/agent/internal/Activator.java thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/agent/internal/Activator.java ---- thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/agent/internal/Activator.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/agent/internal/Activator.java 2014-12-05 14:26:44.814483946 -0500 -@@ -62,14 +62,15 @@ - context.registerService(RMIRegistry.class, registry, null); - ServiceReference pathsRef = context.getServiceReference(CommonPaths.class); - CommonPaths paths = context.getService(pathsRef); -- pool = new MXBeanConnectionPoolImpl(registry, paths.getSystemBinRoot()); -+ UserNameUtilImpl usernameUtil = new UserNameUtilImpl(); -+ context.registerService(UserNameUtil.class, usernameUtil, null); -+ pool = new MXBeanConnectionPoolImpl(paths.getSystemBinRoot(), usernameUtil); - context.registerService(MXBeanConnectionPool.class, pool, null); - StorageCredentials creds = new AgentStorageCredentials(paths.getUserAgentAuthConfigFile()); - context.registerService(StorageCredentials.class, creds, null); - AgentConfigsUtils.setConfigFiles(paths.getSystemAgentConfigurationFile(), paths.getUserAgentConfigurationFile()); - paths = null; - context.ungetService(pathsRef); -- context.registerService(UserNameUtil.class, new UserNameUtilImpl(), null); - VmBlacklistImpl blacklist = new VmBlacklistImpl(); - blacklist.addVmFilter(new AgentProxyFilter()); - context.registerService(VmBlacklist.class, blacklist, null); -@@ -78,10 +79,7 @@ - @Override - public void stop(BundleContext context) throws Exception { - // Services automatically unregistered by framework -- if (pool != null) { -- pool.shutdown(); -- pool = null; -- } -+ pool = null; - } - - // Testing hook. -diff -urN thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/agent/internal/RMIRegistryImpl.java thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/agent/internal/RMIRegistryImpl.java ---- thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/agent/internal/RMIRegistryImpl.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/agent/internal/RMIRegistryImpl.java 2014-12-05 14:26:44.815483952 -0500 -@@ -36,120 +36,31 @@ - - package com.redhat.thermostat.agent.internal; - --import java.io.IOException; --import java.net.InetAddress; --import java.net.ServerSocket; --import java.rmi.NoSuchObjectException; - import java.rmi.Remote; - import java.rmi.RemoteException; --import java.rmi.registry.LocateRegistry; - import java.rmi.registry.Registry; --import java.rmi.server.RMIClientSocketFactory; --import java.rmi.server.RMIServerSocketFactory; --import java.rmi.server.RMISocketFactory; --import java.rmi.server.UnicastRemoteObject; --import java.util.logging.Logger; - - import com.redhat.thermostat.agent.RMIRegistry; --import com.redhat.thermostat.common.utils.LoggingUtils; - -+@Deprecated - public class RMIRegistryImpl implements RMIRegistry { - -- private static final Logger logger = LoggingUtils.getLogger(RMIRegistryImpl.class); -- -- private RegistryWrapper registryWrapper; -- private ServerSocketCreator serverSockCreator; -- private Registry registry; -- -- public RMIRegistryImpl() { -- this(new RegistryWrapper(), new ServerSocketCreator()); -- } -- -- RMIRegistryImpl(RegistryWrapper registryWrapper, ServerSocketCreator serverSockCreator) { -- this.registryWrapper = registryWrapper; -- this.serverSockCreator = serverSockCreator; -- } -- -- public void start() throws RemoteException { -- this.registry = registryWrapper.createRegistry(Registry.REGISTRY_PORT /* TODO customize */, -- RMISocketFactory.getDefaultSocketFactory(), -- new RMIServerSocketFactory() { -- -- @Override -- public ServerSocket createServerSocket(int port) throws IOException { -- // Allow only local connections -- return serverSockCreator.createSocket(port, 0, InetAddress.getLoopbackAddress()); -- } -- }); -- logger.fine("Starting RMI registry"); -+ RMIRegistryImpl() { - } - - @Override - public Registry getRegistry() throws RemoteException { -- // We get a class loading problem when returning the local registry reference, -- // this returns a remote stub reference instead -- return registryWrapper.getRegistry(); -- } -- -- public void stop() throws RemoteException { -- if (registry != null) { -- registryWrapper.destroyRegistry(registry); -- registry = null; -- logger.fine("Shutting down RMI registry"); -- } -+ throw new RemoteException("RMI is no longer used"); - } - - @Override - public Remote export(Remote obj) throws RemoteException { -- if (registry == null) { -- throw new RemoteException("RMI registry is not running"); -- } -- return registryWrapper.export(obj, 0); -+ throw new RemoteException("RMI is no longer used"); - } - - @Override - public boolean unexport(Remote obj) throws RemoteException { -- if (registry == null) { -- throw new RemoteException("RMI registry is not running"); -- } -- return registryWrapper.unexport(obj, true); -- } -- -- /* -- * For testing purposes only. -- */ -- Registry getRegistryImpl() { -- return registry; -+ throw new RemoteException("RMI is no longer used"); - } - -- static class RegistryWrapper { -- Registry createRegistry(int port, RMIClientSocketFactory csf, -- RMIServerSocketFactory ssf) throws RemoteException { -- return LocateRegistry.createRegistry(port, csf, ssf); -- } -- -- Registry getRegistry() throws RemoteException { -- return LocateRegistry.getRegistry(InetAddress.getLoopbackAddress().getHostName()); -- } -- -- void destroyRegistry(Registry registry) throws NoSuchObjectException { -- // Shuts down RMI registry -- UnicastRemoteObject.unexportObject(registry, true); -- } -- -- Remote export(Remote obj, int port) throws RemoteException { -- return UnicastRemoteObject.exportObject(obj, 0); -- } -- -- boolean unexport(Remote obj, boolean force) throws NoSuchObjectException { -- return UnicastRemoteObject.unexportObject(obj, force); -- } -- } -- -- static class ServerSocketCreator { -- ServerSocket createSocket(int port, int backlog, InetAddress bindAddr) throws IOException { -- return new ServerSocket(port, backlog, bindAddr); -- } -- } -- - } -diff -urN thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/agent/RMIRegistry.java thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/agent/RMIRegistry.java ---- thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/agent/RMIRegistry.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/agent/RMIRegistry.java 2014-12-05 14:26:44.816483958 -0500 -@@ -45,8 +45,13 @@ - /** - * Maintains an RMI registry used for inter-process communication between - * the Thermostat agent and other helper processes on the same host. -+ * -+ *

-+ * RMI is no longer used by the Thermostat agent. Invoking any of this -+ * service's methods will result in a {@link RemoteException}. - */ - @Service -+@Deprecated - public interface RMIRegistry { - - /** -diff -urN thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/AgentProxyClient.java thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/AgentProxyClient.java ---- thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/AgentProxyClient.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/AgentProxyClient.java 2014-12-05 14:26:44.816483958 -0500 -@@ -36,141 +36,107 @@ - - package com.redhat.thermostat.utils.management.internal; - -+import java.io.BufferedReader; - import java.io.File; - import java.io.IOException; --import java.rmi.NotBoundException; --import java.rmi.RemoteException; --import java.rmi.registry.Registry; --import java.util.concurrent.CountDownLatch; --import java.util.concurrent.TimeUnit; -+import java.io.InputStream; -+import java.io.InputStreamReader; -+import java.util.logging.Level; - import java.util.logging.Logger; - --import com.redhat.thermostat.agent.RMIRegistry; --import com.redhat.thermostat.agent.proxy.common.AgentProxyControl; --import com.redhat.thermostat.agent.proxy.common.AgentProxyListener; --import com.redhat.thermostat.agent.proxy.common.AgentProxyLogin; - import com.redhat.thermostat.common.tools.ApplicationException; --import com.redhat.thermostat.common.utils.LoggedExternalProcess; - import com.redhat.thermostat.common.utils.LoggingUtils; - --class AgentProxyClient implements AgentProxyListener { -+class AgentProxyClient { - -- private static final long SERVER_TIMEOUT_MS = 5000L; - private static final String SERVER_NAME = "thermostat-agent-proxy"; - private static final Logger logger = LoggingUtils.getLogger(AgentProxyClient.class); - -- private final RMIRegistry registry; - private final int pid; - private final ProcessCreator procCreator; - private final File binPath; -- private final CountDownLatch started; -+ private final String username; - -- private AgentProxyControl proxy; -- private Exception serverError; -- -- AgentProxyClient(RMIRegistry registry, int pid, File binPath) { -- this(registry, pid, binPath, new CountDownLatch(1), -- new ProcessCreator()); -+ AgentProxyClient(int pid, String user, File binPath) { -+ this(pid, user, binPath, new ProcessCreator()); - } - -- AgentProxyClient(RMIRegistry registry, int pid, File binPath, -- CountDownLatch started, ProcessCreator procCreator) { -- this.registry = registry; -+ AgentProxyClient(int pid, String user, File binPath, ProcessCreator procCreator) { - this.pid = pid; - this.binPath = binPath; -- this.started = started; - this.procCreator = procCreator; -+ this.username = user; - } - -- void createProxy() throws IOException, ApplicationException { -- // Export our listener -- AgentProxyListener stub = (AgentProxyListener) registry.export(this); -- String listenerName = REMOTE_PREFIX + String.valueOf(pid); -- Registry reg = registry.getRegistry(); -- reg.rebind(listenerName, stub); -- logger.fine("Registered proxy listener for " + pid); -- -- // Start the agent proxy, and wait until it exports itself -+ String getJMXServiceURL() throws IOException, ApplicationException { -+ // Start the agent proxy -+ Process proxy = null; -+ Thread errReaderThread = null; - try { -- startProcess(); -- } finally { -- // Got started event or timed out, unregister our listener -- try { -- reg.unbind(listenerName); -- registry.unexport(this); -- } catch (NotBoundException e) { -- throw new RemoteException("Error unregistering listener", e); -- } -- } -+ proxy = startProcess(); - -- // Check if server started successfully -- if (serverError != null) { -- throw new RemoteException("Server failed to start", serverError); -- } -+ final InputStream errStream = proxy.getErrorStream(); - -- // Lookup server -- String serverName = AgentProxyLogin.REMOTE_PREFIX + String.valueOf(pid); -- try { -- // Need to authenticate in order to obtain proxy object -- AgentProxyLogin proxyLogin = (AgentProxyLogin) reg.lookup(serverName); -- proxy = proxyLogin.login(); -- } catch (NotBoundException e) { -- throw new RemoteException("Unable to find remote interface", e); -- } -- } -+ // Log stderr in a separate thread -+ errReaderThread = new Thread(new Runnable() { -+ @Override -+ public void run() { -+ BufferedReader errReader = new BufferedReader(new InputStreamReader(errStream)); -+ String line; -+ try { -+ while ((line = errReader.readLine()) != null -+ && !Thread.currentThread().isInterrupted()) { -+ logger.info(line); -+ } -+ errReader.close(); -+ } catch (IOException e) { -+ logger.log(Level.WARNING, "Failed to read error stream", e); -+ } -+ } -+ }); -+ errReaderThread.start(); -+ -+ // Get JMX service URL from stdout -+ BufferedReader outReader = new BufferedReader(new InputStreamReader(proxy.getInputStream())); -+ String url = outReader.readLine(); - -- private void startProcess() throws IOException, ApplicationException { -- String serverPath = binPath + File.separator + SERVER_NAME; -- procCreator.createAndRunProcess(new String[] { serverPath, String.valueOf(pid) }); -- try { -- boolean result = started.await(SERVER_TIMEOUT_MS, TimeUnit.MILLISECONDS); -- if (!result) { -- throw new RemoteException("Timeout while waiting for server"); -+ // Wait for process to terminate -+ try { -+ proxy.waitFor(); -+ } catch (InterruptedException e) { -+ errReaderThread.interrupt(); -+ Thread.currentThread().interrupt(); -+ } -+ outReader.close(); -+ if (url == null) { -+ throw new IOException("Failed to determine JMX service URL from proxy process"); -+ } -+ -+ return url; -+ } finally { -+ if (proxy != null) { -+ proxy.destroy(); -+ } -+ if (errReaderThread != null) { -+ try { -+ errReaderThread.join(); -+ } catch (InterruptedException e) { -+ errReaderThread.interrupt(); -+ Thread.currentThread().interrupt(); -+ } - } -- } catch (InterruptedException e) { -- // Restore interrupted status -- Thread.currentThread().interrupt(); - } - } -- -- void attach() throws RemoteException { -- proxy.attach(); -- } -- -- boolean isAttached() throws RemoteException { -- return proxy.isAttached(); -- } -- -- String getConnectorAddress() throws RemoteException { -- return proxy.getConnectorAddress(); -- } -- -- void detach() throws RemoteException { -- proxy.detach(); -- } -- -- @Override -- public void serverStarted() throws RemoteException { -- started.countDown(); -- } - -- @Override -- public void serverFailedToStart(Exception error) throws RemoteException { -- serverError = error; -- started.countDown(); -- } -- -- /* -- * For testing purposes only. -- */ -- AgentProxyControl getProxy() { -- return proxy; -+ private Process startProcess() throws IOException, ApplicationException { -+ String serverPath = binPath + File.separator + SERVER_NAME; -+ return procCreator.createAndRunProcess(new String[] { serverPath, String.valueOf(pid), username }); - } - - static class ProcessCreator { - Process createAndRunProcess(String[] args) throws IOException, ApplicationException { -- LoggedExternalProcess process = new LoggedExternalProcess(args); -- return process.runAndReturnProcess(); -+ ProcessBuilder process = new ProcessBuilder(args); -+ return process.start(); - } - } - -diff -urN thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/MXBeanConnectionPoolImpl.java thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/MXBeanConnectionPoolImpl.java ---- thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/MXBeanConnectionPoolImpl.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/MXBeanConnectionPoolImpl.java 2014-12-05 14:26:44.817483964 -0500 -@@ -38,46 +38,34 @@ - - import java.io.File; - import java.io.IOException; --import java.rmi.RemoteException; - import java.util.HashMap; - import java.util.Map; --import java.util.logging.Level; --import java.util.logging.Logger; - --import com.redhat.thermostat.agent.RMIRegistry; --import com.redhat.thermostat.agent.internal.RMIRegistryImpl; -+import com.redhat.thermostat.agent.utils.ProcDataSource; - import com.redhat.thermostat.agent.utils.management.MXBeanConnection; - import com.redhat.thermostat.agent.utils.management.MXBeanConnectionPool; -+import com.redhat.thermostat.agent.utils.username.UserNameUtil; - import com.redhat.thermostat.common.Pair; - import com.redhat.thermostat.common.tools.ApplicationException; --import com.redhat.thermostat.common.utils.LoggingUtils; -+import com.redhat.thermostat.utils.management.internal.ProcessUserInfoBuilder.ProcessUserInfo; - - public class MXBeanConnectionPoolImpl implements MXBeanConnectionPool { - -- private static final Logger logger = LoggingUtils.getLogger(MXBeanConnectionPoolImpl.class); -- - // pid -> (usageCount, actualObject) - private Map> pool = new HashMap<>(); - - private final ConnectorCreator creator; -- private final RMIRegistryImpl registry; - private final File binPath; -+ private final ProcessUserInfoBuilder userInfoBuilder; - -- public MXBeanConnectionPoolImpl(RMIRegistryImpl registry, File binPath) { -- this(new ConnectorCreator(), registry, binPath); -+ public MXBeanConnectionPoolImpl(File binPath, UserNameUtil userNameUtil) { -+ this(new ConnectorCreator(), binPath, new ProcessUserInfoBuilder(new ProcDataSource(), userNameUtil)); - } - -- MXBeanConnectionPoolImpl(ConnectorCreator connectorCreator, RMIRegistryImpl registry, File binPath) { -+ MXBeanConnectionPoolImpl(ConnectorCreator connectorCreator, File binPath, ProcessUserInfoBuilder userInfoBuilder) { - this.creator = connectorCreator; -- this.registry = registry; - this.binPath = binPath; -- -- // Start RMI registry -- try { -- registry.start(); -- } catch (RemoteException e) { -- logger.log(Level.SEVERE, "Unable to start RMI registry", e); -- } -+ this.userInfoBuilder = userInfoBuilder; - } - - @Override -@@ -85,16 +73,14 @@ - Pair data = pool.get(pid); - if (data == null) { - MXBeanConnector connector = null; -- try { -- connector = creator.create(registry, pid, binPath); -- connector.attach(); -- MXBeanConnectionImpl connection = connector.connect(); -- data = new Pair(1, connection); -- } finally { -- if (connector != null) { -- connector.close(); -- } -+ ProcessUserInfo info = userInfoBuilder.build(pid); -+ String username = info.getUsername(); -+ if (username == null) { -+ throw new IOException("Unable to determine owner of " + pid); - } -+ connector = creator.create(pid, username, binPath); -+ MXBeanConnectionImpl connection = connector.connect(); -+ data = new Pair(1, connection); - } else { - data = new Pair<>(data.getFirst() + 1, data.getSecond()); - } -@@ -117,17 +103,9 @@ - } - } - -- public void shutdown() { -- try { -- registry.stop(); -- } catch (RemoteException e) { -- logger.log(Level.SEVERE, "Unable to stop RMI registry", e); -- } -- } -- - static class ConnectorCreator { -- public MXBeanConnector create(RMIRegistry registry, int pid, File binPath) throws IOException, ApplicationException { -- MXBeanConnector connector = new MXBeanConnector(registry, pid, binPath); -+ public MXBeanConnector create(int pid, String user, File binPath) throws IOException, ApplicationException { -+ MXBeanConnector connector = new MXBeanConnector(pid, user, binPath); - return connector; - } - } -diff -urN thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/MXBeanConnector.java thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/MXBeanConnector.java ---- thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/MXBeanConnector.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/MXBeanConnector.java 2014-12-05 14:26:44.817483964 -0500 -@@ -36,40 +36,32 @@ - - package com.redhat.thermostat.utils.management.internal; - --import java.io.Closeable; - import java.io.File; - import java.io.IOException; --import java.rmi.RemoteException; - - import javax.management.MBeanServerConnection; - import javax.management.remote.JMXConnector; - import javax.management.remote.JMXConnectorFactory; - import javax.management.remote.JMXServiceURL; - --import com.redhat.thermostat.agent.RMIRegistry; - import com.redhat.thermostat.common.tools.ApplicationException; - --class MXBeanConnector implements Closeable { -+class MXBeanConnector { - -- private final AgentProxyClient client; - private final JMXConnectionCreator jmxCreator; -+ private final String serviceURL; - -- public MXBeanConnector(RMIRegistry registry, int pid, File binPath) throws IOException, ApplicationException { -- this(new AgentProxyClient(registry, pid, binPath), new JMXConnectionCreator()); -+ public MXBeanConnector(int pid, String user, File binPath) throws IOException, ApplicationException { -+ this(new AgentProxyClient(pid, user, binPath), new JMXConnectionCreator()); - } - - MXBeanConnector(AgentProxyClient client, JMXConnectionCreator jmxCreator) throws IOException, ApplicationException { -- this.client = client; - this.jmxCreator = jmxCreator; -- client.createProxy(); -- } -- -- public synchronized void attach() throws Exception { -- client.attach(); -+ this.serviceURL = client.getJMXServiceURL(); - } - - public synchronized MXBeanConnectionImpl connect() throws IOException { -- JMXServiceURL url = new JMXServiceURL(client.getConnectorAddress()); -+ JMXServiceURL url = new JMXServiceURL(serviceURL); - JMXConnector connection = jmxCreator.create(url); - MBeanServerConnection mbsc = null; - try { -@@ -83,15 +75,6 @@ - return new MXBeanConnectionImpl(connection, mbsc); - } - -- public boolean isAttached() throws RemoteException { -- return client.isAttached(); -- } -- -- @Override -- public synchronized void close() throws IOException { -- client.detach(); -- } -- - static class JMXConnectionCreator { - JMXConnector create(JMXServiceURL url) throws IOException { - return JMXConnectorFactory.connect(url); -diff -urN thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/ProcessUserInfoBuilder.java thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/ProcessUserInfoBuilder.java ---- thermostat-1.0.4.old/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/ProcessUserInfoBuilder.java 1969-12-31 19:00:00.000000000 -0500 -+++ thermostat-1.0.4/agent/core/src/main/java/com/redhat/thermostat/utils/management/internal/ProcessUserInfoBuilder.java 2014-12-05 14:26:44.818483970 -0500 -@@ -0,0 +1,140 @@ -+/* -+ * Copyright 2012, 2013 Red Hat, Inc. -+ * -+ * This file is part of Thermostat. -+ * -+ * Thermostat is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published -+ * by the Free Software Foundation; either version 2, or (at your -+ * option) any later version. -+ * -+ * Thermostat is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with Thermostat; see the file COPYING. If not see -+ * . -+ * -+ * Linking this code with other modules is making a combined work -+ * based on this code. Thus, the terms and conditions of the GNU -+ * General Public License cover the whole combination. -+ * -+ * As a special exception, the copyright holders of this code give -+ * you permission to link this code with independent modules to -+ * produce an executable, regardless of the license terms of these -+ * independent modules, and to copy and distribute the resulting -+ * executable under terms of your choice, provided that you also -+ * meet, for each linked independent module, the terms and conditions -+ * of the license of that module. An independent module is a module -+ * which is not derived from or based on this code. If you modify -+ * this code, you may extend this exception to your version of the -+ * library, but you are not obligated to do so. If you do not wish -+ * to do so, delete this exception statement from your version. -+ */ -+ -+package com.redhat.thermostat.utils.management.internal; -+ -+import java.io.BufferedReader; -+import java.io.IOException; -+import java.io.Reader; -+import java.util.logging.Level; -+import java.util.logging.Logger; -+ -+import com.redhat.thermostat.agent.utils.ProcDataSource; -+import com.redhat.thermostat.agent.utils.username.UserNameLookupException; -+import com.redhat.thermostat.agent.utils.username.UserNameUtil; -+import com.redhat.thermostat.common.utils.LoggingUtils; -+ -+/* -+ * FIXME: This class was copied from system-backend to avoid adding new API. -+ */ -+class ProcessUserInfoBuilder { -+ -+ private static final ProcessUserInfo NON_EXISTENT_USER = new ProcessUserInfo(); -+ private static final String PROC_STATUS_UID = "Uid:"; -+ private static final Logger logger = LoggingUtils.getLogger(ProcessUserInfoBuilder.class); -+ private ProcDataSource source; -+ private UserNameUtil userNameUtil; -+ -+ ProcessUserInfoBuilder(ProcDataSource source, UserNameUtil userNameUtil) { -+ this.source = source; -+ this.userNameUtil = userNameUtil; -+ } -+ -+ static class ProcessUserInfo { -+ -+ private long uid; -+ private String username; -+ -+ ProcessUserInfo(long uid, String username) { -+ this.uid = uid; -+ this.username = username; -+ } -+ -+ ProcessUserInfo() { -+ this.uid = -1; -+ this.username = null; -+ } -+ -+ public long getUid() { -+ return uid; -+ } -+ -+ public String getUsername() { -+ return username; -+ } -+ } -+ -+ ProcessUserInfo build(int pid) { -+ ProcessUserInfo info = NON_EXISTENT_USER; -+ try { -+ Reader reader = source.getStatusReader(pid); -+ long uid = getUidFromProcfs(new BufferedReader(reader)); -+ String name = null; -+ try { -+ name = userNameUtil.getUserName(uid); -+ } catch (UserNameLookupException e) { -+ logger.log(Level.WARNING, "Unable to retrieve username for uid: " + uid, e); -+ } -+ info = new ProcessUserInfo(uid, name); -+ } catch (IOException e) { -+ logger.log(Level.WARNING, "Unable to read user info for " + pid, e); -+ } -+ -+ return info; -+ } -+ -+ /* -+ * Look for the following line: -+ * Uid: -+ */ -+ private long getUidFromProcfs(BufferedReader br) throws IOException { -+ long uid = -1; -+ String line; -+ while ((line = br.readLine()) != null) { -+ line = line.trim(); -+ if (line.startsWith(PROC_STATUS_UID)) { -+ String[] parts = line.split("\\s+"); -+ if (parts.length == 5) { -+ try { -+ // Use Real UID -+ uid = Long.parseLong(parts[1]); -+ } catch (NumberFormatException e) { -+ throw new IOException("Unexpected output from ps command", e); -+ } -+ } -+ else { -+ throw new IOException("Expected 5 parts from split /proc/${pid}/status output, got " + parts.length); -+ } -+ } -+ } -+ if (uid < 0) { -+ throw new IOException("Unable to determine UID from /proc/${pid}/status"); -+ } -+ return uid; -+ } -+ -+ -+} -diff -urN thermostat-1.0.4.old/agent/core/src/test/java/com/redhat/thermostat/agent/internal/ActivatorTest.java thermostat-1.0.4/agent/core/src/test/java/com/redhat/thermostat/agent/internal/ActivatorTest.java ---- thermostat-1.0.4.old/agent/core/src/test/java/com/redhat/thermostat/agent/internal/ActivatorTest.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/core/src/test/java/com/redhat/thermostat/agent/internal/ActivatorTest.java 2014-12-05 14:26:44.818483970 -0500 -@@ -89,7 +89,5 @@ - activator.setPool(pool); - - activator.stop(context); -- -- verify(pool).shutdown(); - } - } -diff -urN thermostat-1.0.4.old/agent/core/src/test/java/com/redhat/thermostat/agent/internal/RMIRegistryImplTest.java thermostat-1.0.4/agent/core/src/test/java/com/redhat/thermostat/agent/internal/RMIRegistryImplTest.java ---- thermostat-1.0.4.old/agent/core/src/test/java/com/redhat/thermostat/agent/internal/RMIRegistryImplTest.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/core/src/test/java/com/redhat/thermostat/agent/internal/RMIRegistryImplTest.java 2014-12-05 14:26:44.819483976 -0500 -@@ -1,122 +1,35 @@ - package com.redhat.thermostat.agent.internal; - --import static org.junit.Assert.assertEquals; --import static org.junit.Assert.assertNull; --import static org.mockito.Matchers.any; --import static org.mockito.Matchers.anyInt; - import static org.mockito.Mockito.mock; --import static org.mockito.Mockito.never; --import static org.mockito.Mockito.verify; --import static org.mockito.Mockito.when; - --import java.io.IOException; --import java.net.InetAddress; - import java.rmi.Remote; - import java.rmi.RemoteException; --import java.rmi.registry.Registry; --import java.rmi.server.RMIClientSocketFactory; --import java.rmi.server.RMIServerSocketFactory; --import java.rmi.server.RMISocketFactory; - - import org.junit.Before; - import org.junit.Test; --import org.mockito.ArgumentCaptor; -- --import com.redhat.thermostat.agent.internal.RMIRegistryImpl.RegistryWrapper; --import com.redhat.thermostat.agent.internal.RMIRegistryImpl.ServerSocketCreator; - - public class RMIRegistryImplTest { - -- private RegistryWrapper wrapper; -- private Registry reg; - private RMIRegistryImpl registry; -- private ServerSocketCreator sockCreator; - - @Before -- public void setup() throws RemoteException { -- wrapper = mock(RegistryWrapper.class); -- reg = mock(Registry.class); -- when(wrapper.createRegistry(anyInt(), any(RMIClientSocketFactory.class), -- any(RMIServerSocketFactory.class))).thenReturn(reg); -- sockCreator = mock(ServerSocketCreator.class); -- -- registry = new RMIRegistryImpl(wrapper, sockCreator); -- } -- -- @Test -- public void testRegistryStart() throws IOException { -- registry.start(); -- -- ArgumentCaptor portCaptor = ArgumentCaptor.forClass(Integer.class); -- ArgumentCaptor csfCaptor = ArgumentCaptor.forClass(RMIClientSocketFactory.class); -- ArgumentCaptor ssfCaptor = ArgumentCaptor.forClass(RMIServerSocketFactory.class); -- verify(wrapper).createRegistry(portCaptor.capture(), csfCaptor.capture(), ssfCaptor.capture()); -- -- // Ensure defaults used for port and client socket factory -- int port = portCaptor.getValue(); -- assertEquals(Registry.REGISTRY_PORT, port); -- -- RMIClientSocketFactory csf = csfCaptor.getValue(); -- assertEquals(RMISocketFactory.getDefaultSocketFactory(), csf); -- -- // Ensure bound to loopback address -- RMIServerSocketFactory ssf = ssfCaptor.getValue(); -- ssf.createServerSocket(port); -- verify(sockCreator).createSocket(port, 0, InetAddress.getLoopbackAddress()); -- } -- -- @Test -- public void testRegistryStop() throws IOException { -- registry.start(); -- -- registry.stop(); -- -- verify(wrapper).destroyRegistry(reg); -- assertNull(registry.getRegistryImpl()); -+ public void setup() throws Exception { -+ registry = new RMIRegistryImpl(); - } - -- @Test -- public void testRegistryStopNotStarted() throws IOException { -- registry.stop(); -- -- verify(wrapper, never()).destroyRegistry(reg); -- } -- -- @Test -+ @Test(expected=RemoteException.class) - public void testGetRegistry() throws Exception { -- Registry stub = mock(Registry.class); -- when(wrapper.getRegistry()).thenReturn(stub); -- assertEquals(stub, registry.getRegistry()); -- } -- -- @Test -- public void testExportObject() throws Exception { -- Remote obj = mock(Remote.class); -- Remote stub = mock(Remote.class); -- when(wrapper.export(obj, 0)).thenReturn(stub); -- -- registry.start(); -- assertEquals(stub, registry.export(obj)); -+ registry.getRegistry(); - } - - @Test(expected=RemoteException.class) -- public void testExportObjectNotStarted() throws Exception { -+ public void testExportObject() throws Exception { - Remote obj = mock(Remote.class); - registry.export(obj); - } - -- @Test -- public void testUnexportObject() throws Exception { -- Remote obj = mock(Remote.class); -- when(wrapper.unexport(obj, true)).thenReturn(true); -- -- registry.start(); -- assertEquals(true, registry.unexport(obj)); -- verify(wrapper).unexport(obj, true); -- } -- - @Test(expected=RemoteException.class) -- public void testUnexportObjectNotStarted() throws Exception { -+ public void testUnexportObject() throws Exception { - Remote obj = mock(Remote.class); - registry.unexport(obj); - } -diff -urN thermostat-1.0.4.old/agent/core/src/test/java/com/redhat/thermostat/utils/management/internal/AgentProxyClientTest.java thermostat-1.0.4/agent/core/src/test/java/com/redhat/thermostat/utils/management/internal/AgentProxyClientTest.java ---- thermostat-1.0.4.old/agent/core/src/test/java/com/redhat/thermostat/utils/management/internal/AgentProxyClientTest.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/core/src/test/java/com/redhat/thermostat/utils/management/internal/AgentProxyClientTest.java 2014-12-05 14:26:44.819483976 -0500 -@@ -37,185 +37,116 @@ - package com.redhat.thermostat.utils.management.internal; - - import static org.junit.Assert.assertEquals; --import static org.junit.Assert.assertTrue; - import static org.junit.Assert.fail; - import static org.mockito.Matchers.any; --import static org.mockito.Mockito.doAnswer; - import static org.mockito.Mockito.mock; - import static org.mockito.Mockito.verify; - import static org.mockito.Mockito.when; - -+import java.io.ByteArrayInputStream; - import java.io.File; - import java.io.IOException; --import java.rmi.RemoteException; --import java.rmi.registry.Registry; --import java.util.concurrent.CountDownLatch; --import java.util.concurrent.TimeUnit; -+import java.util.ArrayList; -+import java.util.List; -+import java.util.logging.Handler; -+import java.util.logging.LogRecord; - - import org.junit.Before; - import org.junit.Test; --import org.mockito.invocation.InvocationOnMock; --import org.mockito.stubbing.Answer; -+import org.mockito.ArgumentCaptor; - --import com.redhat.thermostat.agent.internal.RMIRegistryImpl; --import com.redhat.thermostat.agent.proxy.common.AgentProxyControl; --import com.redhat.thermostat.agent.proxy.common.AgentProxyListener; --import com.redhat.thermostat.agent.proxy.common.AgentProxyLogin; --import com.redhat.thermostat.common.tools.ApplicationException; -+import com.redhat.thermostat.common.utils.LoggingUtils; - import com.redhat.thermostat.utils.management.internal.AgentProxyClient.ProcessCreator; - - public class AgentProxyClientTest { - - private AgentProxyClient client; -- private RMIRegistryImpl rmi; -- private Registry registry; - private ProcessCreator procCreator; -- private CountDownLatch latch; -- private AgentProxyListener listenerStub; -- private AgentProxyLogin proxyLogin; -- private AgentProxyControl proxyControl; -+ private String user; - private File binPath; - - @Before - public void setup() throws Exception { -- rmi = mock(RMIRegistryImpl.class); -- listenerStub = mock(AgentProxyListener.class); -- when(rmi.export(any(AgentProxyListener.class))).thenReturn(listenerStub); -- registry = mock(Registry.class); -- when(rmi.getRegistry()).thenReturn(registry); -- proxyLogin = mock(AgentProxyLogin.class); -- when(registry.lookup(AgentProxyLogin.REMOTE_PREFIX + "0")).thenReturn(proxyLogin); -- proxyControl = mock(AgentProxyControl.class); -- when(proxyLogin.login()).thenReturn(proxyControl); -- - procCreator = mock(ProcessCreator.class); - binPath = new File("/path/to/thermostat/bin"); -- latch = mock(CountDownLatch.class); -+ user = "Hello"; -+ client = new AgentProxyClient(9000, user, binPath, procCreator); - } - - @Test - public void testCreateProxy() throws Exception { -- createClient(); -- -- // Verify listener exported and bound -- verify(rmi).export(client); -- verify(registry).rebind(AgentProxyListener.REMOTE_PREFIX + "0", listenerStub); -- -- // Verify server created -- String progName = "/path/to/thermostat/bin" + File.separator + "thermostat-agent-proxy"; -- verify(procCreator).createAndRunProcess(new String[] { progName, "0" }); -- verify(latch).countDown(); -- -- // Verify listener removed -- verify(registry).unbind(AgentProxyListener.REMOTE_PREFIX + "0"); -- verify(rmi).unexport(client); -- -- // Verify login -- verify(registry).lookup(AgentProxyLogin.REMOTE_PREFIX + "0"); -- verify(proxyLogin).login(); -- -- // Check returned proxy control -- assertEquals(proxyControl, client.getProxy()); -- } -- -- private void createClient() throws InterruptedException, IOException, -- ApplicationException { -- client = new AgentProxyClient(rmi, 0, binPath, latch, procCreator); -- -- doAnswer(new Answer() { -- @Override -- public Boolean answer(InvocationOnMock invocation) throws Throwable { -- // Trigger server started -- client.serverStarted(); -- return true; -- } -- }).when(latch).await(any(Long.class), any(TimeUnit.class)); -- -- client.createProxy(); -+ Process proxy = mock(Process.class); -+ final String jmxUrl = "myJmxUrl"; -+ when(proxy.getInputStream()).thenReturn(new ByteArrayInputStream(jmxUrl.getBytes())); -+ when(proxy.getErrorStream()).thenReturn(new ByteArrayInputStream(new byte[0])); -+ when(procCreator.createAndRunProcess(any(String[].class))).thenReturn(proxy); -+ -+ // Check returned URL -+ String result = client.getJMXServiceURL(); -+ assertEquals(jmxUrl, result); -+ -+ // Check process arguments -+ ArgumentCaptor argsCaptor = ArgumentCaptor.forClass(String[].class); -+ verify(procCreator).createAndRunProcess(argsCaptor.capture()); -+ String[] args = argsCaptor.getValue(); -+ assertEquals(3, args.length); -+ assertEquals("/path/to/thermostat/bin/thermostat-agent-proxy", args[0]); -+ assertEquals("9000", args[1]); -+ assertEquals("Hello", args[2]); -+ -+ // Check cleanup -+ verify(proxy).waitFor(); - } - - @Test -- public void testCreateProxyFailed() throws Exception { -- client = new AgentProxyClient(rmi, 0, binPath, latch, procCreator); -- -- final Exception error = mock(Exception.class); -- doAnswer(new Answer() { -- @Override -- public Boolean answer(InvocationOnMock invocation) throws Throwable { -- // Trigger server started -- client.serverFailedToStart(error); -- return true; -- } -- }).when(latch).await(any(Long.class), any(TimeUnit.class)); -+ public void testErrorHandler() throws Exception { -+ Process proxy = mock(Process.class); -+ final String errors = "This is an error\nThis is also an error\nOh no!\n"; -+ when(proxy.getInputStream()).thenReturn(new ByteArrayInputStream(new byte[0])); -+ when(proxy.getErrorStream()).thenReturn(new ByteArrayInputStream(errors.getBytes())); -+ when(procCreator.createAndRunProcess(any(String[].class))).thenReturn(proxy); -+ -+ List logMessages = new ArrayList<>(); -+ TestLogHandler logHandler = new TestLogHandler(logMessages); -+ LoggingUtils.getLogger(AgentProxyClient.class).addHandler(logHandler); - - try { -- client.createProxy(); -- fail("Expected RemoteException"); -- } catch (RemoteException e) { -- assertEquals(error, e.getCause()); -+ try { -+ client.getJMXServiceURL(); -+ fail("Expected exception"); -+ } catch (IOException e) { -+ // Expected -+ } -+ assertEquals(3, logMessages.size()); -+ assertEquals("This is an error", logMessages.get(0).getMessage()); -+ assertEquals("This is also an error", logMessages.get(1).getMessage()); -+ assertEquals("Oh no!", logMessages.get(2).getMessage()); -+ } finally { -+ LoggingUtils.getLogger(AgentProxyClient.class).removeHandler(logHandler); - } -- -- // Verify listener exported and bound -- verify(rmi).export(client); -- verify(registry).rebind(AgentProxyListener.REMOTE_PREFIX + "0", listenerStub); -- -- // Verify server created -- String progName = "/path/to/thermostat/bin" + File.separator + "thermostat-agent-proxy"; -- verify(procCreator).createAndRunProcess(new String[] { progName, "0" }); -- verify(latch).countDown(); -- -- // Verify listener removed -- verify(registry).unbind(AgentProxyListener.REMOTE_PREFIX + "0"); -- verify(rmi).unexport(client); - } - -- @Test -- public void testCreateProxyTimeout() throws Exception { -- when(latch.await(any(Long.class), any(TimeUnit.class))).thenReturn(false); -- client = new AgentProxyClient(rmi, 0, binPath, latch, procCreator); -+ private static class TestLogHandler extends Handler { - -- try { -- client.createProxy(); -- fail("Expected RemoteException"); -- } catch (RemoteException e) { -- // Verify listener exported and bound -- verify(rmi).export(client); -- verify(registry).rebind(AgentProxyListener.REMOTE_PREFIX + "0", listenerStub); -- -- // Verify server created -- String progName = "/path/to/thermostat/bin" + File.separator + "thermostat-agent-proxy"; -- verify(procCreator).createAndRunProcess(new String[] { progName, "0" }); -- -- // Verify listener removed -- verify(registry).unbind(AgentProxyListener.REMOTE_PREFIX + "0"); -- verify(rmi).unexport(client); -+ private List logMessages; -+ public TestLogHandler(List logMessages) { -+ this.logMessages = logMessages; - } -- } -- -- @Test -- public void testAttach() throws Exception { -- createClient(); - -- client.attach(); -- verify(proxyControl).attach(); -- } -- -- @Test -- public void testIsAttached() throws Exception { -- createClient(); -- when(proxyControl.isAttached()).thenReturn(true); -- -- boolean result = client.isAttached(); -- verify(proxyControl).isAttached(); -- assertTrue(result); -- } -- -- @Test -- public void testDetach() throws Exception { -- createClient(); -+ @Override -+ public void publish(LogRecord record) { -+ logMessages.add(record); -+ } -+ -+ @Override -+ public void flush() { -+ // Do nothing -+ } - -- client.detach(); -- verify(proxyControl).detach(); -+ @Override -+ public void close() throws SecurityException { -+ // Do nothing -+ } - } -- -+ - } -diff -urN thermostat-1.0.4.old/agent/core/src/test/java/com/redhat/thermostat/utils/management/internal/MXBeanConnectionPoolImplTest.java thermostat-1.0.4/agent/core/src/test/java/com/redhat/thermostat/utils/management/internal/MXBeanConnectionPoolImplTest.java ---- thermostat-1.0.4.old/agent/core/src/test/java/com/redhat/thermostat/utils/management/internal/MXBeanConnectionPoolImplTest.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/core/src/test/java/com/redhat/thermostat/utils/management/internal/MXBeanConnectionPoolImplTest.java 2014-12-05 14:26:44.820483982 -0500 -@@ -50,9 +50,9 @@ - - import org.junit.Test; - --import com.redhat.thermostat.agent.internal.RMIRegistryImpl; - import com.redhat.thermostat.agent.utils.management.MXBeanConnection; - import com.redhat.thermostat.utils.management.internal.MXBeanConnectionPoolImpl.ConnectorCreator; -+import com.redhat.thermostat.utils.management.internal.ProcessUserInfoBuilder.ProcessUserInfo; - - public class MXBeanConnectionPoolImplTest { - -@@ -64,20 +64,20 @@ - MXBeanConnector connector = mock(MXBeanConnector.class); - ConnectorCreator creator = mock(ConnectorCreator.class); - -- when(creator.create(any(RMIRegistryImpl.class), anyInt(), any(File.class))).thenReturn(connector); -+ when(creator.create(anyInt(), any(String.class), any(File.class))).thenReturn(connector); - when(connector.connect()).thenReturn(toReturn); - -- RMIRegistryImpl registry = mock(RMIRegistryImpl.class); -- MXBeanConnectionPoolImpl pool = new MXBeanConnectionPoolImpl(creator, registry, binDir); -+ ProcessUserInfoBuilder builder = mock(ProcessUserInfoBuilder.class); -+ ProcessUserInfo info = new ProcessUserInfo(0, "Test"); -+ when(builder.build(0)).thenReturn(info); -+ MXBeanConnectionPoolImpl pool = new MXBeanConnectionPoolImpl(creator, binDir, builder); - - MXBeanConnection connection = pool.acquire(0); - - assertNotNull(connection); - assertEquals(connection, toReturn); - -- verify(connector).attach(); - verify(connector).connect(); -- verify(connector).close(); - } - - @Test -@@ -86,17 +86,17 @@ - MXBeanConnector connector = mock(MXBeanConnector.class); - ConnectorCreator creator = mock(ConnectorCreator.class); - -- when(creator.create(any(RMIRegistryImpl.class), anyInt(), any(File.class))).thenReturn(connector); -+ when(creator.create(anyInt(), any(String.class), any(File.class))).thenReturn(connector); - when(connector.connect()).thenReturn(toReturn); - -- RMIRegistryImpl registry = mock(RMIRegistryImpl.class); -- MXBeanConnectionPoolImpl pool = new MXBeanConnectionPoolImpl(creator, registry, binDir); -+ ProcessUserInfoBuilder builder = mock(ProcessUserInfoBuilder.class); -+ ProcessUserInfo info = new ProcessUserInfo(0, "Test"); -+ when(builder.build(0)).thenReturn(info); -+ MXBeanConnectionPoolImpl pool = new MXBeanConnectionPoolImpl(creator, binDir, builder); - - MXBeanConnection connection1 = pool.acquire(0); - -- verify(connector).attach(); - verify(connector).connect(); -- verify(connector).close(); - - MXBeanConnection connection2 = pool.acquire(0); - -@@ -112,11 +112,13 @@ - MXBeanConnector connector = mock(MXBeanConnector.class); - ConnectorCreator creator = mock(ConnectorCreator.class); - -- when(creator.create(any(RMIRegistryImpl.class), anyInt(), any(File.class))).thenReturn(connector); -+ when(creator.create(anyInt(), any(String.class), any(File.class))).thenReturn(connector); - when(connector.connect()).thenReturn(actualConnection); - -- RMIRegistryImpl registry = mock(RMIRegistryImpl.class); -- MXBeanConnectionPoolImpl pool = new MXBeanConnectionPoolImpl(creator, registry, binDir); -+ ProcessUserInfoBuilder builder = mock(ProcessUserInfoBuilder.class); -+ ProcessUserInfo info = new ProcessUserInfo(0, "Test"); -+ when(builder.build(0)).thenReturn(info); -+ MXBeanConnectionPoolImpl pool = new MXBeanConnectionPoolImpl(creator, binDir, builder); - - MXBeanConnection connection = pool.acquire(0); - -@@ -133,11 +135,13 @@ - MXBeanConnector connector = mock(MXBeanConnector.class); - ConnectorCreator creator = mock(ConnectorCreator.class); - -- when(creator.create(any(RMIRegistryImpl.class), anyInt(), any(File.class))).thenReturn(connector); -+ when(creator.create(anyInt(), any(String.class), any(File.class))).thenReturn(connector); - when(connector.connect()).thenReturn(actualConnection); - -- RMIRegistryImpl registry = mock(RMIRegistryImpl.class); -- MXBeanConnectionPoolImpl pool = new MXBeanConnectionPoolImpl(creator, registry, binDir); -+ ProcessUserInfoBuilder builder = mock(ProcessUserInfoBuilder.class); -+ ProcessUserInfo info = new ProcessUserInfo(0, "Test"); -+ when(builder.build(0)).thenReturn(info); -+ MXBeanConnectionPoolImpl pool = new MXBeanConnectionPoolImpl(creator, binDir, builder); - - // connection1 == connection1 == actualConnection - MXBeanConnection connection1 = pool.acquire(0); -@@ -153,14 +157,4 @@ - - } - -- @Test -- public void testShutdown() throws Exception { -- RMIRegistryImpl registry = mock(RMIRegistryImpl.class); -- ConnectorCreator creator = mock(ConnectorCreator.class); -- MXBeanConnectionPoolImpl pool = new MXBeanConnectionPoolImpl(creator, registry, binDir); -- verify(registry).start(); -- -- pool.shutdown(); -- verify(registry).stop(); -- } - } -diff -urN thermostat-1.0.4.old/agent/core/src/test/java/com/redhat/thermostat/utils/management/internal/MXBeanConnectorTest.java thermostat-1.0.4/agent/core/src/test/java/com/redhat/thermostat/utils/management/internal/MXBeanConnectorTest.java ---- thermostat-1.0.4.old/agent/core/src/test/java/com/redhat/thermostat/utils/management/internal/MXBeanConnectorTest.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/core/src/test/java/com/redhat/thermostat/utils/management/internal/MXBeanConnectorTest.java 2014-12-05 14:26:44.821483988 -0500 -@@ -37,7 +37,6 @@ - package com.redhat.thermostat.utils.management.internal; - - import static org.junit.Assert.assertEquals; --import static org.junit.Assert.assertTrue; - import static org.mockito.Mockito.mock; - import static org.mockito.Mockito.verify; - import static org.mockito.Mockito.when; -@@ -53,6 +52,8 @@ - - public class MXBeanConnectorTest { - -+ private static final String JMX_URL = "service:jmx:rmi://myHost:1099/blah"; -+ - private MXBeanConnector connector; - private JMXConnectionCreator jmxCreator; - private AgentProxyClient client; -@@ -61,47 +62,24 @@ - public void setup() throws Exception { - jmxCreator = mock(JMXConnectionCreator.class); - client = mock(AgentProxyClient.class); -+ when(client.getJMXServiceURL()).thenReturn(JMX_URL); - connector = new MXBeanConnector(client, jmxCreator); - } - - @Test - public void testInit() throws Exception { -- // MXBeanConnector constructor calls createProxy -- verify(client).createProxy(); -- } -- -- @Test -- public void testAttach() throws Exception { -- connector.attach(); -- verify(client).attach(); -- } -- -- @Test -- public void testIsAttached() throws Exception { -- when(client.isAttached()).thenReturn(true); -- boolean result = connector.isAttached(); -- verify(client).isAttached(); -- assertTrue(result); -- } -- -- @Test -- public void testClose() throws Exception { -- connector.close(); -- verify(client).detach(); -+ // MXBeanConnector constructor calls getJMXServiceURL -+ verify(client).getJMXServiceURL(); - } - - @Test - public void testConnect() throws Exception { -- String jmxUrl = "service:jmx:rmi://myHost:1099/blah"; -- when(client.getConnectorAddress()).thenReturn(jmxUrl); -- - JMXConnector jmxConnector = mock(JMXConnector.class); -- when(jmxCreator.create(new JMXServiceURL(jmxUrl))).thenReturn(jmxConnector); -+ when(jmxCreator.create(new JMXServiceURL(JMX_URL))).thenReturn(jmxConnector); - MBeanServerConnection connection = mock(MBeanServerConnection.class); - when(jmxConnector.getMBeanServerConnection()).thenReturn(connection); - - MXBeanConnectionImpl result = connector.connect(); -- verify(client).getConnectorAddress(); - assertEquals(connection, result.get()); - } - -diff -urN thermostat-1.0.4.old/agent/proxy/common/pom.xml thermostat-1.0.4/agent/proxy/common/pom.xml ---- thermostat-1.0.4.old/agent/proxy/common/pom.xml 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/common/pom.xml 1969-12-31 19:00:00.000000000 -0500 -@@ -1,82 +0,0 @@ -- -- -- -- 4.0.0 -- -- -- com.redhat.thermostat -- thermostat-agent-proxy -- 1.0.4 -- -- -- thermostat-agent-proxy-common -- Thermostat Agent Proxy Common -- bundle -- -- -- -- -- org.apache.felix -- maven-bundle-plugin -- true -- -- -- Red Hat, Inc. -- com.redhat.thermostat.agent.proxy.common -- -- com.redhat.thermostat.agent.proxy.common, -- -- -- <_nouses>true -- -- -- -- -- -- -- -- -- com.sun -- tools -- system -- ${java.home}/../lib/tools.jar -- -- -- -- -diff -urN thermostat-1.0.4.old/agent/proxy/common/src/main/java/com/redhat/thermostat/agent/proxy/common/AgentProxyControl.java thermostat-1.0.4/agent/proxy/common/src/main/java/com/redhat/thermostat/agent/proxy/common/AgentProxyControl.java ---- thermostat-1.0.4.old/agent/proxy/common/src/main/java/com/redhat/thermostat/agent/proxy/common/AgentProxyControl.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/common/src/main/java/com/redhat/thermostat/agent/proxy/common/AgentProxyControl.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,85 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.common; -- --import java.rmi.Remote; --import java.rmi.RemoteException; -- --import com.sun.tools.attach.VirtualMachine; -- --/** -- * Remote interface to allow control of a JVM using the Hotspot attach -- * mechanism. -- * -- * This interface invokes remote methods of a delegate Java process -- * which acts as a proxy between Thermostat and the target JVM. This -- * delegate is necessary in order to assume the same user and group IDs -- * as the target JVM. -- */ --public interface AgentProxyControl extends Remote { -- -- /** -- * Attach to the target JVM using {@link VirtualMachine#attach}. -- * @throws RemoteException if the attach fails -- */ -- void attach() throws RemoteException; -- -- /** -- * @return whether the delegate is currently attached to the target -- * JVM. -- * @throws RemoteException if this method fails for any reason -- */ -- boolean isAttached() throws RemoteException; -- -- /** -- * @return an address that can be used to establish a JMX connection -- * to the target JVM. -- * @throws RemoteException if the delegate is not attached to the target -- * VM -- */ -- String getConnectorAddress() throws RemoteException; -- -- /** -- * Detaches from the target JVM that was attached previously using -- * {@link #attach()}, and terminates the remote connection to the -- * delegate Java process. -- * @throws RemoteException if the delegate failed to detach from the VM, -- * or failed to terminate the remote connection -- */ -- void detach() throws RemoteException; -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/common/src/main/java/com/redhat/thermostat/agent/proxy/common/AgentProxyListener.java thermostat-1.0.4/agent/proxy/common/src/main/java/com/redhat/thermostat/agent/proxy/common/AgentProxyListener.java ---- thermostat-1.0.4.old/agent/proxy/common/src/main/java/com/redhat/thermostat/agent/proxy/common/AgentProxyListener.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/common/src/main/java/com/redhat/thermostat/agent/proxy/common/AgentProxyListener.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,70 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.common; -- --import java.rmi.Remote; --import java.rmi.RemoteException; -- --/** -- * Remote interface to allow an implementer of {@link AgentProxyControl} -- * to notify clients when it is available. -- */ --public interface AgentProxyListener extends Remote { -- -- /** -- * By appending the PID of the target JVM, forms the name of -- * the exported remote object implementing this interface for -- * that JVM. -- */ -- public static final String REMOTE_PREFIX = "AgentProxyListener"; -- -- /** -- * To be called when an implementer of {@link AgentProxyControl} -- * has exported itself for use by clients. -- * @throws RemoteException if this method fails for any reason -- */ -- void serverStarted() throws RemoteException; -- -- /** -- * To be called when an implementer of {@link AgentProxyControl} -- * has failed to start. -- * @param error - the cause of the failure -- * @throws RemoteException if this method fails for any reason -- */ -- void serverFailedToStart(Exception error) throws RemoteException; -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/common/src/main/java/com/redhat/thermostat/agent/proxy/common/AgentProxyLogin.java thermostat-1.0.4/agent/proxy/common/src/main/java/com/redhat/thermostat/agent/proxy/common/AgentProxyLogin.java ---- thermostat-1.0.4.old/agent/proxy/common/src/main/java/com/redhat/thermostat/agent/proxy/common/AgentProxyLogin.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/common/src/main/java/com/redhat/thermostat/agent/proxy/common/AgentProxyLogin.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,61 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.common; -- --import java.rmi.Remote; --import java.rmi.RemoteException; -- --public interface AgentProxyLogin extends Remote { -- -- /** -- * By appending the PID of the target JVM, forms the name of -- * the exported remote object implementing this interface for -- * that JVM. -- */ -- public static final String REMOTE_PREFIX = "AgentProxy"; -- -- /** -- * Authenticates using the currently logged in system user, and -- * if successful, returns an object to control the agent proxy. -- * @return a control object for the agent proxy -- * @throws RemoteException if this method fails for some reason -- * @throws SecurityException if the currently logged in user -- * is not authorized to log in -- */ -- AgentProxyControl login() throws RemoteException, SecurityException; -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/pom.xml thermostat-1.0.4/agent/proxy/pom.xml ---- thermostat-1.0.4.old/agent/proxy/pom.xml 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/pom.xml 2014-12-05 14:26:44.822483994 -0500 -@@ -51,7 +51,6 @@ - Thermostat Agent Proxy - - -- common - server - - -diff -urN thermostat-1.0.4.old/agent/proxy/server/Makefile thermostat-1.0.4/agent/proxy/server/Makefile ---- thermostat-1.0.4.old/agent/proxy/server/Makefile 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/Makefile 1969-12-31 19:00:00.000000000 -0500 -@@ -1,41 +0,0 @@ --CC = gcc --JAVAH = javah --MYCFLAGS = -c -Wall -fPIC --MYLDFLAGS = -fPIC -shared --COPY = cp -a -- --CLASSPATH = target/classes --TARGET_DIR = target -- --INCLUDE = -I $(TARGET_DIR) -I $(JAVA_HOME)/include/ -I $(JAVA_HOME)/include/linux --SOURCES = src/main/native/AgentProxy.c --TARGET = $(TARGET_DIR)/AgentProxy.c --OBJECTS = $(TARGET:.c=.o) -- --EXECUTABLE = libAgentProxy.so -- --.PHONY: --JNI_LIST = com.redhat.thermostat.agent.proxy.server.AgentProxyNativeUtils -- --$(JNI_LIST): -- $(JAVAH) -force -classpath $(CLASSPATH) -d $(TARGET_DIR) $(JNI_LIST) -- --all: $(JNI_LIST) init $(SOURCES) $(EXECUTABLE) -- --.PHONY: --init: -- $(COPY) $(SOURCES) $(TARGET) -- --$(EXECUTABLE): $(OBJECTS) -- $(CC) $(OBJECTS) -o $(TARGET_DIR)/$@ $(MYLDFLAGS) $(LDFLAGS) -- --.c.o: -- $(CC) $(MYCFLAGS) $(CFLAGS) $(INCLUDE) $< -o $@ -- --clean-lib: -- rm -f $(TARGET_DIR)/$(EXECUTABLE) -- --clean-obj: -- rm -f $(OBJECTS) $(TARGET) -- --clean: clean-obj clean-lib -diff -urN thermostat-1.0.4.old/agent/proxy/server/pom.xml thermostat-1.0.4/agent/proxy/server/pom.xml ---- thermostat-1.0.4.old/agent/proxy/server/pom.xml 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/pom.xml 2014-12-05 14:26:44.823484000 -0500 -@@ -49,33 +49,6 @@ - Thermostat Agent Proxy Server - - -- -- -- org.codehaus.mojo -- exec-maven-plugin -- 1.2.1 -- -- -- compile -- -- exec -- -- -- -- -- make -- -- all -- -- -- -- JAVA_HOME -- ${java.home} -- -- -- -- -- - - - -@@ -110,11 +83,6 @@ - - - com.redhat.thermostat -- thermostat-agent-proxy-common -- ${project.version} -- -- -- com.redhat.thermostat - thermostat-common-core - ${project.version} - -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlImpl.java thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlImpl.java ---- thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlImpl.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlImpl.java 2014-12-05 14:26:44.823484000 -0500 -@@ -40,9 +40,6 @@ - import java.io.IOException; - import java.rmi.RemoteException; - import java.util.Properties; --import java.util.Set; -- --import javax.security.auth.Subject; - - import com.sun.tools.attach.AgentInitializationException; - import com.sun.tools.attach.AgentLoadException; -@@ -69,58 +66,44 @@ - this.vmUtils = vmUtils; - } - -- void attach(Subject user) throws RemoteException, SecurityException { -- authCheck(user); -- try { -- vm = vmUtils.attach(String.valueOf(pid)); -- attached = true; -- -- Properties props = vm.getAgentProperties(); -- connectorAddress = props.getProperty(CONNECTOR_ADDRESS_PROPERTY); -- if (connectorAddress == null) { -+ void attach() throws AttachNotSupportedException, IOException { -+ vm = vmUtils.attach(String.valueOf(pid)); -+ attached = true; -+ -+ Properties props = vm.getAgentProperties(); -+ connectorAddress = props.getProperty(CONNECTOR_ADDRESS_PROPERTY); -+ if (connectorAddress == null) { -+ String home = null; -+ String agent = null; -+ try { - props = vm.getSystemProperties(); -- String home = props.getProperty("java.home"); -- String agent = home + File.separator + "lib" + File.separator + "management-agent.jar"; -+ home = props.getProperty("java.home"); -+ agent = home + File.separator + "lib" + File.separator + "management-agent.jar"; - vm.loadAgent(agent); -- -+ - props = vm.getAgentProperties(); - connectorAddress = props.getProperty(CONNECTOR_ADDRESS_PROPERTY); -+ } catch (IOException | AgentLoadException | AgentInitializationException e) { -+ throw new RemoteException("Failed to load agent ('" + agent + "', from home '" + home + "') into VM (pid: " + pid + ")", e); - } -- } catch (AttachNotSupportedException | IOException | AgentLoadException | AgentInitializationException e) { -- throw new RemoteException("Failed to attach to VM", e); - } - } - -- boolean isAttached(Subject user) throws RemoteException, SecurityException { -- authCheck(user); -+ boolean isAttached() { - return attached; - } - -- String getConnectorAddress(Subject user) throws RemoteException, SecurityException { -- authCheck(user); -+ String getConnectorAddress() throws IOException { - if (!attached) { -- throw new RemoteException("Agent not attached to target VM"); -+ throw new IOException("Agent not attached to target VM"); - } - return connectorAddress; - } - -- void detach(Subject user) throws RemoteException, SecurityException { -- authCheck(user); -- try { -- if (attached) { -- vm.detach(); -- attached = false; -- } -- } catch (IOException e) { -- throw new RemoteException("Failed to detach from VM", e); -- } -- } -- -- private void authCheck(Subject user) throws SecurityException { -- // If we've added our Principal, we've authenticated this user -- Set principals = user.getPrincipals(AgentProxyPrincipal.class); -- if (principals.isEmpty()) { -- throw new SecurityException("Access Denied"); -+ void detach() throws IOException { -+ if (attached) { -+ vm.detach(); -+ attached = false; - } - } - -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlWrapper.java thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlWrapper.java ---- thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlWrapper.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlWrapper.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,97 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import java.rmi.RemoteException; -- --import javax.security.auth.Subject; --import javax.security.auth.login.LoginException; -- --import com.redhat.thermostat.agent.proxy.common.AgentProxyControl; -- --class AgentProxyControlWrapper implements AgentProxyControl { -- -- private final Subject user; -- private final AgentProxyLoginContext context; -- private final AgentProxyControlImpl impl; -- private final ShutdownListener listener; -- private final RegistryUtils registryUtils; -- -- AgentProxyControlWrapper(Subject user, AgentProxyLoginContext context, AgentProxyControlImpl impl, -- ShutdownListener listener, RegistryUtils registryUtils) { -- this.user = user; -- this.context = context; -- this.impl = impl; -- this.listener = listener; -- this.registryUtils = registryUtils; -- } -- -- @Override -- public void attach() throws RemoteException, SecurityException { -- impl.attach(user); -- } -- -- @Override -- public boolean isAttached() throws RemoteException, SecurityException { -- return impl.isAttached(user); -- } -- -- @Override -- public String getConnectorAddress() throws RemoteException, SecurityException { -- return impl.getConnectorAddress(user); -- } -- -- @Override -- public void detach() throws RemoteException, SecurityException { -- try { -- impl.detach(user); -- } finally { -- try { -- // Removes all Principals -- context.logout(); -- } catch (LoginException e) { -- throw new RemoteException("Failed to log out", e); -- } -- // Unexport this object -- registryUtils.unexportObject(this); -- -- // Shutdown RMI server -- listener.shutdown(); -- } -- } -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxy.java thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxy.java ---- thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxy.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxy.java 2014-12-05 14:26:44.824484006 -0500 -@@ -37,50 +37,21 @@ - package com.redhat.thermostat.agent.proxy.server; - - import java.io.IOException; --import java.rmi.NotBoundException; --import java.rmi.RemoteException; --import java.rmi.registry.Registry; --import java.util.Timer; --import java.util.TimerTask; -+import java.io.PrintStream; - import java.util.logging.Level; - import java.util.logging.Logger; - --import com.redhat.thermostat.agent.proxy.common.AgentProxyListener; --import com.redhat.thermostat.agent.proxy.common.AgentProxyLogin; - import com.redhat.thermostat.common.utils.LoggingUtils; -+import com.sun.tools.attach.AttachNotSupportedException; - - public class AgentProxy { - - private static final Logger logger = LoggingUtils.getLogger(AgentProxy.class); -- private static final long TIMEOUT_MS = 300000L; // 5 minutes should be more than enough -- private static final ShutdownListener shutdownListener = new ShutdownListener() { -- @Override -- public void shutdown() throws RemoteException { -- shutdownProxy(); -- } -- }; -- private static final TimerTask timeoutTask = new TimerTask() { -- @Override -- public void run() { -- try { -- shutdownProxy(); -- logger.warning("Server timed out"); -- } catch (RemoteException e) { -- logger.log(Level.SEVERE, "Exception while shutting down " -- + "timed out server" , e); -- } -- } -- }; -- -- private static String name = null; -+ - private static int pid = -1; -- private static Registry registry = null; -- private static boolean bound = false; -- private static AgentProxyLogin agent = null; -- private static RegistryUtils registryUtils = new RegistryUtils(); -- private static AgentProxyNativeUtils nativeUtils = new AgentProxyNativeUtils(); -- private static ProcessUserInfoBuilder builder = new ProcessUserInfoBuilder(new ProcDataSource()); -- private static Timer timeoutTimer = new Timer(true); -+ private static AgentProxyControlImpl agent = null; -+ private static ControlCreator creator = new ControlCreator(); -+ private static PrintStream outStream = System.out; - - public static void main(String[] args) { - if (args.length < 1) { -@@ -94,87 +65,27 @@ - usage(); - } - -- // Schedule a timeout -- timeoutTimer.schedule(timeoutTask, TIMEOUT_MS); -- -- // Load the native library -- nativeUtils.loadLibrary(); -- -- // Look for registered status listener -- AgentProxyListener listener; -- try { -- String listenerName = AgentProxyListener.REMOTE_PREFIX + String.valueOf(pid); -- registry = registryUtils.getRegistry(); -- listener = (AgentProxyListener) registry.lookup(listenerName); -- } catch (RemoteException e) { -- throw new RuntimeException("Failed to locate registry", e); -- } catch (NotBoundException e) { -- throw new RuntimeException("No listener registered", e); -- } -- - // Start proxy agent -- Exception ex = null; -+ agent = creator.create(pid); -+ - try { -- setupProxy(pid); -- } catch (Exception e) { -- logger.log(Level.SEVERE, "Failed to setup agent proxy for " + pid, e); -- ex = e; -+ agent.attach(); -+ } catch (AttachNotSupportedException | IOException e) { -+ logger.log(Level.SEVERE, "Failed to attach to VM (pid: " + pid + ")", e); -+ return; - } - -- // Notify listener of result - try { -- if (ex == null) { -- // Success -- listener.serverStarted(); -- } -- else { -- // Send exception to client -- listener.serverFailedToStart(ex); -- } -- } catch (RemoteException e) { -- throw new RuntimeException("Failed to notify listener", e); -+ String connectorAddress = agent.getConnectorAddress(); -+ outStream.println(connectorAddress); -+ } catch (IOException e) { -+ logger.log(Level.SEVERE, "Failed to retrieve JMX connection URL", e); - } -- } -- -- private static void setupProxy(int pid) throws Exception { -+ - try { -- UnixCredentials creds; -- try { -- creds = builder.build(pid); -- } catch (IOException e) { -- throw new Exception("Failed to read credentials", e); -- } -- -- try { -- // Set UID/GID to owner of target VM -- nativeUtils.setCredentials(creds.getUid(), creds.getGid()); -- } catch (Exception e) { -- throw new Exception("Failed to set credentials to " + creds.getUid() -- + ":" + creds.getGid() , e); -- } -- -- agent = new AgentProxyLoginImpl(creds, pid, shutdownListener); -- name = AgentProxyLogin.REMOTE_PREFIX + String.valueOf(pid); -- AgentProxyLogin stub = (AgentProxyLogin) registryUtils.exportObject(agent); -- registry.rebind(name, stub); -- bound = true; -- logger.info(name + " bound to RMI registry"); -- } catch (RemoteException e) { -- throw new Exception("Failed to create remote object", e); -- } -- } -- -- private static void shutdownProxy() throws RemoteException { -- // Unbind from RMI registry -- if (bound) { -- try { -- registry.unbind(name); -- registryUtils.unexportObject(agent); -- logger.info(name + " unbound from RMI registry"); -- bound = false; -- } catch (NotBoundException e) { -- throw new RemoteException("Object not bound", e); -- } -+ agent.detach(); -+ } catch (IOException e) { -+ logger.log(Level.WARNING, "Failed to detach from VM (pid: " + pid + ")", e); - } - } - -@@ -182,52 +93,24 @@ - throw new RuntimeException("usage: java " + AgentProxy.class.getName() + " "); - } - -- /* -- * For testing purposes only. -- */ -- static AgentProxyLogin getAgentProxyLogin() { -- return agent; -- } -- -- /* -- * For testing purposes only. -- */ -- static ShutdownListener getShutdownListener() { -- return shutdownListener; -- } -- -- /* -- * For testing purposes only. -- */ -- static boolean isBound() { -- return bound; -- } -- -- /* -- * For testing purposes only. -- */ -- static void setRegistryUtils(RegistryUtils registryUtils) { -- AgentProxy.registryUtils = registryUtils; -+ static class ControlCreator { -+ AgentProxyControlImpl create(int pid) { -+ return new AgentProxyControlImpl(pid); -+ } - } - - /* - * For testing purposes only. - */ -- static void setNativeUtils(AgentProxyNativeUtils nativeUtils) { -- AgentProxy.nativeUtils = nativeUtils; -+ static void setControlCreator(ControlCreator creator) { -+ AgentProxy.creator = creator; - } - - /* - * For testing purposes only. - */ -- static void setProcessUserInfoBuilder(ProcessUserInfoBuilder builder) { -- AgentProxy.builder = builder; -+ static void setOutStream(PrintStream stream) { -+ AgentProxy.outStream = stream; - } - -- /* -- * For testing purposes only. -- */ -- static void setTimeoutTimer(Timer timeoutTimer) { -- AgentProxy.timeoutTimer = timeoutTimer; -- } - } -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginContext.java thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginContext.java ---- thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginContext.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginContext.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,101 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import java.io.IOException; -- --import javax.security.auth.Subject; --import javax.security.auth.callback.Callback; --import javax.security.auth.callback.CallbackHandler; --import javax.security.auth.callback.UnsupportedCallbackException; --import javax.security.auth.login.LoginContext; --import javax.security.auth.login.LoginException; -- --import com.redhat.thermostat.agent.proxy.server.AgentProxyLoginModule.AgentProxyCallback; -- --/* -- * Wraps both of our LoginModules. -- */ --class AgentProxyLoginContext { -- -- private static final String UNIX_LOGIN_MODULE = "UnixLogin"; -- private static final String AGENT_PROXY_LOGIN_MODULE = "AgentProxyLogin"; -- -- private final LoginContext unixContext; -- private final LoginContext context; -- -- AgentProxyLoginContext(Subject user, UnixCredentials creds) throws LoginException { -- this(user, creds, new ContextCreator()); -- } -- -- AgentProxyLoginContext(Subject user, final UnixCredentials creds, ContextCreator creator) throws LoginException { -- unixContext = creator.createContext(UNIX_LOGIN_MODULE, user); -- context = creator.createContext(AGENT_PROXY_LOGIN_MODULE, user, new CallbackHandler() { -- -- @Override -- public void handle(Callback[] callbacks) throws IOException, -- UnsupportedCallbackException { -- for (Callback callback : callbacks) { -- if (callback instanceof AgentProxyCallback) { -- ((AgentProxyCallback) callback).setTargetCredentials(creds); -- } -- } -- } -- }); -- } -- -- void login() throws LoginException { -- unixContext.login(); -- context.login(); -- } -- -- void logout() throws LoginException { -- context.logout(); -- unixContext.logout(); -- } -- -- static class ContextCreator { -- LoginContext createContext(String name, Subject subject) throws LoginException { -- return new LoginContext(name, subject); -- } -- -- LoginContext createContext(String name, Subject subject, CallbackHandler handler) throws LoginException { -- return new LoginContext(name, subject, handler); -- } -- } -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginImpl.java thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginImpl.java ---- thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginImpl.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginImpl.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,90 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import java.rmi.RemoteException; -- --import javax.security.auth.Subject; --import javax.security.auth.login.LoginException; -- --import com.redhat.thermostat.agent.proxy.common.AgentProxyControl; --import com.redhat.thermostat.agent.proxy.common.AgentProxyLogin; -- --class AgentProxyLoginImpl implements AgentProxyLogin { -- -- private final UnixCredentials creds; -- private final AgentProxyControlImpl impl; -- private final ShutdownListener listener; -- private final LoginContextCreator contextCreator; -- private final RegistryUtils registryUtils; -- -- AgentProxyLoginImpl(UnixCredentials creds, int pid, ShutdownListener listener) throws RemoteException { -- this(creds, pid, listener, new LoginContextCreator(), new RegistryUtils()); -- } -- -- AgentProxyLoginImpl(UnixCredentials creds, int pid, ShutdownListener listener, -- LoginContextCreator contextCreator, RegistryUtils registryUtils) throws RemoteException { -- this.creds = creds; -- this.impl = new AgentProxyControlImpl(pid); -- this.listener = listener; -- this.contextCreator = contextCreator; -- this.registryUtils = registryUtils; -- } -- -- @Override -- public AgentProxyControl login() throws RemoteException, SecurityException { -- Subject user = new Subject(); -- try { -- AgentProxyLoginContext context = contextCreator.createContext(user, creds); -- context.login(); -- -- AgentProxyControl control = new AgentProxyControlWrapper(user, context, impl, -- listener, registryUtils); -- AgentProxyControl stub = (AgentProxyControl) registryUtils.exportObject(control); -- return stub; -- } catch (LoginException e) { -- throw new RemoteException("Failed to login", e); -- } -- } -- -- static class LoginContextCreator { -- AgentProxyLoginContext createContext(Subject user, UnixCredentials creds) throws LoginException { -- return new AgentProxyLoginContext(user, creds); -- } -- } -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginModule.java thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginModule.java ---- thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginModule.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginModule.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,239 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import java.io.IOException; --import java.util.Map; --import java.util.Set; --import java.util.concurrent.CountDownLatch; -- --import javax.security.auth.Subject; --import javax.security.auth.callback.Callback; --import javax.security.auth.callback.CallbackHandler; --import javax.security.auth.callback.UnsupportedCallbackException; --import javax.security.auth.login.LoginException; --import javax.security.auth.spi.LoginModule; -- --public class AgentProxyLoginModule implements LoginModule { -- -- private Subject subject; -- private CallbackHandler callbackHandler; -- private AgentProxyPrincipal principal; -- private boolean loggedIn; -- private boolean committed; -- private boolean debug; -- -- interface AgentProxyCallback extends Callback { -- -- void setTargetCredentials(UnixCredentials creds); -- -- } -- -- @Override -- public void initialize(Subject subject, CallbackHandler callbackHandler, -- Map sharedState, Map options) { -- this.subject = subject; -- this.callbackHandler = callbackHandler; -- -- // Check for debug option -- debug = "true".equalsIgnoreCase((String) options.get("debug")); -- } -- -- @Override -- public boolean login() throws LoginException { -- loggedIn = false; -- -- // Get credentials of target process from callback -- UnixCredentials creds = getTargetCredentials(); -- -- // Verify subject's credentials match those of target process -- checkCredentials(creds); -- -- // Add a custom principal to the subject to show we've authenticated -- principal = createPrincipal(); -- if (debug) { -- System.out.println("\t\t[AgentProxyLoginModule]: " + -- "created principal for user: " + principal.getName()); -- } -- -- loggedIn = true; -- return true; -- } -- -- private UnixCredentials getTargetCredentials() throws LoginException { -- final CountDownLatch latch = new CountDownLatch(1); -- final UnixCredentials[] credsContainer = new UnixCredentials[1]; -- -- try { -- callbackHandler.handle(new Callback[] { new AgentProxyCallback() { -- -- @Override -- public void setTargetCredentials(UnixCredentials creds) { -- credsContainer[0] = creds; -- latch.countDown(); -- } -- -- }}); -- -- latch.await(); -- -- return credsContainer[0]; -- } catch (IOException e) { -- throw new LoginException(e.getMessage()); -- } catch (UnsupportedCallbackException e) { -- throw new LoginException(e.getMessage()); -- } catch (InterruptedException e) { -- throw new LoginException("Interrupted"); -- } -- } -- -- @Override -- public boolean commit() throws LoginException { -- committed = false; -- -- if (loggedIn) { -- subject.getPrincipals().add(principal); -- if (debug) { -- System.out.println("\t\t[AgentProxyLoginModule]: " + -- "adding AgentProxyPrincipal to Subject"); -- } -- committed = true; -- } -- return committed; -- } -- -- @Override -- public boolean abort() throws LoginException { -- if (debug) { -- System.out.println("\t\t[AgentProxyLoginModule]: " + -- "aborted authentication attempt"); -- } -- if (!loggedIn) { -- return false; -- } -- else if (loggedIn && !committed) { -- // Clean up state -- loggedIn = false; -- principal = null; -- } -- else { -- // Clean up state & remove principal -- logout(); -- } -- -- return true; -- } -- -- @Override -- public boolean logout() throws LoginException { -- // Remove principal -- subject.getPrincipals().remove(principal); -- if (debug) { -- System.out.println("\t\t[AgentProxyLoginModule]: " + -- "removed principal for user: " + principal.getName()); -- } -- -- // Clean up state -- loggedIn = false; -- committed = false; -- principal = null; -- -- return true; -- } -- -- @SuppressWarnings("restriction") -- private void checkCredentials(UnixCredentials creds) throws LoginException { -- boolean uidOkay = false, gidOkay = false; -- -- // Check UID -- Set userPrincipals = subject.getPrincipals(com.sun.security.auth.UnixNumericUserPrincipal.class); -- if (!userPrincipals.isEmpty()) { -- com.sun.security.auth.UnixNumericUserPrincipal userPrincipal = userPrincipals.iterator().next(); -- if (debug) { -- System.out.println("UnixLoginModule UID: " + userPrincipal.longValue() + ", PID: " + creds.getPid() + ", Owner: " + creds.getUid()); -- } -- if (userPrincipal.longValue() == creds.getUid() || userPrincipal.longValue() == 0) { -- uidOkay = true; -- } -- } -- -- // Check GID -- Set groupPrincipals = subject.getPrincipals(com.sun.security.auth.UnixNumericGroupPrincipal.class); -- for (com.sun.security.auth.UnixNumericGroupPrincipal groupPrincipal : groupPrincipals) { -- if (groupPrincipal.longValue() == creds.getGid() || groupPrincipal.longValue() == 0) { -- gidOkay = true; -- } -- } -- -- if (!uidOkay || !gidOkay) { -- throw new LoginException("Access Denied"); -- } -- } -- -- @SuppressWarnings("restriction") -- private AgentProxyPrincipal createPrincipal() throws LoginException { -- Set userPrincipals = subject.getPrincipals(com.sun.security.auth.UnixPrincipal.class); -- if (userPrincipals.isEmpty()) { -- throw new LoginException("Unable to obtain user ID"); -- } -- -- com.sun.security.auth.UnixPrincipal userPrincipal = userPrincipals.iterator().next(); -- return new AgentProxyPrincipal(userPrincipal.getName()); -- } -- -- /* -- * For testing purposes only. -- */ -- AgentProxyPrincipal getPrincipal() { -- return principal; -- } -- -- /* -- * For testing purposes only. -- */ -- boolean isLoggedIn() { -- return loggedIn; -- } -- -- /* -- * For testing purposes only. -- */ -- boolean isCommitted() { -- return committed; -- } -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyNativeUtils.java thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyNativeUtils.java ---- thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyNativeUtils.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyNativeUtils.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,53 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import com.redhat.thermostat.shared.config.NativeLibraryResolver; --import com.redhat.thermostat.shared.config.internal.CommonPathsImpl; -- --class AgentProxyNativeUtils { -- -- void loadLibrary() { -- // TODO if this used OSGi, then we wouldn't need this line -- NativeLibraryResolver.setCommonPaths(new CommonPathsImpl()); -- String libPath = NativeLibraryResolver.getAbsoluteLibraryPath("AgentProxy"); -- System.load(libPath); -- } -- -- native void setCredentials(long uid, long gid) throws Exception; -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyPrincipal.java thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyPrincipal.java ---- thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyPrincipal.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyPrincipal.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,54 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import java.security.Principal; -- --class AgentProxyPrincipal implements Principal { -- -- private final String name; -- -- AgentProxyPrincipal(String name) { -- this.name = name; -- } -- -- @Override -- public String getName() { -- return name; -- } -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/ProcDataSource.java thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/ProcDataSource.java ---- thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/ProcDataSource.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/ProcDataSource.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,63 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import java.io.FileReader; --import java.io.IOException; --import java.io.Reader; -- --/** -- * Wrapper for files under /proc. See proc(5) for details about this. -- */ --class ProcDataSource { -- -- private static final String PID_STATUS_FILE = "/proc/${pid}/status"; -- -- /** -- * Returns a reader for /proc/$PID/status -- */ -- Reader getStatusReader(int pid) throws IOException { -- return new FileReader(getPidFile(PID_STATUS_FILE, pid)); -- } -- -- private String getPidFile(String fileName, int pid) { -- return fileName.replace("${pid}", Integer.toString(pid)); -- } -- --} -- -- -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/ProcessUserInfoBuilder.java thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/ProcessUserInfoBuilder.java ---- thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/ProcessUserInfoBuilder.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/ProcessUserInfoBuilder.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,105 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import java.io.BufferedReader; --import java.io.IOException; --import java.io.Reader; -- --class ProcessUserInfoBuilder { -- -- private static final String PROC_STATUS_UID = "Uid:"; -- private static final String PROC_STATUS_GID = "Gid:"; -- -- private final ProcDataSource source; -- -- ProcessUserInfoBuilder(ProcDataSource source) { -- this.source = source; -- } -- -- UnixCredentials build(int pid) throws IOException { -- Reader reader = source.getStatusReader(pid); -- UnixCredentials creds = getUidGidFromProcfs(new BufferedReader(reader), pid); -- return creds; -- } -- -- /* -- * Look for the following lines: -- * Uid: -- * Gid: -- */ -- private UnixCredentials getUidGidFromProcfs(BufferedReader br, int pid) throws IOException { -- long uid = -1; -- long gid = -1; -- String line; -- while ((line = br.readLine()) != null) { -- line = line.trim(); -- if (line.startsWith(PROC_STATUS_UID)) { -- uid = parseUidGid(line); -- } -- else if (line.startsWith(PROC_STATUS_GID)) { -- gid = parseUidGid(line); -- } -- } -- if (uid < 0) { -- throw new IOException("Unable to determine UID from /proc/${pid}/status"); -- } -- if (gid < 0) { -- throw new IOException("Unable to determine GID from /proc/${pid}/status"); -- } -- -- return new UnixCredentials(uid, gid, pid); -- } -- -- private long parseUidGid(String line) throws IOException { -- long result = -1; -- String[] parts = line.split("\\s+"); -- if (parts.length == 5) { -- try { -- // Use Effective UID/GID -- result = Long.parseLong(parts[2]); -- } catch (NumberFormatException e) { -- throw new IOException("Unexpected output from ps command", e); -- } -- } -- else { -- throw new IOException("Expected 5 parts from split /proc/${pid}/status output, got " + parts.length); -- } -- return result; -- } -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/RegistryUtils.java thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/RegistryUtils.java ---- thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/RegistryUtils.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/RegistryUtils.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,26 +0,0 @@ --package com.redhat.thermostat.agent.proxy.server; -- --import java.net.InetAddress; --import java.rmi.NoSuchObjectException; --import java.rmi.Remote; --import java.rmi.RemoteException; --import java.rmi.registry.LocateRegistry; --import java.rmi.registry.Registry; --import java.rmi.server.UnicastRemoteObject; -- --class RegistryUtils { -- -- Registry getRegistry() throws RemoteException { -- return LocateRegistry.getRegistry(InetAddress.getLoopbackAddress().getHostName()); -- } -- -- Remote exportObject(Remote obj) throws RemoteException { -- // Single arg method exports stub instead of real object -- return UnicastRemoteObject.exportObject(obj, 0); -- } -- -- void unexportObject(Remote obj) throws NoSuchObjectException { -- UnicastRemoteObject.unexportObject(obj, true); -- } -- --} -\ No newline at end of file -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/ShutdownListener.java thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/ShutdownListener.java ---- thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/ShutdownListener.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/ShutdownListener.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,45 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import java.rmi.RemoteException; -- --interface ShutdownListener { -- -- void shutdown() throws RemoteException; -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/UnixCredentials.java thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/UnixCredentials.java ---- thermostat-1.0.4.old/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/UnixCredentials.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/UnixCredentials.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,63 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --class UnixCredentials { -- -- private final long uid; -- private final long gid; -- private final int pid; -- -- UnixCredentials(long uid, long gid, int pid) { -- this.uid = uid; -- this.gid = gid; -- this.pid = pid; -- } -- -- long getUid() { -- return uid; -- } -- -- long getGid() { -- return gid; -- } -- -- int getPid() { -- return pid; -- } -- --} -\ No newline at end of file -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/main/native/AgentProxy.c thermostat-1.0.4/agent/proxy/server/src/main/native/AgentProxy.c ---- thermostat-1.0.4.old/agent/proxy/server/src/main/native/AgentProxy.c 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/main/native/AgentProxy.c 1969-12-31 19:00:00.000000000 -0500 -@@ -1,75 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --#include "com_redhat_thermostat_agent_proxy_server_AgentProxyNativeUtils.h" -- --#include --#include --#include -- --static jint throw_Exception(JNIEnv *, const char *, const char *); -- --JNIEXPORT void JNICALL --Java_com_redhat_thermostat_agent_proxy_server_AgentProxyNativeUtils_setCredentials( -- JNIEnv *env, jclass splitAgentKlass, jlong uid, jlong gid) { -- int rc; -- char *err; -- -- // Need to setegid before seteuid, or otherwise we've dropped permissions -- // needed to do so. -- rc = setegid(gid); -- if (rc < 0) { -- err = strerror(errno); -- throw_Exception(env, "java/lang/Exception", err); -- } -- -- rc = seteuid(uid); -- if (rc < 0) { -- err = strerror(errno); -- throw_Exception(env, "java/lang/Exception", err); -- } --} -- --static jint throw_Exception(JNIEnv *env, const char *class_name, -- const char *message) { -- jclass class; -- -- class = (*env)->FindClass(env, class_name); -- if (class == NULL) { -- return -1; -- } -- return (*env)->ThrowNew(env, class, message); --} -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlImplTest.java thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlImplTest.java ---- thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlImplTest.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlImplTest.java 2014-12-05 14:26:44.829484036 -0500 -@@ -47,11 +47,9 @@ - import static org.mockito.Mockito.when; - - import java.io.File; --import java.rmi.RemoteException; -+import java.io.IOException; - import java.util.Properties; - --import javax.security.auth.Subject; -- - import org.junit.Before; - import org.junit.Test; - -@@ -84,9 +82,7 @@ - - @Test - public void testAttach() throws Exception { -- Subject subject = new Subject(); -- addPrincipal(subject); -- control.attach(subject); -+ control.attach(); - - verify(vmUtils).attach("0"); - verify(vm, times(2)).getAgentProperties(); -@@ -94,79 +90,36 @@ - verify(vm).loadAgent("/path/to/java/home" + File.separator + "lib" + File.separator + "management-agent.jar"); - } - -- @Test(expected=SecurityException.class) -- public void testAttachDenied() throws Exception { -- Subject subject = new Subject(); -- control.attach(subject); -- } -- - @Test - public void testIsAttached() throws Exception { -- Subject subject = new Subject(); -- addPrincipal(subject); -- -- assertFalse(control.isAttached(subject)); -- control.attach(subject); -- assertTrue(control.isAttached(subject)); -- } -- -- @Test(expected=SecurityException.class) -- public void testIsAttachedDenied() throws Exception { -- Subject subject = new Subject(); -- control.isAttached(subject); -+ assertFalse(control.isAttached()); -+ control.attach(); -+ assertTrue(control.isAttached()); - } - - @Test - public void testGetAddress() throws Exception { -- Subject subject = new Subject(); -- addPrincipal(subject); -- -- control.attach(subject); -- String addr = control.getConnectorAddress(subject); -+ control.attach(); -+ String addr = control.getConnectorAddress(); - assertEquals("myJmxUrl", addr); - } - -- @Test(expected=SecurityException.class) -- public void testGetAddressDenied() throws Exception { -- Subject subject = new Subject(); -- control.getConnectorAddress(subject); -- } -- -- @Test(expected=RemoteException.class) -+ @Test(expected=IOException.class) - public void testGetAddressNotAttached() throws Exception { -- Subject subject = new Subject(); -- addPrincipal(subject); -- -- control.getConnectorAddress(subject); -+ control.getConnectorAddress(); - } - - @Test - public void testDetach() throws Exception { -- Subject subject = new Subject(); -- addPrincipal(subject); -- -- control.attach(subject); -- control.detach(subject); -+ control.attach(); -+ control.detach(); - verify(vm).detach(); - } - - @Test - public void testDetachNotAttached() throws Exception { -- Subject subject = new Subject(); -- addPrincipal(subject); -- -- control.detach(subject); -+ control.detach(); - verify(vm, never()).detach(); - } - -- @Test(expected=SecurityException.class) -- public void testDetachDenied() throws Exception { -- Subject subject = new Subject(); -- control.detach(subject); -- } -- -- private void addPrincipal(Subject subject) { -- subject.getPrincipals().add(new AgentProxyPrincipal("TEST")); -- } -- - } -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlWrapperTest.java thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlWrapperTest.java ---- thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlWrapperTest.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlWrapperTest.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,94 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import static org.mockito.Mockito.mock; --import static org.mockito.Mockito.verify; -- --import javax.security.auth.Subject; -- --import org.junit.Before; --import org.junit.Test; -- --public class AgentProxyControlWrapperTest { -- -- private AgentProxyControlWrapper control; -- private AgentProxyControlImpl impl; -- private Subject user; -- private AgentProxyLoginContext context; -- private ShutdownListener listener; -- private RegistryUtils registryUtils; -- -- @Before -- public void setup() throws Exception { -- user = new Subject(); -- context = mock(AgentProxyLoginContext.class); -- impl = mock(AgentProxyControlImpl.class); -- listener = mock(ShutdownListener.class); -- registryUtils = mock(RegistryUtils.class); -- control = new AgentProxyControlWrapper(user, context, impl, listener, registryUtils); -- } -- -- @Test -- public void testAttach() throws Exception { -- control.attach(); -- verify(impl).attach(user); -- } -- -- @Test -- public void testIsAttached() throws Exception { -- control.isAttached(); -- verify(impl).isAttached(user); -- } -- -- @Test -- public void testGetAddress() throws Exception { -- control.getConnectorAddress(); -- verify(impl).getConnectorAddress(user); -- } -- -- @Test -- public void testDetach() throws Exception { -- control.detach(); -- -- verify(impl).detach(user); -- verify(context).logout(); -- verify(listener).shutdown(); -- verify(registryUtils).unexportObject(control); -- } -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginContextTest.java thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginContextTest.java ---- thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginContextTest.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginContextTest.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,105 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import static org.mockito.Matchers.any; --import static org.mockito.Matchers.eq; --import static org.mockito.Matchers.same; --import static org.mockito.Mockito.mock; --import static org.mockito.Mockito.verify; --import static org.mockito.Mockito.when; -- --import javax.security.auth.Subject; --import javax.security.auth.callback.Callback; --import javax.security.auth.callback.CallbackHandler; --import javax.security.auth.login.LoginContext; -- --import org.junit.Before; --import org.junit.Test; --import org.mockito.ArgumentCaptor; -- --import com.redhat.thermostat.agent.proxy.server.AgentProxyLoginContext.ContextCreator; --import com.redhat.thermostat.agent.proxy.server.AgentProxyLoginModule.AgentProxyCallback; -- --public class AgentProxyLoginContextTest { -- -- private AgentProxyLoginContext context; -- private ContextCreator creator; -- private Subject user; -- private UnixCredentials creds; -- private LoginContext unixContext; -- private LoginContext ourContext; -- -- @Before -- public void setup() throws Exception { -- user = new Subject(); -- creds = new UnixCredentials(9000, 9001, 0); -- creator = mock(ContextCreator.class); -- unixContext = mock(LoginContext.class); -- ourContext = mock(LoginContext.class); -- when(creator.createContext("UnixLogin", user)).thenReturn(unixContext); -- when(creator.createContext(eq("AgentProxyLogin"), same(user), any(CallbackHandler.class))).thenReturn(ourContext); -- context = new AgentProxyLoginContext(user, creds, creator); -- } -- -- @Test -- public void testCreate() throws Exception { -- verify(creator).createContext("UnixLogin", user); -- ArgumentCaptor captor = ArgumentCaptor.forClass(CallbackHandler.class); -- verify(creator).createContext(eq("AgentProxyLogin"), same(user), captor.capture()); -- CallbackHandler handler = captor.getValue(); -- -- AgentProxyCallback callback = mock(AgentProxyCallback.class); -- handler.handle(new Callback[] { callback }); -- verify(callback).setTargetCredentials(creds); -- } -- -- @Test -- public void testLogin() throws Exception { -- context.login(); -- verify(unixContext).login(); -- verify(ourContext).login(); -- } -- -- @Test -- public void testLogout() throws Exception { -- context.logout(); -- verify(ourContext).logout(); -- verify(unixContext).logout(); -- } -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginImplTest.java thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginImplTest.java ---- thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginImplTest.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginImplTest.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,117 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import static org.junit.Assert.assertEquals; --import static org.junit.Assert.assertFalse; --import static org.junit.Assert.assertTrue; --import static org.junit.Assert.fail; --import static org.mockito.Matchers.any; --import static org.mockito.Matchers.same; --import static org.mockito.Mockito.doThrow; --import static org.mockito.Mockito.mock; --import static org.mockito.Mockito.never; --import static org.mockito.Mockito.verify; --import static org.mockito.Mockito.when; -- --import java.rmi.RemoteException; --import java.rmi.registry.Registry; -- --import javax.security.auth.Subject; --import javax.security.auth.login.LoginException; -- --import org.junit.Before; --import org.junit.Test; --import org.mockito.ArgumentCaptor; -- --import com.redhat.thermostat.agent.proxy.common.AgentProxyControl; --import com.redhat.thermostat.agent.proxy.server.AgentProxyLoginImpl.LoginContextCreator; -- --public class AgentProxyLoginImplTest { -- -- private RegistryUtils registryUtils; -- private Registry registry; -- private UnixCredentials creds; -- private LoginContextCreator contextCreator; -- private AgentProxyLoginContext context; -- -- @Before -- public void setup() throws Exception { -- registry = mock(Registry.class); -- registryUtils = mock(RegistryUtils.class); -- when(registryUtils.getRegistry()).thenReturn(registry); -- creds = new UnixCredentials(9000, 9001, 0); -- contextCreator = mock(LoginContextCreator.class); -- context = mock(AgentProxyLoginContext.class); -- when(contextCreator.createContext(any(Subject.class), same(creds))).thenReturn(context); -- } -- -- @Test -- public void testLoginSuccess() throws Exception { -- ShutdownListener listener = mock(ShutdownListener.class); -- AgentProxyLoginImpl proxyLogin = new AgentProxyLoginImpl(creds, 0, listener, contextCreator, registryUtils); -- AgentProxyControl stub = proxyLogin.login(); -- -- ArgumentCaptor captor = ArgumentCaptor.forClass(AgentProxyControl.class); -- verify(registryUtils).exportObject(captor.capture()); -- AgentProxyControl control = captor.getValue(); -- -- assertTrue(control instanceof AgentProxyControlWrapper); -- assertFalse(stub instanceof AgentProxyControlWrapper); -- } -- -- @Test -- public void testLoginFailure() throws Exception { -- ShutdownListener listener = mock(ShutdownListener.class); -- -- // Simulate login failure -- LoginException ex = new LoginException("TEST"); -- doThrow(ex).when(context).login(); -- -- AgentProxyLoginImpl proxyLogin = new AgentProxyLoginImpl(creds, 0, listener, contextCreator, registryUtils); -- -- try { -- proxyLogin.login(); -- fail("Expected exception from login"); -- } catch (RemoteException e) { -- assertEquals(ex, e.getCause()); -- } -- -- verify(registryUtils, never()).exportObject(any(AgentProxyControl.class)); -- } -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginModuleTest.java thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginModuleTest.java ---- thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginModuleTest.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyLoginModuleTest.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,246 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import static org.junit.Assert.assertEquals; --import static org.junit.Assert.assertFalse; --import static org.junit.Assert.assertNotNull; --import static org.junit.Assert.assertNull; --import static org.junit.Assert.assertTrue; --import static org.junit.Assert.fail; --import static org.mockito.Mockito.*; -- --import java.util.HashMap; --import java.util.Set; -- --import javax.security.auth.Subject; --import javax.security.auth.callback.Callback; --import javax.security.auth.callback.CallbackHandler; --import javax.security.auth.login.LoginException; -- --import org.junit.Before; --import org.junit.Test; --import org.mockito.invocation.InvocationOnMock; --import org.mockito.stubbing.Answer; -- --import com.redhat.thermostat.agent.proxy.server.AgentProxyLoginModule.AgentProxyCallback; -- --public class AgentProxyLoginModuleTest { -- -- private AgentProxyLoginModule module; -- private CallbackHandler handler; -- private Subject subject; -- -- @Before -- public void setup() throws Exception { -- module = new AgentProxyLoginModule(); -- subject = new Subject(); -- handler = mock(CallbackHandler.class); -- final UnixCredentials creds = new UnixCredentials(9000, 9001, 0); -- doAnswer(new Answer() { -- @Override -- public Void answer(InvocationOnMock invocation) throws Throwable { -- Callback[] callbacks = (Callback[]) invocation.getArguments()[0]; -- for (Callback callback : callbacks) { -- if (callback instanceof AgentProxyCallback) { -- ((AgentProxyCallback) callback).setTargetCredentials(creds); -- } -- } -- return null; -- } -- }).when(handler).handle(any(Callback[].class)); -- module.initialize(subject, handler, new HashMap(), new HashMap()); -- } -- -- @Test -- public void testLoginSuccess() throws Exception { -- addPrincipals(); -- -- assertTrue(module.login()); -- -- AgentProxyPrincipal principal = module.getPrincipal(); -- assertNotNull(principal); -- assertEquals("TEST", principal.getName()); -- assertTrue(module.isLoggedIn()); -- assertFalse(module.isCommitted()); -- assertTrue(subject.getPrincipals(AgentProxyPrincipal.class).isEmpty()); -- } -- -- @SuppressWarnings("restriction") -- @Test -- public void testLoginBadUid() throws Exception { -- subject.getPrincipals().add(new com.sun.security.auth.UnixPrincipal("TEST")); -- subject.getPrincipals().add(new com.sun.security.auth.UnixNumericUserPrincipal(8000)); -- subject.getPrincipals().add(new com.sun.security.auth.UnixNumericGroupPrincipal(9001, true)); -- -- verifyFailedLogin(); -- } -- -- @SuppressWarnings("restriction") -- @Test -- public void testLoginMissingUid() throws Exception { -- subject.getPrincipals().add(new com.sun.security.auth.UnixPrincipal("TEST")); -- subject.getPrincipals().add(new com.sun.security.auth.UnixNumericGroupPrincipal(9001, true)); -- -- verifyFailedLogin(); -- } -- -- @SuppressWarnings("restriction") -- @Test -- public void testLoginBadGid() throws Exception { -- subject.getPrincipals().add(new com.sun.security.auth.UnixPrincipal("TEST")); -- subject.getPrincipals().add(new com.sun.security.auth.UnixNumericUserPrincipal(9000)); -- subject.getPrincipals().add(new com.sun.security.auth.UnixNumericGroupPrincipal(8001, true)); -- -- verifyFailedLogin(); -- } -- -- @SuppressWarnings("restriction") -- @Test -- public void testLoginMissingGid() throws Exception { -- subject.getPrincipals().add(new com.sun.security.auth.UnixPrincipal("TEST")); -- subject.getPrincipals().add(new com.sun.security.auth.UnixNumericUserPrincipal(9000)); -- -- verifyFailedLogin(); -- } -- -- @SuppressWarnings("restriction") -- @Test -- public void testLoginMissingUsername() throws Exception { -- subject.getPrincipals().add(new com.sun.security.auth.UnixNumericUserPrincipal(9000)); -- subject.getPrincipals().add(new com.sun.security.auth.UnixNumericGroupPrincipal(9001, true)); -- -- verifyFailedLogin(); -- } -- -- @Test -- public void testCommitSuccess() throws Exception { -- addPrincipals(); -- -- assertTrue(module.login()); -- assertTrue(module.commit()); -- -- assertTrue(module.isLoggedIn()); -- assertTrue(module.isCommitted()); -- Set principals = subject.getPrincipals(AgentProxyPrincipal.class); -- assertFalse(principals.isEmpty()); -- assertEquals(module.getPrincipal(), principals.iterator().next()); -- } -- -- @Test -- public void testCommitNotLoggedIn() throws Exception { -- addPrincipals(); -- -- assertFalse(module.commit()); -- -- assertFalse(module.isLoggedIn()); -- assertFalse(module.isCommitted()); -- assertTrue(subject.getPrincipals(AgentProxyPrincipal.class).isEmpty()); -- } -- -- @Test -- public void testAbortNotLoggedIn() throws Exception { -- addPrincipals(); -- -- assertFalse(module.abort()); -- -- verifyStateReset(); -- } -- -- @Test -- public void testAbortNotCommitted() throws Exception { -- addPrincipals(); -- -- assertTrue(module.login()); -- assertTrue(module.abort()); -- -- verifyStateReset(); -- } -- -- @Test -- public void testAbortCommitted() throws Exception { -- addPrincipals(); -- -- assertTrue(module.login()); -- assertTrue(module.commit()); -- assertTrue(module.abort()); -- -- verifyStateReset(); -- } -- -- @Test -- public void testLogout() throws Exception { -- addPrincipals(); -- -- assertTrue(module.login()); -- assertTrue(module.commit()); -- assertTrue(module.logout()); -- -- verifyStateReset(); -- } -- -- @SuppressWarnings("restriction") -- private void addPrincipals() { -- subject.getPrincipals().add(new com.sun.security.auth.UnixPrincipal("TEST")); -- subject.getPrincipals().add(new com.sun.security.auth.UnixNumericUserPrincipal(9000)); -- subject.getPrincipals().add(new com.sun.security.auth.UnixNumericGroupPrincipal(9001, true)); -- } -- -- private void verifyFailedLogin() { -- try { -- module.login(); -- fail("Expected LoginException"); -- } catch (LoginException e) { -- assertFalse(module.isLoggedIn()); -- assertNull(module.getPrincipal()); -- assertFalse(module.isCommitted()); -- assertTrue(subject.getPrincipals(AgentProxyPrincipal.class).isEmpty()); -- } -- } -- -- @SuppressWarnings("restriction") -- private void verifyStateReset() { -- assertFalse(module.isLoggedIn()); -- assertFalse(module.isCommitted()); -- assertNull(module.getPrincipal()); -- assertTrue(subject.getPrincipals(AgentProxyPrincipal.class).isEmpty()); -- assertFalse(subject.getPrincipals(com.sun.security.auth.UnixPrincipal.class).isEmpty()); -- assertFalse(subject.getPrincipals(com.sun.security.auth.UnixNumericUserPrincipal.class).isEmpty()); -- assertFalse(subject.getPrincipals(com.sun.security.auth.UnixNumericGroupPrincipal.class).isEmpty()); -- } -- --} -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyTest.java thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyTest.java ---- thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyTest.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/AgentProxyTest.java 2014-12-05 14:26:44.831484048 -0500 -@@ -36,106 +36,99 @@ - - package com.redhat.thermostat.agent.proxy.server; - --import static org.junit.Assert.assertEquals; --import static org.junit.Assert.assertFalse; --import static org.junit.Assert.assertTrue; --import static org.mockito.Matchers.any; - import static org.mockito.Mockito.doThrow; - import static org.mockito.Mockito.mock; -+import static org.mockito.Mockito.never; - import static org.mockito.Mockito.verify; - import static org.mockito.Mockito.when; - --import java.rmi.RemoteException; --import java.rmi.registry.Registry; --import java.util.Timer; --import java.util.TimerTask; -+import java.io.IOException; -+import java.io.PrintStream; - -+import org.junit.After; - import org.junit.Before; - import org.junit.Test; --import org.mockito.ArgumentCaptor; - --import com.redhat.thermostat.agent.proxy.common.AgentProxyListener; --import com.redhat.thermostat.agent.proxy.common.AgentProxyLogin; -+import com.redhat.thermostat.agent.proxy.server.AgentProxy.ControlCreator; - - public class AgentProxyTest { - -- private AgentProxyNativeUtils nativeUtils; -- private RegistryUtils registryUtils; -- private Registry registry; -- private AgentProxyLogin loginStub; -- private AgentProxyListener listener; -- private Timer timeoutTimer; -+ private static final String JMX_URL = "service:jmx:rmi://myHost:1099/blah"; -+ -+ private AgentProxyControlImpl control; -+ private PrintStream outStream; - - @Before - public void setup() throws Exception { -- registry = mock(Registry.class); -- listener = mock(AgentProxyListener.class); -- when(registry.lookup(AgentProxyListener.REMOTE_PREFIX + "0")).thenReturn(listener); -- registryUtils = mock(RegistryUtils.class); -- when(registryUtils.getRegistry()).thenReturn(registry); -- loginStub = mock(AgentProxyLogin.class); -- when(registryUtils.exportObject(any(AgentProxyLogin.class))).thenReturn(loginStub); -- -- nativeUtils = mock(AgentProxyNativeUtils.class); -- ProcessUserInfoBuilder builder = mock(ProcessUserInfoBuilder.class); -- when(builder.build(0)).thenReturn(new UnixCredentials(9000, 9001, 0)); -- timeoutTimer = mock(Timer.class); -- AgentProxy.setRegistryUtils(registryUtils); -- AgentProxy.setNativeUtils(nativeUtils); -- AgentProxy.setProcessUserInfoBuilder(builder); -- AgentProxy.setTimeoutTimer(timeoutTimer); -+ ControlCreator creator = mock(ControlCreator.class); -+ control = mock(AgentProxyControlImpl.class); -+ when(control.getConnectorAddress()).thenReturn(JMX_URL); -+ outStream = mock(PrintStream.class); -+ when(creator.create(0)).thenReturn(control); -+ AgentProxy.setControlCreator(creator); -+ AgentProxy.setOutStream(outStream); -+ } -+ -+ @After -+ public void teardown() throws Exception { -+ AgentProxy.setControlCreator(new ControlCreator()); -+ AgentProxy.setOutStream(System.out); - } - - @Test - public void testMainSuccess() throws Exception { -- assertFalse(AgentProxy.isBound()); -- - // Invoke main with PID of 0 - AgentProxy.main(new String[] { "0" }); - -- assertTrue(AgentProxy.isBound()); -- -- // Verify timeout set -- verify(timeoutTimer).schedule(any(TimerTask.class), any(Long.class)); -- -- // Verify native library loaded and credentials properly set -- verify(nativeUtils).loadLibrary(); -- verify(nativeUtils).setCredentials(9000, 9001); -+ verify(control).attach(); -+ verify(control).getConnectorAddress(); -+ verify(control).detach(); -+ verify(outStream).println(JMX_URL); -+ } -+ -+ @Test -+ public void testMainAttachFails() throws Exception { -+ // Simulate failure binding the login object -+ doThrow(new IOException()).when(control).attach(); - -- // Verify login object exported -- AgentProxyLogin proxyLogin = AgentProxy.getAgentProxyLogin(); -- verify(registryUtils).exportObject(proxyLogin); -- verify(registry).rebind(AgentProxyLogin.REMOTE_PREFIX + "0", loginStub); -+ // Invoke main with PID of 0 -+ AgentProxy.main(new String[] { "0" }); - -- // Verify listener notified with positive response -- verify(listener).serverStarted(); -+ verify(control).attach(); -+ verify(control, never()).getConnectorAddress(); -+ verify(control, never()).detach(); -+ verify(outStream, never()).println(JMX_URL); -+ } -+ -+ @Test -+ public void testMainGetAddressFails() throws Exception { -+ // Simulate failure binding the login object -+ doThrow(new IOException()).when(control).getConnectorAddress(); - -- // Shutdown server -- ShutdownListener shutdownListener = AgentProxy.getShutdownListener(); -- shutdownListener.shutdown(); -+ // Invoke main with PID of 0 -+ AgentProxy.main(new String[] { "0" }); - -- // Verify login object unexported -- verify(registry).unbind(AgentProxyLogin.REMOTE_PREFIX + "0"); -- verify(registryUtils).unexportObject(proxyLogin); -+ verify(control).attach(); -+ verify(control).getConnectorAddress(); - -- assertFalse(AgentProxy.isBound()); -+ // Should detach, but not print URL -+ verify(control).detach(); -+ verify(outStream, never()).println(JMX_URL); - } - - @Test -- public void testMainFailure() throws Exception { -+ public void testMainDetachFails() throws Exception { - // Simulate failure binding the login object -- RemoteException ex = new RemoteException("TEST"); -- doThrow(ex).when(registry).rebind(AgentProxyLogin.REMOTE_PREFIX + "0", loginStub); -+ doThrow(new IOException()).when(control).detach(); - - // Invoke main with PID of 0 - AgentProxy.main(new String[] { "0" }); - -- // Verify listener notified with negative response -- ArgumentCaptor errorCaptor = ArgumentCaptor.forClass(Exception.class); -- verify(listener).serverFailedToStart(errorCaptor.capture()); -- assertEquals(ex, errorCaptor.getValue().getCause()); -- -- assertFalse(AgentProxy.isBound()); -+ // All should be called -+ verify(control).attach(); -+ verify(control).getConnectorAddress(); -+ verify(control).detach(); -+ verify(outStream).println(JMX_URL); - } - - } -diff -urN thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/ProcessUserInfoBuilderTest.java thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/ProcessUserInfoBuilderTest.java ---- thermostat-1.0.4.old/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/ProcessUserInfoBuilderTest.java 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/agent/proxy/server/src/test/java/com/redhat/thermostat/agent/proxy/server/ProcessUserInfoBuilderTest.java 1969-12-31 19:00:00.000000000 -0500 -@@ -1,84 +0,0 @@ --/* -- * Copyright 2012, 2013 Red Hat, Inc. -- * -- * This file is part of Thermostat. -- * -- * Thermostat is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published -- * by the Free Software Foundation; either version 2, or (at your -- * option) any later version. -- * -- * Thermostat is distributed in the hope that it will be useful, but -- * WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with Thermostat; see the file COPYING. If not see -- * . -- * -- * Linking this code with other modules is making a combined work -- * based on this code. Thus, the terms and conditions of the GNU -- * General Public License cover the whole combination. -- * -- * As a special exception, the copyright holders of this code give -- * you permission to link this code with independent modules to -- * produce an executable, regardless of the license terms of these -- * independent modules, and to copy and distribute the resulting -- * executable under terms of your choice, provided that you also -- * meet, for each linked independent module, the terms and conditions -- * of the license of that module. An independent module is a module -- * which is not derived from or based on this code. If you modify -- * this code, you may extend this exception to your version of the -- * library, but you are not obligated to do so. If you do not wish -- * to do so, delete this exception statement from your version. -- */ -- --package com.redhat.thermostat.agent.proxy.server; -- --import static org.junit.Assert.assertEquals; --import static org.mockito.Matchers.anyInt; --import static org.mockito.Mockito.mock; --import static org.mockito.Mockito.when; -- --import java.io.IOException; --import java.io.StringReader; -- --import org.junit.Test; -- --import com.redhat.thermostat.common.tools.ApplicationException; -- --public class ProcessUserInfoBuilderTest { -- -- @Test -- public void testBuild() throws IOException { -- StringReader reader = new StringReader("Uid: 2000 2000 2000 2000\nGid: 2001 2001 2001 2001"); -- ProcDataSource source = mock(ProcDataSource.class); -- when(source.getStatusReader(anyInt())).thenReturn(reader); -- ProcessUserInfoBuilder builder = new ProcessUserInfoBuilder(source); -- UnixCredentials creds = builder.build(1); -- -- assertEquals(2000, creds.getUid()); -- assertEquals(2001, creds.getGid()); -- assertEquals(1, creds.getPid()); -- } -- -- @Test(expected=IOException.class) -- public void testBuildErrorUid() throws IOException, ApplicationException { -- StringReader reader = new StringReader("Gid: 2001 2001 2001 2001"); -- ProcDataSource source = mock(ProcDataSource.class); -- when(source.getStatusReader(anyInt())).thenReturn(reader); -- ProcessUserInfoBuilder builder = new ProcessUserInfoBuilder(source); -- builder.build(0); -- } -- -- @Test(expected=IOException.class) -- public void testBuildErrorGid() throws IOException, ApplicationException { -- StringReader reader = new StringReader("Uid: 2000 2000 2000 2000"); -- ProcDataSource source = mock(ProcDataSource.class); -- when(source.getStatusReader(anyInt())).thenReturn(reader); -- ProcessUserInfoBuilder builder = new ProcessUserInfoBuilder(source); -- builder.build(0); -- } -- --} -diff -urN thermostat-1.0.4.old/distribution/assembly/core-assembly.xml thermostat-1.0.4/distribution/assembly/core-assembly.xml ---- thermostat-1.0.4.old/distribution/assembly/core-assembly.xml 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/distribution/assembly/core-assembly.xml 2014-12-05 14:26:44.832484054 -0500 -@@ -59,7 +59,6 @@ - com.redhat.thermostat:thermostat-agent-core - com.redhat.thermostat:thermostat-agent-cli - com.redhat.thermostat:thermostat-agent-command -- com.redhat.thermostat:thermostat-agent-proxy-common - com.redhat.thermostat:thermostat-agent-proxy-server - com.redhat.thermostat:thermostat-killvm-agent - com.redhat.thermostat:thermostat-killvm-client-swing -diff -urN thermostat-1.0.4.old/distribution/config/agent_proxy_jaas.conf thermostat-1.0.4/distribution/config/agent_proxy_jaas.conf ---- thermostat-1.0.4.old/distribution/config/agent_proxy_jaas.conf 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/distribution/config/agent_proxy_jaas.conf 1969-12-31 19:00:00.000000000 -0500 -@@ -1,7 +0,0 @@ --UnixLogin { -- com.sun.security.auth.module.UnixLoginModule required debug=false; --}; -- --AgentProxyLogin { -- com.redhat.thermostat.agent.proxy.server.AgentProxyLoginModule required debug=false; --}; -diff -urN thermostat-1.0.4.old/distribution/config/commands/agent.properties thermostat-1.0.4/distribution/config/commands/agent.properties ---- thermostat-1.0.4.old/distribution/config/commands/agent.properties 2014-12-05 14:25:26.298012971 -0500 -+++ thermostat-1.0.4/distribution/config/commands/agent.properties 2014-12-05 14:26:44.833484060 -0500 -@@ -8,7 +8,6 @@ - com.redhat.thermostat.process=${project.version}, \ - com.redhat.thermostat.common.core=${project.version}, \ - com.redhat.thermostat.agent.cli=${project.version}, \ -- com.redhat.thermostat.agent.proxy.common=${project.version}, \ - com.redhat.thermostat.common.command=${project.version}, \ - com.redhat.thermostat.agent.command=${project.version}, \ - com.redhat.thermostat.killvm.agent=${project.version}, \ -diff -urN thermostat-1.0.4.old/distribution/config/commands/service.properties thermostat-1.0.4/distribution/config/commands/service.properties ---- thermostat-1.0.4.old/distribution/config/commands/service.properties 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/distribution/config/commands/service.properties 2014-12-05 14:26:44.833484060 -0500 -@@ -10,7 +10,6 @@ - com.redhat.thermostat.agent.command=${project.version}, \ - com.redhat.thermostat.storage.cli=${project.version}, \ - com.redhat.thermostat.agent.cli=${project.version}, \ -- com.redhat.thermostat.agent.proxy.common=${project.version}, \ - org.jboss.netty=${netty.version} - - description = starts and stops the thermostat storage and agent -diff -urN thermostat-1.0.4.old/distribution/pom.xml thermostat-1.0.4/distribution/pom.xml ---- thermostat-1.0.4.old/distribution/pom.xml 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/distribution/pom.xml 2014-12-05 14:26:44.834484066 -0500 -@@ -145,7 +145,6 @@ - thermostat-users.properties - thermostat-roles.properties - thermostat_jaas.conf -- agent_proxy_jaas.conf - db.properties - logging.properties - osgi-export.properties -@@ -209,8 +208,6 @@ - todir="${project.build.directory}/image/libs/native" /> - -- - - -diff -urN thermostat-1.0.4.old/distribution/scripts/thermostat thermostat-1.0.4/distribution/scripts/thermostat ---- thermostat-1.0.4.old/distribution/scripts/thermostat 2014-12-05 14:25:46.545134421 -0500 -+++ thermostat-1.0.4/distribution/scripts/thermostat 2014-12-05 14:26:44.834484066 -0500 -@@ -60,8 +60,6 @@ - SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_LIBS}/thermostat-launcher-@project.version@.jar" - SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_LIBS}/thermostat-main-@project.version@.jar" - SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_LIBS}/thermostat-shared-config-@project.version@.jar" --# This needs to be on the classpath for the RMI registry to find it --SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_LIBS}/thermostat-agent-proxy-common-@project.version@.jar" - SERVICE_CLASSPATH="${TOOLS_JAR}:${SERVICE_CLASSPATH}" - - THERMOSTAT_MAIN="com.redhat.thermostat.main.Thermostat" -diff -urN thermostat-1.0.4.old/distribution/scripts/thermostat-agent-proxy thermostat-1.0.4/distribution/scripts/thermostat-agent-proxy ---- thermostat-1.0.4.old/distribution/scripts/thermostat-agent-proxy 2014-06-02 14:46:53.000000000 -0400 -+++ thermostat-1.0.4/distribution/scripts/thermostat-agent-proxy 2014-12-05 14:26:44.835484072 -0500 -@@ -40,6 +40,10 @@ - JAVA_DIR="@java.dir@" - JAVA="@java.home@/bin/java" - -+if [ "$#" -lt 2 ]; then -+ echo "usage: $0 " >&2 -+fi -+ - if [ x"$THERMOSTAT_INSTALL_DIR" = x ] ; then - THERMOSTAT_INSTALL_DIR="@thermostat.home@" - fi -@@ -56,19 +60,20 @@ - # JARs necessary for the server - SERVICE_CLASSPATH="${THERMOSTAT_LIBS}/thermostat-common-core-@project.version@.jar" - SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_LIBS}/thermostat-shared-config-@project.version@.jar" --SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_LIBS}/thermostat-agent-proxy-common-@project.version@.jar" - SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_LIBS}/thermostat-agent-proxy-server-@project.version@.jar" - SERVICE_CLASSPATH="${TOOLS_JAR}:${SERVICE_CLASSPATH}" - - AGENT_PROXY_CLASS="com.redhat.thermostat.agent.proxy.server.AgentProxy" - --JAAS_CONFIG="${THERMOSTAT_HOME}/etc/agent_proxy_jaas.conf" -- - # Set this to remote debug - if [ x"$THERMOSTAT_DEBUG" != x ] ; then - DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=1082" - fi - - # Start server --${JAVA} -cp ${SERVICE_CLASSPATH} ${DEBUG_OPTS} "-Djava.security.auth.login.config=${JAAS_CONFIG}" \ --"-Djava.rmi.server.randomIDs=true" ${AGENT_PROXY_CLASS} "$1" -+# Drop permissions, if root -+if [ "$(/bin/id -u)" -eq 0 ]; then -+ /bin/su "$2" -c "${JAVA} -cp ${SERVICE_CLASSPATH} ${DEBUG_OPTS} ${AGENT_PROXY_CLASS} $1" -+else -+ ${JAVA} -cp ${SERVICE_CLASSPATH} ${DEBUG_OPTS} ${AGENT_PROXY_CLASS} $1 -+fi diff --git a/SOURCES/fix_bundle_loading.patch b/SOURCES/fix_bundle_loading.patch index feb564b..7285b9a 100644 --- a/SOURCES/fix_bundle_loading.patch +++ b/SOURCES/fix_bundle_loading.patch @@ -1,3 +1,38 @@ +# HG changeset patch +# Parent 5d0c366a0fbe751f2185d3cdda3aae293da98611 +diff --git a/dev/multi-module-plugin-archetype/src/main/resources/archetype-resources/distribution/thermostat-plugin.xml b/dev/multi-module-plugin-archetype/src/main/resources/archetype-resources/distribution/thermostat-plugin.xml +--- a/dev/multi-module-plugin-archetype/src/main/resources/archetype-resources/distribution/thermostat-plugin.xml ++++ b/dev/multi-module-plugin-archetype/src/main/resources/archetype-resources/distribution/thermostat-plugin.xml +@@ -39,6 +39,7 @@ + org.apache.commons.logging${symbol_dollar}{commons-logging.version} + org.apache.httpcomponents.httpcore${symbol_dollar}{httpcomponents.core.version} + org.apache.httpcomponents.httpclient${symbol_dollar}{httpcomponents.client.version} ++ org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${symbol_dollar}{gson.version} + +diff --git a/dev/schema-info-command/distribution/thermostat-plugin.xml b/dev/schema-info-command/distribution/thermostat-plugin.xml +--- a/dev/schema-info-command/distribution/thermostat-plugin.xml ++++ b/dev/schema-info-command/distribution/thermostat-plugin.xml +@@ -62,6 +62,7 @@ + com.redhat.thermostat.web.client${project.version} + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} ++ org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + org.mongodb.mongo-java-driver${mongo-driver.osgi-version} + +diff --git a/distribution/config/commands/agent-info.properties b/distribution/config/commands/agent-info.properties +--- a/distribution/config/commands/agent-info.properties ++++ b/distribution/config/commands/agent-info.properties +@@ -4,6 +4,7 @@ + com.redhat.thermostat.web.client=${project.version}, \ + org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ + org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ ++ org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ + ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ + com.google.gson=${gson.version}, \ + org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ diff --git a/distribution/config/commands/agent.properties b/distribution/config/commands/agent.properties --- a/distribution/config/commands/agent.properties +++ b/distribution/config/commands/agent.properties @@ -6,9 +41,9 @@ diff --git a/distribution/config/commands/agent.properties b/distribution/config org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ + ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ com.google.gson=${gson.version}, \ com.redhat.thermostat.process=${project.version}, \ - com.redhat.thermostat.common.core=${project.version}, \ diff --git a/distribution/config/commands/clean-data.properties b/distribution/config/commands/clean-data.properties --- a/distribution/config/commands/clean-data.properties +++ b/distribution/config/commands/clean-data.properties @@ -17,9 +52,9 @@ diff --git a/distribution/config/commands/clean-data.properties b/distribution/c org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ + ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ com.google.gson=${gson.version}, \ org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ - org.apache.commons.beanutils=${commons-beanutils.version}, \ diff --git a/distribution/config/commands/connect.properties b/distribution/config/commands/connect.properties --- a/distribution/config/commands/connect.properties +++ b/distribution/config/commands/connect.properties @@ -28,24 +63,36 @@ diff --git a/distribution/config/commands/connect.properties b/distribution/conf org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ + ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ com.google.gson=${gson.version} - description = persistently connect to storage diff --git a/distribution/config/commands/gui.properties b/distribution/config/commands/gui.properties --- a/distribution/config/commands/gui.properties +++ b/distribution/config/commands/gui.properties -@@ -20,7 +20,10 @@ +@@ -19,8 +19,11 @@ com.redhat.thermostat.process=${project.version}, \ org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ -- org.jboss.netty=${netty.version} + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ + ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ +- org.jboss.netty=${netty.version} + org.jboss.netty=${netty.version}, \ + org.jfree.jcommon=${jcommon.osgi.version} , \ + org.jfree.jfreechart=${jfreechart.osgi.version} description = launches the GUI client +diff --git a/distribution/config/commands/list-agents.properties b/distribution/config/commands/list-agents.properties +--- a/distribution/config/commands/list-agents.properties ++++ b/distribution/config/commands/list-agents.properties +@@ -4,6 +4,7 @@ + com.redhat.thermostat.web.client=${project.version}, \ + org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ + org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ ++ org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ + ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ + com.google.gson=${gson.version}, \ + org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ diff --git a/distribution/config/commands/list-vms.properties b/distribution/config/commands/list-vms.properties --- a/distribution/config/commands/list-vms.properties +++ b/distribution/config/commands/list-vms.properties @@ -54,9 +101,9 @@ diff --git a/distribution/config/commands/list-vms.properties b/distribution/con org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ + ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ com.google.gson=${gson.version}, \ org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ - org.apache.commons.beanutils=${commons-beanutils.version}, \ diff --git a/distribution/config/commands/ping.properties b/distribution/config/commands/ping.properties --- a/distribution/config/commands/ping.properties +++ b/distribution/config/commands/ping.properties @@ -65,9 +112,9 @@ diff --git a/distribution/config/commands/ping.properties b/distribution/config/ org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ + ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ com.google.gson=${gson.version}, \ org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ - org.apache.commons.beanutils=${commons-beanutils.version}, \ diff --git a/distribution/config/commands/vm-info.properties b/distribution/config/commands/vm-info.properties --- a/distribution/config/commands/vm-info.properties +++ b/distribution/config/commands/vm-info.properties @@ -76,20 +123,20 @@ diff --git a/distribution/config/commands/vm-info.properties b/distribution/conf org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ + ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ com.google.gson=${gson.version}, \ org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ - org.apache.commons.beanutils=${commons-beanutils.version}, \ diff --git a/distribution/config/commands/vm-stat.properties b/distribution/config/commands/vm-stat.properties --- a/distribution/config/commands/vm-stat.properties +++ b/distribution/config/commands/vm-stat.properties -@@ -4,6 +4,7 @@ - com.redhat.thermostat.web.client=${project.version}, \ +@@ -5,6 +5,7 @@ + com.redhat.thermostat.client.core=${project.version}, \ org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ + ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ com.google.gson=${gson.version}, \ org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ - org.apache.commons.beanutils=${commons-beanutils.version}, \ diff --git a/distribution/config/osgi-export.properties b/distribution/config/osgi-export.properties --- a/distribution/config/osgi-export.properties +++ b/distribution/config/osgi-export.properties @@ -114,11 +161,10 @@ diff --git a/distribution/config/osgi-export.properties b/distribution/config/os sun.swing sun.swing.table -@@ -60,11 +46,3 @@ - sun.jvmstat +@@ -61,11 +47,4 @@ sun.jvmstat.monitor sun.jvmstat.monitor.event -- + -# webservice command depends on jetty-jndi, which requires -# javax.transaction and javax.mail. We don't use jndi stuff, -# so we add those "fake" exports here. @@ -126,10 +172,11 @@ diff --git a/distribution/config/osgi-export.properties b/distribution/config/os -# available. -javax.transaction="1.1" -javax.mail="1.4" + diff --git a/distribution/scripts/thermostat b/distribution/scripts/thermostat --- a/distribution/scripts/thermostat +++ b/distribution/scripts/thermostat -@@ -56,15 +56,12 @@ +@@ -56,13 +56,10 @@ # This is the minimal boot classpath thermostat needs. Other dependencies # will get started by the OSGi framework once that's up. @@ -138,112 +185,170 @@ diff --git a/distribution/scripts/thermostat b/distribution/scripts/thermostat SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_LIBS}/thermostat-launcher-@project.version@.jar" SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_LIBS}/thermostat-main-@project.version@.jar" SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_LIBS}/thermostat-shared-config-@project.version@.jar" - # This needs to be on the classpath for the RMI registry to find it - SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_LIBS}/thermostat-agent-proxy-common-@project.version@.jar" -# FIXME: Remove once jfreechart is a real OSGi bundle upstream -SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_LIBS}/jfreechart-@jfreechart.version@.jar" -SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_LIBS}/jcommon-@jcommon.version@.jar" + # Needed to parse web.xml files without network connection See PR 2029. + SERVICE_CLASSPATH="${SERVICE_CLASSPATH}:${THERMOSTAT_HOME}/plugins/embedded-web-endpoint/jetty-schemas-@jetty-schemas.version@.jar" SERVICE_CLASSPATH="${TOOLS_JAR}:${SERVICE_CLASSPATH}" - - THERMOSTAT_MAIN="com.redhat.thermostat.main.Thermostat" +diff --git a/killvm/distribution/thermostat-plugin.xml b/killvm/distribution/thermostat-plugin.xml +--- a/killvm/distribution/thermostat-plugin.xml ++++ b/killvm/distribution/thermostat-plugin.xml +@@ -80,6 +80,7 @@ + org.apache.commons.logging${commons-logging.version} + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} ++ org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${gson.version} + org.jboss.netty${netty.version} diff --git a/main/src/main/resources/com/redhat/thermostat/main/impl/bootstrapbundles.properties b/main/src/main/resources/com/redhat/thermostat/main/impl/bootstrapbundles.properties --- a/main/src/main/resources/com/redhat/thermostat/main/impl/bootstrapbundles.properties +++ b/main/src/main/resources/com/redhat/thermostat/main/impl/bootstrapbundles.properties -@@ -4,6 +4,7 @@ +@@ -4,5 +4,6 @@ thermostat-common-core-${project.version}.jar, \ thermostat-plugin-validator-${project.version}.jar, \ thermostat-launcher-${project.version}.jar, \ - jline-${jline.version}.jar, \ -- commons-cli-${commons-cli.version}.jar, \ -- org.apache.servicemix.bundles.lucene-${lucene.version}.jar +- commons-cli-${commons-cli.version}.jar + jline2.jar, \ + jansi.jar, \ -+ commons-cli.jar, \ -+ lucene.jar ++ commons-cli.jar +diff --git a/storage-profile/distribution/thermostat-plugin.xml b/storage-profile/distribution/thermostat-plugin.xml +--- a/storage-profile/distribution/thermostat-plugin.xml ++++ b/storage-profile/distribution/thermostat-plugin.xml +@@ -68,6 +68,7 @@ + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} ++ org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + com.google.gson${gson.version} + org.mongodb.mongo-java-driver${mongo-driver.osgi-version} + org.apache.commons.beanutils${commons-beanutils.version} +diff --git a/vm-gc/distribution/thermostat-plugin.xml b/vm-gc/distribution/thermostat-plugin.xml +--- a/vm-gc/distribution/thermostat-plugin.xml ++++ b/vm-gc/distribution/thermostat-plugin.xml +@@ -74,6 +74,7 @@ + org.apache.commons.logging${commons-logging.version} + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} ++ org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${gson.version} + org.jboss.netty${netty.version} diff --git a/vm-heap-analysis/distribution/thermostat-plugin.xml b/vm-heap-analysis/distribution/thermostat-plugin.xml --- a/vm-heap-analysis/distribution/thermostat-plugin.xml +++ b/vm-heap-analysis/distribution/thermostat-plugin.xml -@@ -86,8 +86,11 @@ +@@ -86,9 +86,12 @@ org.apache.commons.logging${commons-logging.version} org.apache.httpcomponents.httpcore${httpcomponents.core.version} org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} com.google.gson${gson.version} org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} + org.jfree.jfreechart${jfreechart.osgi.version} + org.apache.servicemix.bundles.lucene${lucene.osgi-version} + org.apache.servicemix.bundles.lucene-analyzers-common${lucene.osgi-version} - - -@@ -139,8 +142,11 @@ +@@ -142,9 +145,12 @@ org.apache.commons.logging${commons-logging.version} org.apache.httpcomponents.httpcore${httpcomponents.core.version} org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} com.google.gson${gson.version} org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} + org.jfree.jfreechart${jfreechart.osgi.version} + org.apache.servicemix.bundles.lucene${lucene.osgi-version} + org.apache.servicemix.bundles.lucene-analyzers-common${lucene.osgi-version} - - -@@ -195,8 +201,11 @@ +@@ -201,9 +207,12 @@ org.apache.commons.logging${commons-logging.version} org.apache.httpcomponents.httpcore${httpcomponents.core.version} org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} com.google.gson${gson.version} org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} + org.jfree.jfreechart${jfreechart.osgi.version} + org.apache.servicemix.bundles.lucene${lucene.osgi-version} + org.apache.servicemix.bundles.lucene-analyzers-common${lucene.osgi-version} - - -@@ -245,8 +254,11 @@ +@@ -254,9 +263,12 @@ org.apache.commons.logging${commons-logging.version} org.apache.httpcomponents.httpcore${httpcomponents.core.version} org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} com.google.gson${gson.version} org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} + org.jfree.jfreechart${jfreechart.osgi.version} + org.apache.servicemix.bundles.lucene${lucene.osgi-version} + org.apache.servicemix.bundles.lucene-analyzers-common${lucene.osgi-version} - - -@@ -295,8 +307,11 @@ +@@ -307,9 +319,12 @@ org.apache.commons.logging${commons-logging.version} org.apache.httpcomponents.httpcore${httpcomponents.core.version} org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} com.google.gson${gson.version} org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} + org.jfree.jfreechart${jfreechart.osgi.version} + org.apache.servicemix.bundles.lucene${lucene.osgi-version} + org.apache.servicemix.bundles.lucene-analyzers-common${lucene.osgi-version} - - -@@ -345,8 +360,11 @@ +@@ -360,9 +375,12 @@ org.apache.commons.logging${commons-logging.version} org.apache.httpcomponents.httpcore${httpcomponents.core.version} org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} com.google.gson${gson.version} org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} + org.jfree.jfreechart${jfreechart.osgi.version} + org.apache.servicemix.bundles.lucene${lucene.osgi-version} + org.apache.servicemix.bundles.lucene-analyzers-common${lucene.osgi-version} - - -@@ -388,8 +406,11 @@ +@@ -406,9 +424,12 @@ org.apache.commons.logging${commons-logging.version} org.apache.httpcomponents.httpcore${httpcomponents.core.version} org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} com.google.gson${gson.version} org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} + org.jfree.jfreechart${jfreechart.osgi.version} + org.apache.servicemix.bundles.lucene${lucene.osgi-version} + org.apache.servicemix.bundles.lucene-analyzers-common${lucene.osgi-version} - - +diff --git a/vm-profiler/distribution/thermostat-plugin.xml b/vm-profiler/distribution/thermostat-plugin.xml +--- a/vm-profiler/distribution/thermostat-plugin.xml ++++ b/vm-profiler/distribution/thermostat-plugin.xml +@@ -94,6 +94,7 @@ + org.apache.commons.logging${commons-logging.version} + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} ++ org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + + +diff --git a/web/endpoint-plugin/distribution/thermostat-plugin.xml b/web/endpoint-plugin/distribution/thermostat-plugin.xml +--- a/web/endpoint-plugin/distribution/thermostat-plugin.xml ++++ b/web/endpoint-plugin/distribution/thermostat-plugin.xml +@@ -68,6 +68,7 @@ + com.redhat.thermostat.web.client${project.version} + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} ++ org.apache.httpcomponents.httpmime${httpcomponents.mime.version} + ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${gson.version} + com.redhat.thermostat.process${project.version} diff --git a/SOURCES/fix_loglevel.patch b/SOURCES/fix_loglevel.patch deleted file mode 100644 index 764d8ec..0000000 --- a/SOURCES/fix_loglevel.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff --git a/distribution/config/logging.properties b/distribution/config/logging.properties ---- a/distribution/config/logging.properties -+++ b/distribution/config/logging.properties -@@ -54,12 +54,12 @@ - ################################################################### - # Possible levels are in descending order: - #com.redhat.thermostat.level=SEVERE --#com.redhat.thermostat.level=WARNING -+com.redhat.thermostat.level=WARNING - #com.redhat.thermostat.level=INFO - #com.redhat.thermostat.level=CONFIG - #com.redhat.thermostat.level=FINE - #com.redhat.thermostat.level=FINER --com.redhat.thermostat.level=FINEST -+#com.redhat.thermostat.level=FINEST - #com.redhat.thermostat.level=OFF - - ################################################################### diff --git a/SOURCES/fix_lucene_symbolic_name.patch b/SOURCES/fix_lucene_symbolic_name.patch new file mode 100644 index 0000000..5d770a8 --- /dev/null +++ b/SOURCES/fix_lucene_symbolic_name.patch @@ -0,0 +1,120 @@ +# HG changeset patch +# Parent 87052247afc2111919d290cb94eabefd83979263 +diff --git a/pom.xml b/pom.xml +--- a/pom.xml ++++ b/pom.xml +@@ -238,8 +238,10 @@ + 1.2.2 + + 2.9 +- 4.7.0_1 +- 4.7.0.1 ++ 4.8.0_1 ++ 4.8.0.1 ++ org.apache.lucene.analysis ++ org.apache.lucene.core + - 4.3.1 - 4.3.1 +- 4.3.1.201210102024 +- osgi.cmpn 4.2.0 3.2.4.Final -@@ -431,16 +442,6 @@ +@@ -630,17 +639,7 @@ + tools + ${jdktools.version} - - +- +- - org.osgi - org.osgi.core - ${osgi.core.version} @@ -589,10 +683,10 @@ diff --git a/pom.xml b/pom.xml - org.osgi.compendium - ${osgi.compendium.version} - -- ++ + org.apache.felix org.apache.felix.framework - ${felix.framework.version} diff --git a/storage/cli/pom.xml b/storage/cli/pom.xml --- a/storage/cli/pom.xml +++ b/storage/cli/pom.xml @@ -610,9 +704,9 @@ diff --git a/storage/cli/pom.xml b/storage/cli/pom.xml diff --git a/system-backend/pom.xml b/system-backend/pom.xml --- a/system-backend/pom.xml +++ b/system-backend/pom.xml -@@ -94,14 +94,8 @@ +@@ -87,14 +87,8 @@ - + - org.osgi - org.osgi.core @@ -690,9 +784,9 @@ diff --git a/thread/client-swing/pom.xml b/thread/client-swing/pom.xml diff --git a/thread/collector/pom.xml b/thread/collector/pom.xml --- a/thread/collector/pom.xml +++ b/thread/collector/pom.xml -@@ -78,14 +78,8 @@ +@@ -85,14 +85,8 @@ - + - org.osgi - org.osgi.core @@ -730,7 +824,7 @@ diff --git a/thread/harvester/pom.xml b/thread/harvester/pom.xml diff --git a/unix-process-handler/pom.xml b/unix-process-handler/pom.xml --- a/unix-process-handler/pom.xml +++ b/unix-process-handler/pom.xml -@@ -40,14 +40,8 @@ +@@ -77,14 +77,8 @@ @@ -750,7 +844,7 @@ diff --git a/unix-process-handler/pom.xml b/unix-process-handler/pom.xml diff --git a/vm-classstat/agent/pom.xml b/vm-classstat/agent/pom.xml --- a/vm-classstat/agent/pom.xml +++ b/vm-classstat/agent/pom.xml -@@ -43,14 +43,8 @@ +@@ -80,13 +80,8 @@ test @@ -761,16 +855,15 @@ diff --git a/vm-classstat/agent/pom.xml b/vm-classstat/agent/pom.xml - - org.osgi - org.osgi.compendium -- provided + org.apache.felix + org.apache.felix.framework + provided - com.redhat.thermostat diff --git a/vm-classstat/client-core/pom.xml b/vm-classstat/client-core/pom.xml --- a/vm-classstat/client-core/pom.xml +++ b/vm-classstat/client-core/pom.xml -@@ -62,14 +62,8 @@ +@@ -99,14 +99,8 @@ test @@ -790,7 +883,7 @@ diff --git a/vm-classstat/client-core/pom.xml b/vm-classstat/client-core/pom.xml diff --git a/vm-classstat/client-swing/pom.xml b/vm-classstat/client-swing/pom.xml --- a/vm-classstat/client-swing/pom.xml +++ b/vm-classstat/client-swing/pom.xml -@@ -50,14 +50,8 @@ +@@ -87,14 +87,8 @@ test @@ -810,7 +903,7 @@ diff --git a/vm-classstat/client-swing/pom.xml b/vm-classstat/client-swing/pom.x diff --git a/vm-classstat/common/pom.xml b/vm-classstat/common/pom.xml --- a/vm-classstat/common/pom.xml +++ b/vm-classstat/common/pom.xml -@@ -62,14 +62,8 @@ +@@ -99,14 +99,8 @@ test @@ -830,7 +923,7 @@ diff --git a/vm-classstat/common/pom.xml b/vm-classstat/common/pom.xml diff --git a/vm-cpu/agent/pom.xml b/vm-cpu/agent/pom.xml --- a/vm-cpu/agent/pom.xml +++ b/vm-cpu/agent/pom.xml -@@ -43,14 +43,8 @@ +@@ -80,14 +80,8 @@ test @@ -850,7 +943,7 @@ diff --git a/vm-cpu/agent/pom.xml b/vm-cpu/agent/pom.xml diff --git a/vm-cpu/client-cli/pom.xml b/vm-cpu/client-cli/pom.xml --- a/vm-cpu/client-cli/pom.xml +++ b/vm-cpu/client-cli/pom.xml -@@ -43,14 +43,8 @@ +@@ -80,14 +80,8 @@ test @@ -870,7 +963,7 @@ diff --git a/vm-cpu/client-cli/pom.xml b/vm-cpu/client-cli/pom.xml diff --git a/vm-cpu/client-core/pom.xml b/vm-cpu/client-core/pom.xml --- a/vm-cpu/client-core/pom.xml +++ b/vm-cpu/client-core/pom.xml -@@ -62,14 +62,8 @@ +@@ -99,14 +99,8 @@ test @@ -890,7 +983,7 @@ diff --git a/vm-cpu/client-core/pom.xml b/vm-cpu/client-core/pom.xml diff --git a/vm-cpu/client-swing/pom.xml b/vm-cpu/client-swing/pom.xml --- a/vm-cpu/client-swing/pom.xml +++ b/vm-cpu/client-swing/pom.xml -@@ -50,14 +50,8 @@ +@@ -87,14 +87,8 @@ test @@ -910,7 +1003,7 @@ diff --git a/vm-cpu/client-swing/pom.xml b/vm-cpu/client-swing/pom.xml diff --git a/vm-cpu/common/pom.xml b/vm-cpu/common/pom.xml --- a/vm-cpu/common/pom.xml +++ b/vm-cpu/common/pom.xml -@@ -62,14 +62,8 @@ +@@ -99,14 +99,8 @@ test @@ -930,7 +1023,7 @@ diff --git a/vm-cpu/common/pom.xml b/vm-cpu/common/pom.xml diff --git a/vm-gc/agent/pom.xml b/vm-gc/agent/pom.xml --- a/vm-gc/agent/pom.xml +++ b/vm-gc/agent/pom.xml -@@ -43,14 +43,8 @@ +@@ -80,14 +80,8 @@ test @@ -950,7 +1043,7 @@ diff --git a/vm-gc/agent/pom.xml b/vm-gc/agent/pom.xml diff --git a/vm-gc/client-core/pom.xml b/vm-gc/client-core/pom.xml --- a/vm-gc/client-core/pom.xml +++ b/vm-gc/client-core/pom.xml -@@ -62,14 +62,8 @@ +@@ -99,14 +99,8 @@ test @@ -970,7 +1063,7 @@ diff --git a/vm-gc/client-core/pom.xml b/vm-gc/client-core/pom.xml diff --git a/vm-gc/client-swing/pom.xml b/vm-gc/client-swing/pom.xml --- a/vm-gc/client-swing/pom.xml +++ b/vm-gc/client-swing/pom.xml -@@ -50,14 +50,8 @@ +@@ -87,14 +87,8 @@ test @@ -987,10 +1080,30 @@ diff --git a/vm-gc/client-swing/pom.xml b/vm-gc/client-swing/pom.xml org.jfree +diff --git a/vm-gc/command/pom.xml b/vm-gc/command/pom.xml +--- a/vm-gc/command/pom.xml ++++ b/vm-gc/command/pom.xml +@@ -67,14 +67,8 @@ + ${project.version} + + +- org.osgi +- org.osgi.core +- provided +- +- +- org.osgi +- org.osgi.compendium +- provided ++ org.apache.felix ++ org.apache.felix.framework + + + com.redhat.thermostat diff --git a/vm-gc/common/pom.xml b/vm-gc/common/pom.xml --- a/vm-gc/common/pom.xml +++ b/vm-gc/common/pom.xml -@@ -62,14 +62,8 @@ +@@ -99,14 +99,8 @@ test @@ -1110,7 +1223,7 @@ diff --git a/vm-heap-analysis/agent/pom.xml b/vm-heap-analysis/agent/pom.xml diff --git a/vm-heap-analysis/client-core/pom.xml b/vm-heap-analysis/client-core/pom.xml --- a/vm-heap-analysis/client-core/pom.xml +++ b/vm-heap-analysis/client-core/pom.xml -@@ -94,14 +94,8 @@ +@@ -94,14 +94,9 @@ test @@ -1123,7 +1236,8 @@ diff --git a/vm-heap-analysis/client-core/pom.xml b/vm-heap-analysis/client-core - org.osgi.compendium - provided + org.apache.felix -+ org.apache.felix.framework ++ org.apache.felix.framework ++ @@ -1190,7 +1304,7 @@ diff --git a/vm-heap-analysis/common/pom.xml b/vm-heap-analysis/common/pom.xml diff --git a/vm-jmx/agent/pom.xml b/vm-jmx/agent/pom.xml --- a/vm-jmx/agent/pom.xml +++ b/vm-jmx/agent/pom.xml -@@ -49,14 +49,8 @@ +@@ -86,14 +86,8 @@ test @@ -1210,7 +1324,7 @@ diff --git a/vm-jmx/agent/pom.xml b/vm-jmx/agent/pom.xml diff --git a/vm-jmx/client-core/pom.xml b/vm-jmx/client-core/pom.xml --- a/vm-jmx/client-core/pom.xml +++ b/vm-jmx/client-core/pom.xml -@@ -51,14 +51,8 @@ +@@ -88,14 +88,8 @@ test @@ -1230,7 +1344,7 @@ diff --git a/vm-jmx/client-core/pom.xml b/vm-jmx/client-core/pom.xml diff --git a/vm-jmx/client-swing/pom.xml b/vm-jmx/client-swing/pom.xml --- a/vm-jmx/client-swing/pom.xml +++ b/vm-jmx/client-swing/pom.xml -@@ -59,14 +59,8 @@ +@@ -96,14 +96,8 @@ test @@ -1250,7 +1364,7 @@ diff --git a/vm-jmx/client-swing/pom.xml b/vm-jmx/client-swing/pom.xml diff --git a/vm-jmx/common/pom.xml b/vm-jmx/common/pom.xml --- a/vm-jmx/common/pom.xml +++ b/vm-jmx/common/pom.xml -@@ -51,14 +51,8 @@ +@@ -88,14 +88,8 @@ test @@ -1270,7 +1384,7 @@ diff --git a/vm-jmx/common/pom.xml b/vm-jmx/common/pom.xml diff --git a/vm-memory/agent/pom.xml b/vm-memory/agent/pom.xml --- a/vm-memory/agent/pom.xml +++ b/vm-memory/agent/pom.xml -@@ -43,14 +43,8 @@ +@@ -80,14 +80,8 @@ test @@ -1290,7 +1404,7 @@ diff --git a/vm-memory/agent/pom.xml b/vm-memory/agent/pom.xml diff --git a/vm-memory/client-cli/pom.xml b/vm-memory/client-cli/pom.xml --- a/vm-memory/client-cli/pom.xml +++ b/vm-memory/client-cli/pom.xml -@@ -43,14 +43,8 @@ +@@ -80,14 +80,8 @@ test @@ -1310,7 +1424,7 @@ diff --git a/vm-memory/client-cli/pom.xml b/vm-memory/client-cli/pom.xml diff --git a/vm-memory/client-core/pom.xml b/vm-memory/client-core/pom.xml --- a/vm-memory/client-core/pom.xml +++ b/vm-memory/client-core/pom.xml -@@ -47,14 +47,8 @@ +@@ -84,14 +84,8 @@ test @@ -1330,7 +1444,7 @@ diff --git a/vm-memory/client-core/pom.xml b/vm-memory/client-core/pom.xml diff --git a/vm-memory/client-swing/pom.xml b/vm-memory/client-swing/pom.xml --- a/vm-memory/client-swing/pom.xml +++ b/vm-memory/client-swing/pom.xml -@@ -53,14 +53,8 @@ +@@ -90,14 +90,8 @@ test @@ -1350,7 +1464,7 @@ diff --git a/vm-memory/client-swing/pom.xml b/vm-memory/client-swing/pom.xml diff --git a/vm-memory/common/pom.xml b/vm-memory/common/pom.xml --- a/vm-memory/common/pom.xml +++ b/vm-memory/common/pom.xml -@@ -62,14 +62,8 @@ +@@ -99,14 +99,8 @@ test @@ -1370,7 +1484,7 @@ diff --git a/vm-memory/common/pom.xml b/vm-memory/common/pom.xml diff --git a/vm-overview/client-core/pom.xml b/vm-overview/client-core/pom.xml --- a/vm-overview/client-core/pom.xml +++ b/vm-overview/client-core/pom.xml -@@ -46,14 +46,8 @@ +@@ -83,14 +83,8 @@ test @@ -1390,7 +1504,87 @@ diff --git a/vm-overview/client-core/pom.xml b/vm-overview/client-core/pom.xml diff --git a/vm-overview/client-swing/pom.xml b/vm-overview/client-swing/pom.xml --- a/vm-overview/client-swing/pom.xml +++ b/vm-overview/client-swing/pom.xml -@@ -50,14 +50,8 @@ +@@ -87,14 +87,8 @@ + test + + +- org.osgi +- org.osgi.core +- provided +- +- +- org.osgi +- org.osgi.compendium +- provided ++ org.apache.felix ++ org.apache.felix.framework + + + org.jfree +diff --git a/vm-profiler/agent/pom.xml b/vm-profiler/agent/pom.xml +--- a/vm-profiler/agent/pom.xml ++++ b/vm-profiler/agent/pom.xml +@@ -96,14 +96,8 @@ + test + + +- org.osgi +- org.osgi.core +- provided +- +- +- org.osgi +- org.osgi.compendium +- provided ++ org.apache.felix ++ org.apache.felix.framework + + + com.redhat.thermostat +diff --git a/vm-profiler/client-cli/pom.xml b/vm-profiler/client-cli/pom.xml +--- a/vm-profiler/client-cli/pom.xml ++++ b/vm-profiler/client-cli/pom.xml +@@ -80,14 +80,8 @@ + test + + +- org.osgi +- org.osgi.core +- provided +- +- +- org.osgi +- org.osgi.compendium +- provided ++ org.apache.felix ++ org.apache.felix.framework + + + com.redhat.thermostat +diff --git a/vm-profiler/client-core/pom.xml b/vm-profiler/client-core/pom.xml +--- a/vm-profiler/client-core/pom.xml ++++ b/vm-profiler/client-core/pom.xml +@@ -99,14 +99,8 @@ + test + + +- org.osgi +- org.osgi.core +- provided +- +- +- org.osgi +- org.osgi.compendium +- provided ++ org.apache.felix ++ org.apache.felix.framework + + + com.redhat.thermostat +diff --git a/vm-profiler/client-swing/pom.xml b/vm-profiler/client-swing/pom.xml +--- a/vm-profiler/client-swing/pom.xml ++++ b/vm-profiler/client-swing/pom.xml +@@ -87,14 +87,8 @@ test @@ -1407,30 +1601,73 @@ diff --git a/vm-overview/client-swing/pom.xml b/vm-overview/client-swing/pom.xml org.jfree +diff --git a/vm-profiler/common/pom.xml b/vm-profiler/common/pom.xml +--- a/vm-profiler/common/pom.xml ++++ b/vm-profiler/common/pom.xml +@@ -99,14 +99,8 @@ + test + + +- org.osgi +- org.osgi.core +- provided +- +- +- org.osgi +- org.osgi.compendium +- provided ++ org.apache.felix ++ org.apache.felix.framework + + + com.redhat.thermostat diff --git a/web/client/pom.xml b/web/client/pom.xml --- a/web/client/pom.xml +++ b/web/client/pom.xml -@@ -64,14 +64,8 @@ +@@ -64,9 +64,8 @@ - org.osgi - org.osgi.core - provided -- ++ org.apache.felix ++ org.apache.felix.framework + + + +@@ -93,12 +92,6 @@ + httpclient-osgi + ${httpcomponents.client.version} + +- - - org.osgi - org.osgi.compendium +- + + org.apache.httpcomponents + httpcore-osgi +diff --git a/web/endpoint-plugin/web-service/pom.xml b/web/endpoint-plugin/web-service/pom.xml +--- a/web/endpoint-plugin/web-service/pom.xml ++++ b/web/endpoint-plugin/web-service/pom.xml +@@ -54,9 +54,8 @@ + + + +- org.osgi +- org.osgi.core - provided + org.apache.felix + org.apache.felix.framework - + diff --git a/web/server/pom.xml b/web/server/pom.xml --- a/web/server/pom.xml +++ b/web/server/pom.xml -@@ -127,9 +127,8 @@ +@@ -131,9 +131,8 @@ @@ -1442,3 +1679,238 @@ diff --git a/web/server/pom.xml b/web/server/pom.xml +diff --git a/distribution/assembly/core-assembly.xml b/distribution/assembly/core-assembly.xml +--- a/distribution/assembly/core-assembly.xml ++++ b/distribution/assembly/core-assembly.xml +@@ -69,7 +69,6 @@ + com.redhat.thermostat:thermostat-web-client + com.redhat.thermostat:thermostat-system-backend + com.redhat.thermostat:thermostat-laf-utils +- org.osgi:org.osgi.compendium + + + org.osgi:org.osgi.core +diff --git a/distribution/config/commands/agent-info.properties b/distribution/config/commands/agent-info.properties +--- a/distribution/config/commands/agent-info.properties ++++ b/distribution/config/commands/agent-info.properties +@@ -5,7 +5,6 @@ + org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ + org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ +- ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ + com.google.gson=${gson.version}, \ + org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ + org.apache.commons.beanutils=${commons-beanutils.version}, \ +diff --git a/distribution/config/commands/agent.properties b/distribution/config/commands/agent.properties +--- a/distribution/config/commands/agent.properties ++++ b/distribution/config/commands/agent.properties +@@ -4,7 +4,6 @@ + org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ + org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ +- ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ + com.google.gson=${gson.version}, \ + com.redhat.thermostat.process=${project.version}, \ + com.redhat.thermostat.common.core=${project.version}, \ +diff --git a/distribution/config/commands/clean-data.properties b/distribution/config/commands/clean-data.properties +--- a/distribution/config/commands/clean-data.properties ++++ b/distribution/config/commands/clean-data.properties +@@ -5,7 +5,6 @@ + org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ + org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ +- ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ + com.google.gson=${gson.version}, \ + org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ + org.apache.commons.beanutils=${commons-beanutils.version}, \ +diff --git a/distribution/config/commands/connect.properties b/distribution/config/commands/connect.properties +--- a/distribution/config/commands/connect.properties ++++ b/distribution/config/commands/connect.properties +@@ -11,7 +11,6 @@ + org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ + org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ +- ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ + com.google.gson=${gson.version} + + description = persistently connect to storage +diff --git a/distribution/config/commands/gui.properties b/distribution/config/commands/gui.properties +--- a/distribution/config/commands/gui.properties ++++ b/distribution/config/commands/gui.properties +@@ -20,7 +20,6 @@ + org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ + org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ +- ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ + org.jboss.netty=${netty.version}, \ + org.jfree.jcommon=${jcommon.osgi.version} , \ + org.jfree.jfreechart=${jfreechart.osgi.version} +diff --git a/distribution/config/commands/list-agents.properties b/distribution/config/commands/list-agents.properties +--- a/distribution/config/commands/list-agents.properties ++++ b/distribution/config/commands/list-agents.properties +@@ -5,7 +5,6 @@ + org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ + org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ +- ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ + com.google.gson=${gson.version}, \ + org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ + org.apache.commons.beanutils=${commons-beanutils.version}, \ +diff --git a/distribution/config/commands/list-vms.properties b/distribution/config/commands/list-vms.properties +--- a/distribution/config/commands/list-vms.properties ++++ b/distribution/config/commands/list-vms.properties +@@ -5,7 +5,6 @@ + org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ + org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ +- ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ + com.google.gson=${gson.version}, \ + org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ + org.apache.commons.beanutils=${commons-beanutils.version}, \ +diff --git a/distribution/config/commands/ping.properties b/distribution/config/commands/ping.properties +--- a/distribution/config/commands/ping.properties ++++ b/distribution/config/commands/ping.properties +@@ -6,7 +6,6 @@ + org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ + org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ +- ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ + com.google.gson=${gson.version}, \ + org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ + org.apache.commons.beanutils=${commons-beanutils.version}, \ +diff --git a/distribution/config/commands/vm-info.properties b/distribution/config/commands/vm-info.properties +--- a/distribution/config/commands/vm-info.properties ++++ b/distribution/config/commands/vm-info.properties +@@ -5,7 +5,6 @@ + org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ + org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ +- ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ + com.google.gson=${gson.version}, \ + org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ + org.apache.commons.beanutils=${commons-beanutils.version}, \ +diff --git a/distribution/config/commands/vm-stat.properties b/distribution/config/commands/vm-stat.properties +--- a/distribution/config/commands/vm-stat.properties ++++ b/distribution/config/commands/vm-stat.properties +@@ -6,7 +6,6 @@ + org.apache.httpcomponents.httpcore=${httpcomponents.core.version}, \ + org.apache.httpcomponents.httpclient=${httpcomponents.client.version}, \ + org.apache.httpcomponents.httpmime=${httpcomponents.mime.version}, \ +- ${osgi.compendium.bundle.symbolic-name}=${osgi.compendium.osgi-version}, \ + com.google.gson=${gson.version}, \ + org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ + org.apache.commons.beanutils=${commons-beanutils.version}, \ +diff --git a/killvm/distribution/thermostat-plugin.xml b/killvm/distribution/thermostat-plugin.xml +--- a/killvm/distribution/thermostat-plugin.xml ++++ b/killvm/distribution/thermostat-plugin.xml +@@ -81,7 +81,6 @@ + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} +- ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${gson.version} + org.jboss.netty${netty.version} + +diff --git a/storage-profile/distribution/thermostat-plugin.xml b/storage-profile/distribution/thermostat-plugin.xml +--- a/storage-profile/distribution/thermostat-plugin.xml ++++ b/storage-profile/distribution/thermostat-plugin.xml +@@ -65,7 +65,6 @@ + com.redhat.thermostat.storage.mongodb${project.version} + com.redhat.thermostat.web.common${project.version} + com.redhat.thermostat.web.client${project.version} +- ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} +diff --git a/vm-gc/distribution/thermostat-plugin.xml b/vm-gc/distribution/thermostat-plugin.xml +--- a/vm-gc/distribution/thermostat-plugin.xml ++++ b/vm-gc/distribution/thermostat-plugin.xml +@@ -75,7 +75,6 @@ + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} +- ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${gson.version} + org.jboss.netty${netty.version} + +diff --git a/vm-heap-analysis/distribution/thermostat-plugin.xml b/vm-heap-analysis/distribution/thermostat-plugin.xml +--- a/vm-heap-analysis/distribution/thermostat-plugin.xml ++++ b/vm-heap-analysis/distribution/thermostat-plugin.xml +@@ -87,7 +87,6 @@ + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} +- ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${gson.version} + org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} +@@ -146,7 +145,6 @@ + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} +- ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${gson.version} + org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} +@@ -208,7 +206,6 @@ + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} +- ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${gson.version} + org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} +@@ -264,7 +261,6 @@ + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} +- ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${gson.version} + org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} +@@ -320,7 +316,6 @@ + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} +- ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${gson.version} + org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} +@@ -376,7 +371,6 @@ + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} +- ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${gson.version} + org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} +@@ -425,7 +419,6 @@ + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} +- ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${gson.version} + org.jboss.netty${netty.version} + org.jfree.jcommon${jcommon.osgi.version} +diff --git a/vm-profiler/distribution/thermostat-plugin.xml b/vm-profiler/distribution/thermostat-plugin.xml +--- a/vm-profiler/distribution/thermostat-plugin.xml ++++ b/vm-profiler/distribution/thermostat-plugin.xml +@@ -95,7 +95,6 @@ + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} +- ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + + + +diff --git a/web/endpoint-plugin/distribution/thermostat-plugin.xml b/web/endpoint-plugin/distribution/thermostat-plugin.xml +--- a/web/endpoint-plugin/distribution/thermostat-plugin.xml ++++ b/web/endpoint-plugin/distribution/thermostat-plugin.xml +@@ -69,7 +69,6 @@ + org.apache.httpcomponents.httpcore${httpcomponents.core.version} + org.apache.httpcomponents.httpclient${httpcomponents.client.version} + org.apache.httpcomponents.httpmime${httpcomponents.mime.version} +- ${osgi.compendium.bundle.symbolic-name}${osgi.compendium.osgi-version} + com.google.gson${gson.version} + com.redhat.thermostat.process${project.version} + com.redhat.thermostat.agent.cli${project.version} diff --git a/SOURCES/remove_adduser_command.patch b/SOURCES/remove_adduser_command.patch new file mode 100644 index 0000000..a211c75 --- /dev/null +++ b/SOURCES/remove_adduser_command.patch @@ -0,0 +1,1001 @@ +# HG changeset patch +# Parent 580b6482ef65a0e0b5a45f2923aecd75e838dcd3 +diff --git a/distribution/config/commands/add-mongodb-user.properties b/distribution/config/commands/add-mongodb-user.properties +deleted file mode 100644 +--- a/distribution/config/commands/add-mongodb-user.properties ++++ /dev/null +@@ -1,23 +0,0 @@ +-bundles = com.redhat.thermostat.storage.mongodb=${project.version}, \ +- org.mongodb.mongo-java-driver=${mongo-driver.osgi-version}, \ +- org.apache.commons.beanutils=${commons-beanutils.version}, \ +- org.apache.commons.codec=${commons-codec.osgi-version}, \ +- org.apache.commons.collections=${commons-collections.version}, \ +- org.apache.commons.logging=${commons-logging.version} +- +-description = adds a new mongodb user to the thermostat DB, reading credentials \ +- from standard input +- +-usage = add-mongodb-user -d |\ +- add-mongodb-user -s +- +-options = AUTO_LOG_OPTION, AUTO_DB_OPTIONS, startStorage +- +-startStorage.short = s +-startStorage.long = startStorage +-startStorage.description = start storage with appropriate options before \ +- running the command and stop the storage when the command finishes +-startStorage.required = false +-startStorage.hasarg = false +- +-environments = cli +diff --git a/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/Activator.java b/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/Activator.java +--- a/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/Activator.java ++++ b/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/Activator.java +@@ -40,8 +40,6 @@ + import org.osgi.framework.BundleContext; + import org.osgi.framework.ServiceRegistration; + +-import com.redhat.thermostat.common.cli.CommandRegistry; +-import com.redhat.thermostat.common.cli.CommandRegistryImpl; + import com.redhat.thermostat.storage.core.StorageProvider; + import com.redhat.thermostat.storage.mongodb.MongoStorageProvider; + +@@ -49,20 +47,16 @@ + + @SuppressWarnings("rawtypes") + private ServiceRegistration reg; +- private CommandRegistry cmdReg; + + @Override + public void start(BundleContext context) throws Exception { + StorageProvider prov = new MongoStorageProvider(); + reg = context.registerService(StorageProvider.class.getName(), prov, null); +- cmdReg = new CommandRegistryImpl(context); +- cmdReg.registerCommand(AddUserCommandDispatcher.COMMAND_NAME, new AddUserCommandDispatcher(context)); + } + + @Override + public void stop(BundleContext context) throws Exception { + reg.unregister(); +- cmdReg.unregisterCommands(); + } + + } +diff --git a/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/AddUserCommand.java b/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/AddUserCommand.java +deleted file mode 100644 +--- a/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/AddUserCommand.java ++++ /dev/null +@@ -1,198 +0,0 @@ +-/* +- * Copyright 2012-2014 Red Hat, Inc. +- * +- * This file is part of Thermostat. +- * +- * Thermostat is free software; you can redistribute it and/or modify +- * it under the terms of the GNU General Public License as published +- * by the Free Software Foundation; either version 2, or (at your +- * option) any later version. +- * +- * Thermostat is distributed in the hope that it will be useful, but +- * WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with Thermostat; see the file COPYING. If not see +- * . +- * +- * Linking this code with other modules is making a combined work +- * based on this code. Thus, the terms and conditions of the GNU +- * General Public License cover the whole combination. +- * +- * As a special exception, the copyright holders of this code give +- * you permission to link this code with independent modules to +- * produce an executable, regardless of the license terms of these +- * independent modules, and to copy and distribute the resulting +- * executable under terms of your choice, provided that you also +- * meet, for each linked independent module, the terms and conditions +- * of the license of that module. An independent module is a module +- * which is not derived from or based on this code. If you modify +- * this code, you may extend this exception to your version of the +- * library, but you are not obligated to do so. If you do not wish +- * to do so, delete this exception statement from your version. +- */ +- +-package com.redhat.thermostat.storage.mongodb.internal; +- +-import java.io.File; +-import java.io.IOException; +-import java.lang.reflect.Field; +-import java.util.Arrays; +-import java.util.Objects; +- +-import org.osgi.framework.BundleContext; +-import org.osgi.framework.ServiceReference; +-import org.osgi.framework.ServiceRegistration; +- +-import com.redhat.thermostat.common.cli.CommandContext; +-import com.redhat.thermostat.common.cli.CommandException; +-import com.redhat.thermostat.common.tools.StorageAuthInfoGetter; +-import com.redhat.thermostat.shared.config.CommonPaths; +-import com.redhat.thermostat.shared.locale.LocalizedString; +-import com.redhat.thermostat.shared.locale.Translate; +-import com.redhat.thermostat.storage.core.DbService; +-import com.redhat.thermostat.storage.core.DbServiceFactory; +-import com.redhat.thermostat.storage.core.QueuedStorage; +-import com.redhat.thermostat.storage.core.Storage; +-import com.redhat.thermostat.storage.core.StorageCredentials; +- +-/** +- * This command needs to be in the mongodb storage bundle since it +- * uses MongoStorage directly (casts to it). +- * +- */ +-public class AddUserCommand extends BaseAddUserCommand { +- +- private static final Translate t = LocaleResources.createLocalizer(); +- static final String DB_URL_ARG = "dbUrl"; +- private final BundleContext context; +- private final StorageCredentials emptyCredentials; +- +- AddUserCommand(BundleContext context) { +- this.context = context; +- // These are empty credentials we'll use for the initial connect. We +- // connect with them when the local host exception is turned off. +- emptyCredentials = new StorageCredentials() { +- +- @Override +- public String getUsername() { +- return null; +- } +- +- @Override +- public char[] getPassword() { +- return null; +- } +- }; +- } +- +- // PRE: storage started with --permitLocalHostException. +- // FIXME: Is there anything we can do to ensure this precondition? +- @Override +- public void run(CommandContext ctx) throws CommandException { +- // Check if mongodb stamp file exists. +- ServiceReference commonPathRef = context.getServiceReference(CommonPaths.class.getName()); +- requireNonNull(commonPathRef, t.localize(LocaleResources.COMMON_PATHS_SERVICE_UNAVAILABLE)); +- CommonPaths commonPath = (CommonPaths)context.getService(commonPathRef); +- File dataDir = commonPath.getUserPersistentDataDirectory(); +- // Since this is backing storage specific, it's most likely not a good +- // candidate for CommonPaths +- File mongodbSetupStamp = new File(dataDir, BaseAddUserCommand.MONGODB_STAMP_FILE_NAME); +- if (mongodbSetupStamp.exists()) { +- String msg = t.localize(LocaleResources.MONGODB_SETUP_FILE_EXISTS, +- mongodbSetupStamp.getAbsolutePath()).getContents(); +- ctx.getConsole().getOutput().println(msg); +- return; +- } +- +- ServiceReference dbServiceRef = context.getServiceReference(DbService.class); +- if (dbServiceRef != null) { +- // Already connected, bail out +- throw new CommandException(t.localize(LocaleResources.ALREADY_CONNECTED_TO_STORAGE_WARNING)); +- } +- String dbUrl = ctx.getArguments().getArgument(DB_URL_ARG); +- // dbUrl is a required argument. This should never happen +- Objects.requireNonNull(dbUrl); +- // we only understand "mongodb://" URLs +- if (!dbUrl.startsWith("mongodb://")) { +- throw new CommandException(t.localize(LocaleResources.UNKNOWN_STORAGE_URL)); +- } +- +- // Register empty credentials so that connection succeeds +- ServiceRegistration reg = context.registerService(StorageCredentials.class.getName(), emptyCredentials, null); +- DbServiceFactory factory = new DbServiceFactory(); +- DbService service = factory.createDbService(dbUrl); +- // this synchronously connects to storage +- service.connect(); +- // Unregister empty credentials +- reg.unregister(); +- +- ServiceReference storageRef = context.getServiceReference(Storage.class.getName()); +- requireNonNull(storageRef, t.localize(LocaleResources.STORAGE_SERVICE_UNAVAILABLE)); +- @SuppressWarnings("unchecked") +- // FIXME: Hack alarm. We use knowledge that via MongoStorageProvider we +- // have a MongoStorage instance wrapped in QueuedStorage. What's +- // more, we use the "delegate" field name in order to get at the +- // MongoStorage instance, which we cast to. I'm not sure if adding +- // method in BackingStorage (the interface) directly would be +- // any better than this. After all, this is very backing storage +- // impl specific. For now do this hack :-/ +- QueuedStorage storage = (QueuedStorage)context.getService(storageRef); +- MongoStorage mongoStorage = getDelegate(storage); +- requireNonNull(mongoStorage, t.localize(LocaleResources.MONGOSTORAGE_RETRIEVAL_FAILED)); +- StorageAuthInfoGetter getter = null; +- try { +- LocalizedString userPrompt = new LocalizedString("Please enter the username you'd like to add to mongodb storage at " + dbUrl + ": "); +- LocalizedString passWordPrompt = new LocalizedString("Please enter the desired password of this user: "); +- getter = new StorageAuthInfoGetter(ctx.getConsole(), userPrompt, passWordPrompt); +- } catch (IOException e) { +- throw new CommandException(t.localize(LocaleResources.ADDING_USER_FAILED)); +- } +- ConsoleStorageCredentials creds = new ConsoleStorageCredentials(getter); +- addUser(mongoStorage, creds); +- +- // create the STAMP file +- try { +- mongodbSetupStamp.createNewFile(); +- } catch (IOException e) { +- String msg = t.localize(LocaleResources.STAMP_FILE_CREATION_FAILED, +- mongodbSetupStamp.getAbsolutePath()).getContents(); +- ctx.getConsole().getError().println(msg); +- throw new CommandException(new LocalizedString(msg)); +- } +- +- String msg = t.localize(LocaleResources.MONGODB_USER_SETUP_COMPLETE).getContents(); +- ctx.getConsole().getOutput().println(msg); +- } +- +- // package-private for testing +- void addUser(MongoStorage mongoStorage, StorageCredentials creds) { +- // It's important that getUsername is called prior getPassword. +- // otherwise prompts don't make much sense. +- String username = creds.getUsername(); +- char[] pwd = creds.getPassword(); +- mongoStorage.addUser(username, pwd); +- // zero out password. We no longer use it. +- Arrays.fill(pwd, '\0'); +- } +- +- // package-private for testing +- MongoStorage getDelegate(QueuedStorage storage) { +- try { +- Field field = storage.getClass().getDeclaredField("delegate"); +- field.setAccessible(true); +- MongoStorage mongo = (MongoStorage)field.get(storage); +- return mongo; +- } catch (Exception e) { +- return null; +- } +- } +- +- @Override +- public boolean isStorageRequired() { +- return false; +- } +- +-} +diff --git a/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/AddUserCommandDispatcher.java b/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/AddUserCommandDispatcher.java +deleted file mode 100644 +--- a/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/AddUserCommandDispatcher.java ++++ /dev/null +@@ -1,78 +0,0 @@ +-/* +- * Copyright 2012-2014 Red Hat, Inc. +- * +- * This file is part of Thermostat. +- * +- * Thermostat is free software; you can redistribute it and/or modify +- * it under the terms of the GNU General Public License as published +- * by the Free Software Foundation; either version 2, or (at your +- * option) any later version. +- * +- * Thermostat is distributed in the hope that it will be useful, but +- * WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with Thermostat; see the file COPYING. If not see +- * . +- * +- * Linking this code with other modules is making a combined work +- * based on this code. Thus, the terms and conditions of the GNU +- * General Public License cover the whole combination. +- * +- * As a special exception, the copyright holders of this code give +- * you permission to link this code with independent modules to +- * produce an executable, regardless of the license terms of these +- * independent modules, and to copy and distribute the resulting +- * executable under terms of your choice, provided that you also +- * meet, for each linked independent module, the terms and conditions +- * of the license of that module. An independent module is a module +- * which is not derived from or based on this code. If you modify +- * this code, you may extend this exception to your version of the +- * library, but you are not obligated to do so. If you do not wish +- * to do so, delete this exception statement from your version. +- */ +- +-package com.redhat.thermostat.storage.mongodb.internal; +- +-import org.osgi.framework.BundleContext; +- +-import com.redhat.thermostat.common.cli.CommandContext; +-import com.redhat.thermostat.common.cli.CommandException; +-import com.redhat.thermostat.shared.locale.Translate; +- +-/** +- * Dispatcher making sure either -d or -s has been provided. +- * +- */ +-class AddUserCommandDispatcher extends BaseAddUserCommand { +- +- private static final Translate t = LocaleResources.createLocalizer(); +- private static final String START_STORAGE_ARG = "startStorage"; +- private static final String DB_URL_ARG = "dbUrl"; +- static final String COMMAND_NAME = "add-mongodb-user"; +- private final BundleContext context; +- private BaseAddUserCommand command; +- +- AddUserCommandDispatcher(BundleContext context, BaseAddUserCommand cmd) { +- this.context = context; +- this.command = cmd; +- } +- +- AddUserCommandDispatcher(BundleContext context) { +- this(context, new AddUserCommand(context)); +- } +- +- @Override +- public void run(CommandContext ctx) throws CommandException { +- if (ctx.getArguments().hasArgument(START_STORAGE_ARG)) { +- // decorate and run +- command = new StartStopAddUserCommandDecorator(context, command); +- } else if (!ctx.getArguments().hasArgument(DB_URL_ARG)) { +- throw new CommandException(t.localize(LocaleResources.DISPATCHER_WRONG_OPTION)); +- } +- command.run(ctx); +- } +- +-} +diff --git a/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/BaseAddUserCommand.java b/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/BaseAddUserCommand.java +deleted file mode 100644 +--- a/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/BaseAddUserCommand.java ++++ /dev/null +@@ -1,62 +0,0 @@ +-/* +- * Copyright 2012-2014 Red Hat, Inc. +- * +- * This file is part of Thermostat. +- * +- * Thermostat is free software; you can redistribute it and/or modify +- * it under the terms of the GNU General Public License as published +- * by the Free Software Foundation; either version 2, or (at your +- * option) any later version. +- * +- * Thermostat is distributed in the hope that it will be useful, but +- * WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with Thermostat; see the file COPYING. If not see +- * . +- * +- * Linking this code with other modules is making a combined work +- * based on this code. Thus, the terms and conditions of the GNU +- * General Public License cover the whole combination. +- * +- * As a special exception, the copyright holders of this code give +- * you permission to link this code with independent modules to +- * produce an executable, regardless of the license terms of these +- * independent modules, and to copy and distribute the resulting +- * executable under terms of your choice, provided that you also +- * meet, for each linked independent module, the terms and conditions +- * of the license of that module. An independent module is a module +- * which is not derived from or based on this code. If you modify +- * this code, you may extend this exception to your version of the +- * library, but you are not obligated to do so. If you do not wish +- * to do so, delete this exception statement from your version. +- */ +- +-package com.redhat.thermostat.storage.mongodb.internal; +- +-import com.redhat.thermostat.common.cli.AbstractCommand; +-import com.redhat.thermostat.common.cli.CommandContext; +-import com.redhat.thermostat.common.cli.CommandException; +- +-/** +- * +- * Base class for user setup decorators. +- * +- * @see AddUserCommand +- * @see StartStopAddUserCommandDecorator +- * +- */ +-abstract class BaseAddUserCommand extends AbstractCommand { +- +- static final String MONGODB_STAMP_FILE_NAME = "mongodb-user-done.stamp"; +- +- @Override +- abstract public void run(CommandContext ctx) throws CommandException; +- +- @Override +- public boolean isStorageRequired() { +- return false; +- } +-} +diff --git a/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/StartStopAddUserCommandDecorator.java b/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/StartStopAddUserCommandDecorator.java +deleted file mode 100644 +--- a/storage/mongo/src/main/java/com/redhat/thermostat/storage/mongodb/internal/StartStopAddUserCommandDecorator.java ++++ /dev/null +@@ -1,268 +0,0 @@ +-/* +- * Copyright 2012-2014 Red Hat, Inc. +- * +- * This file is part of Thermostat. +- * +- * Thermostat is free software; you can redistribute it and/or modify +- * it under the terms of the GNU General Public License as published +- * by the Free Software Foundation; either version 2, or (at your +- * option) any later version. +- * +- * Thermostat is distributed in the hope that it will be useful, but +- * WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with Thermostat; see the file COPYING. If not see +- * . +- * +- * Linking this code with other modules is making a combined work +- * based on this code. Thus, the terms and conditions of the GNU +- * General Public License cover the whole combination. +- * +- * As a special exception, the copyright holders of this code give +- * you permission to link this code with independent modules to +- * produce an executable, regardless of the license terms of these +- * independent modules, and to copy and distribute the resulting +- * executable under terms of your choice, provided that you also +- * meet, for each linked independent module, the terms and conditions +- * of the license of that module. An independent module is a module +- * which is not derived from or based on this code. If you modify +- * this code, you may extend this exception to your version of the +- * library, but you are not obligated to do so. If you do not wish +- * to do so, delete this exception statement from your version. +- */ +- +-package com.redhat.thermostat.storage.mongodb.internal; +- +-import java.io.File; +-import java.util.ArrayList; +-import java.util.Collections; +-import java.util.List; +-import java.util.concurrent.CountDownLatch; +- +-import org.osgi.framework.BundleContext; +-import org.osgi.framework.ServiceReference; +- +-import com.redhat.thermostat.common.ActionEvent; +-import com.redhat.thermostat.common.ActionListener; +-import com.redhat.thermostat.common.cli.AbstractStateNotifyingCommand; +-import com.redhat.thermostat.common.cli.Arguments; +-import com.redhat.thermostat.common.cli.CommandContext; +-import com.redhat.thermostat.common.cli.CommandContextFactory; +-import com.redhat.thermostat.common.cli.CommandException; +-import com.redhat.thermostat.common.tools.ApplicationState; +-import com.redhat.thermostat.launcher.Launcher; +-import com.redhat.thermostat.shared.config.CommonPaths; +-import com.redhat.thermostat.shared.locale.Translate; +- +-/* +- * A command which adds a mongdb user by using AddUserCommand. It has been +- * introduced in order to aid boot-strapping of thermostat deployments. In order +- * to set up a user in mongodb, storage needs to be started with the +- * --permitLocalhostException option first. Then the credentials need to be +- * injected and storage stopped again. This command performs all three +- * required steps. +- */ +-public class StartStopAddUserCommandDecorator extends BaseAddUserCommand { +- +- public static final String COMMAND_NAME = "admin-mongodb-creds-setup"; +- private static final Translate t = LocaleResources.createLocalizer(); +- private final BundleContext context; +- private final List> listeners; +- private final CountDownLatch setupFinishedBarrier; +- private final BaseAddUserCommand decoratee; +- private boolean setupSuccessful; +- private Launcher launcher; +- private CommandContext cmdCtx; +- +- StartStopAddUserCommandDecorator(BundleContext context, BaseAddUserCommand command) { +- this.context = context; +- this.listeners = new ArrayList<>(1); +- this.setupFinishedBarrier = new CountDownLatch(1); +- this.setupSuccessful = true; +- this.decoratee = command; +- } +- +- @Override +- public void run(CommandContext ctx) throws CommandException { +- cmdCtx = ctx; +- if (!stampFileExists()) { +- startStorageAndRunDecoratee(); +- stopStorage(); +- } +- // if stamp file exists, there is nothing to do. +- String msg; +- if (setupSuccessful) { +- msg = t.localize(LocaleResources.USER_SETUP_COMPLETE).getContents(); +- cmdCtx.getConsole().getOutput().println(msg); +- } else { +- msg = t.localize(LocaleResources.USER_SETUP_FAILED).getContents(); +- cmdCtx.getConsole().getOutput().println(msg); +- } +- } +- +- private void stopStorage() throws CommandException { +- listeners.clear(); +- CountDownLatch storageStoppedlatch = new CountDownLatch(1); +- StorageStoppedListener listener = new StorageStoppedListener(storageStoppedlatch); +- String[] storageStopArgs = new String[] { +- "storage", "--stop" +- }; +- listeners.add(listener); +- launcher.run(storageStopArgs, listeners, false); +- try { +- storageStoppedlatch.await(); +- } catch (InterruptedException e) { +- setupSuccessful = false; +- throw new CommandException(t.localize(LocaleResources.INTERRUPTED_WAITING_FOR_STORAGE_STOP), e); +- } +- if (!listener.storageStopPassed) { +- setupSuccessful = false; +- String msg = t.localize(LocaleResources.STORAGE_STOP_FAILED).getContents(); +- cmdCtx.getConsole().getError().println(msg); +- } +- } +- +- private void startStorageAndRunDecoratee() throws CommandException { +- ServiceReference launcherRef = context.getServiceReference(Launcher.class); +- if (launcherRef == null) { +- throw new CommandException(t.localize(LocaleResources.LAUNCHER_SERVICE_UNAVAILABLE)); +- } +- launcher = (Launcher) context.getService(launcherRef); +- StorageStartedListener listener = new StorageStartedListener(); +- listeners.add(listener); +- String[] storageStartArgs = new String[] { "storage", "--start", "--permitLocalhostException"}; +- launcher.run(storageStartArgs, listeners, false); +- try { +- setupFinishedBarrier.await(); +- } catch (InterruptedException e) { +- e.printStackTrace(); +- } +- } +- +- private boolean stampFileExists() throws CommandException { +- ServiceReference commonPathRef = context.getServiceReference(CommonPaths.class.getName()); +- if (commonPathRef == null) { +- throw new CommandException(t.localize(LocaleResources.COMMON_PATHS_SERVICE_UNAVAILABLE)); +- } +- CommonPaths commonPath = (CommonPaths)context.getService(commonPathRef); +- File dataDir = commonPath.getUserPersistentDataDirectory(); +- // Since this is backing storage specific, it's most likely not a good +- // candidate for CommonPaths +- File mongodbSetupStamp = new File(dataDir, BaseAddUserCommand.MONGODB_STAMP_FILE_NAME); +- if (mongodbSetupStamp.exists()) { +- String msg = t.localize(LocaleResources.MONGODB_SETUP_FILE_EXISTS, +- mongodbSetupStamp.getAbsolutePath()).getContents(); +- cmdCtx.getConsole().getOutput().println(msg); +- return true; +- } else { +- return false; +- } +- } +- +- private class StorageStartedListener implements ActionListener { +- +- @Override +- public void actionPerformed(ActionEvent actionEvent) { +- if (actionEvent.getSource() instanceof AbstractStateNotifyingCommand) { +- AbstractStateNotifyingCommand storage = (AbstractStateNotifyingCommand) actionEvent.getSource(); +- // Implementation detail: there is a single StorageCommand instance registered +- // as an OSGi service. We remove ourselves as listener so that we don't get +- // notified in the case that the command is invoked by some other means later. +- storage.getNotifier().removeActionListener(this); +- +- try { +- switch (actionEvent.getActionId()) { +- case START: +- // Payload is connection URL +- Object payload = actionEvent.getPayload(); +- if (payload == null || !(payload instanceof String)) { +- setupSuccessful = false; +- throw new CommandException(t.localize(LocaleResources.UNRECOGNIZED_PAYLOAD_FROM_STORAGE_CMD)); +- } +- final String dbUrl = (String)payload; +- try { +- CommandContext ctx = getAddUserCommandContext(dbUrl); +- decoratee.run(ctx); +- } catch (CommandException e) { +- cmdCtx.getConsole().getError().println(e.getMessage()); +- String msg = t.localize(LocaleResources.ADDING_USER_FAILED).getContents(); +- cmdCtx.getConsole().getError().println(msg); +- } +- break; +- case FAIL: +- // nothing +- break; +- default: +- // nothing +- break; +- } +- } catch (CommandException e) { +- cmdCtx.getConsole().getError().println(e.getMessage()); +- } finally { +- setupFinishedBarrier.countDown(); +- } +- } +- +- } +- +- private CommandContext getAddUserCommandContext(final String dbUrl) { +- CommandContextFactory factory = new CommandContextFactory(context); +- CommandContext ctx = factory.createContext(new Arguments() { +- +- @Override +- public boolean hasArgument(String name) { +- if (name.equals(AddUserCommand.DB_URL_ARG)) { +- return true; +- } +- return false; +- } +- +- @Override +- public List getNonOptionArguments() { +- return Collections.emptyList(); +- } +- +- @Override +- public String getArgument(String name) { +- if (name.equals(AddUserCommand.DB_URL_ARG)) { +- return dbUrl; +- } +- return null; +- } +- }); +- return ctx; +- } +- } +- +- private static class StorageStoppedListener implements ActionListener { +- +- private boolean storageStopPassed; +- private final CountDownLatch storageStoppedLatch; +- private StorageStoppedListener(CountDownLatch latch) { +- storageStoppedLatch = latch; +- } +- +- @Override +- public void actionPerformed(ActionEvent actionEvent) { +- if (actionEvent.getSource() instanceof AbstractStateNotifyingCommand) { +- AbstractStateNotifyingCommand storage = (AbstractStateNotifyingCommand) actionEvent.getSource(); +- // remove ourselves so that we get called more than once. +- storage.getNotifier().removeActionListener(this); +- switch(actionEvent.getActionId()) { +- case STOP: +- storageStopPassed = true; +- storageStoppedLatch.countDown(); +- break; +- default: +- storageStoppedLatch.countDown(); +- break; +- +- } +- } +- } +- +- } +-} +diff --git a/storage/mongo/src/test/java/com/redhat/thermostat/storage/mongodb/internal/AddUserCommandDispatcherTest.java b/storage/mongo/src/test/java/com/redhat/thermostat/storage/mongodb/internal/AddUserCommandDispatcherTest.java +deleted file mode 100644 +--- a/storage/mongo/src/test/java/com/redhat/thermostat/storage/mongodb/internal/AddUserCommandDispatcherTest.java ++++ /dev/null +@@ -1,119 +0,0 @@ +-/* +- * Copyright 2012-2014 Red Hat, Inc. +- * +- * This file is part of Thermostat. +- * +- * Thermostat is free software; you can redistribute it and/or modify +- * it under the terms of the GNU General Public License as published +- * by the Free Software Foundation; either version 2, or (at your +- * option) any later version. +- * +- * Thermostat is distributed in the hope that it will be useful, but +- * WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with Thermostat; see the file COPYING. If not see +- * . +- * +- * Linking this code with other modules is making a combined work +- * based on this code. Thus, the terms and conditions of the GNU +- * General Public License cover the whole combination. +- * +- * As a special exception, the copyright holders of this code give +- * you permission to link this code with independent modules to +- * produce an executable, regardless of the license terms of these +- * independent modules, and to copy and distribute the resulting +- * executable under terms of your choice, provided that you also +- * meet, for each linked independent module, the terms and conditions +- * of the license of that module. An independent module is a module +- * which is not derived from or based on this code. If you modify +- * this code, you may extend this exception to your version of the +- * library, but you are not obligated to do so. If you do not wish +- * to do so, delete this exception statement from your version. +- */ +- +-package com.redhat.thermostat.storage.mongodb.internal; +- +-import static org.junit.Assert.assertEquals; +-import static org.junit.Assert.assertTrue; +-import static org.junit.Assert.fail; +-import static org.mockito.Matchers.eq; +-import static org.mockito.Matchers.any; +-import static org.mockito.Mockito.mock; +-import static org.mockito.Mockito.when; +- +-import org.junit.Test; +-import org.osgi.framework.BundleContext; +- +-import com.redhat.thermostat.common.cli.Arguments; +-import com.redhat.thermostat.common.cli.CommandContext; +-import com.redhat.thermostat.common.cli.CommandContextFactory; +-import com.redhat.thermostat.common.cli.CommandException; +- +-public class AddUserCommandDispatcherTest { +- +- @Test +- public void canRunUndecorated() { +- BundleContext context = mock(BundleContext.class); +- BaseAddUserCommand mockCmd = mock(BaseAddUserCommand.class); +- AddUserCommandDispatcher dispatcher = new AddUserCommandDispatcher(context, mockCmd); +- CommandContextFactory factory = new CommandContextFactory(context); +- Arguments args = mock(Arguments.class); +- when(args.hasArgument(eq("dbUrl"))).thenReturn(true); +- CommandContext ctx = factory.createContext(args); +- +- // This should not throw any exception +- try { +- dispatcher.run(ctx); +- } catch (CommandException e) { +- fail(e.getMessage()); +- } +- } +- +- @Test(expected = CommandException.class ) +- public void failsToRunWithNoArguments() throws CommandException { +- BundleContext context = mock(BundleContext.class); +- BaseAddUserCommand mockCmd = mock(BaseAddUserCommand.class); +- AddUserCommandDispatcher dispatcher = new AddUserCommandDispatcher(context, mockCmd); +- CommandContextFactory factory = new CommandContextFactory(context); +- Arguments args = mock(Arguments.class); +- when(args.hasArgument(any(String.class))).thenReturn(false); +- CommandContext ctx = factory.createContext(args); +- +- // this throws CommandException +- dispatcher.run(ctx); +- } +- +- @Test +- public void decoratesIfStorageStartOptionGiven() { +- BundleContext context = mock(BundleContext.class); +- BaseAddUserCommand mockCmd = mock(BaseAddUserCommand.class); +- AddUserCommandDispatcher dispatcher = new AddUserCommandDispatcher(context, mockCmd); +- CommandContextFactory factory = new CommandContextFactory(context); +- Arguments args = mock(Arguments.class); +- when(args.hasArgument(eq("startStorage"))).thenReturn(true); +- CommandContext ctx = factory.createContext(args); +- +- try { +- dispatcher.run(ctx); +- fail("CommonPaths not available, should have thrown exception"); +- } catch (CommandException e) { +- boolean passed = false; +- for( StackTraceElement elmt: e.getStackTrace()) { +- // StartStopAddUserCommandDecorator should be in stack trace +- if (elmt.getClassName().equals(StartStopAddUserCommandDecorator.class.getName())) { +- passed = true; +- break; +- } +- } +- assertTrue("Expected mocked BaseAddUserCommand to be decorated", passed); +- } +- } +- +- @Test +- public void testCommandName() { +- assertEquals("add-mongodb-user", AddUserCommandDispatcher.COMMAND_NAME); +- } +-} +diff --git a/storage/mongo/src/test/java/com/redhat/thermostat/storage/mongodb/internal/AddUserCommandTest.java b/storage/mongo/src/test/java/com/redhat/thermostat/storage/mongodb/internal/AddUserCommandTest.java +deleted file mode 100644 +--- a/storage/mongo/src/test/java/com/redhat/thermostat/storage/mongodb/internal/AddUserCommandTest.java ++++ /dev/null +@@ -1,116 +0,0 @@ +-/* +- * Copyright 2012-2014 Red Hat, Inc. +- * +- * This file is part of Thermostat. +- * +- * Thermostat is free software; you can redistribute it and/or modify +- * it under the terms of the GNU General Public License as published +- * by the Free Software Foundation; either version 2, or (at your +- * option) any later version. +- * +- * Thermostat is distributed in the hope that it will be useful, but +- * WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with Thermostat; see the file COPYING. If not see +- * . +- * +- * Linking this code with other modules is making a combined work +- * based on this code. Thus, the terms and conditions of the GNU +- * General Public License cover the whole combination. +- * +- * As a special exception, the copyright holders of this code give +- * you permission to link this code with independent modules to +- * produce an executable, regardless of the license terms of these +- * independent modules, and to copy and distribute the resulting +- * executable under terms of your choice, provided that you also +- * meet, for each linked independent module, the terms and conditions +- * of the license of that module. An independent module is a module +- * which is not derived from or based on this code. If you modify +- * this code, you may extend this exception to your version of the +- * library, but you are not obligated to do so. If you do not wish +- * to do so, delete this exception statement from your version. +- */ +- +-package com.redhat.thermostat.storage.mongodb.internal; +- +-import static org.junit.Assert.assertSame; +-import static org.junit.Assert.assertTrue; +-import static org.mockito.Mockito.inOrder; +-import static org.mockito.Mockito.mock; +-import static org.mockito.Mockito.when; +- +-import java.util.Arrays; +-import java.util.concurrent.CountDownLatch; +- +-import org.junit.Test; +-import org.junit.runner.RunWith; +-import org.mockito.InOrder; +-import org.powermock.api.mockito.PowerMockito; +-import org.powermock.core.classloader.annotations.PowerMockIgnore; +-import org.powermock.core.classloader.annotations.PrepareForTest; +-import org.powermock.modules.junit4.PowerMockRunner; +- +-import com.mongodb.DB; +-import com.redhat.thermostat.storage.core.QueuedStorage; +-import com.redhat.thermostat.storage.core.Storage; +-import com.redhat.thermostat.storage.core.StorageCredentials; +- +-//There is a bug (resolved as wontfix) in powermock which results in +-//java.lang.LinkageError if javax.management.* classes aren't ignored by +-//Powermock. More here: http://code.google.com/p/powermock/issues/detail?id=277 +-//SSL tests need this and having that annotation on method level doesn't seem +-//to solve the issue. +-@PowerMockIgnore( {"javax.management.*"}) +-@RunWith(PowerMockRunner.class) +-@PrepareForTest({ DB.class }) +-public class AddUserCommandTest { +- +- /* +- * Verifies that credentials' methods are called in the right order and +- * the password array is filled with zeros after use. +- */ +- @Test +- public void verifyAddUser() { +- DB db = PowerMockito.mock(DB.class); +- CountDownLatch latch = new CountDownLatch(1); +- MongoStorage storage = new MongoStorage(db, latch); +- +- StorageCredentials creds = mock(StorageCredentials.class); +- String username = "fooUser"; +- char[] password = new char[] { 'f', 'o', 'o' }; +- when(creds.getUsername()).thenReturn(username); +- when(creds.getPassword()).thenReturn(password); +- InOrder inOrder = inOrder(creds); +- +- AddUserCommand command = new AddUserCommand(null /* unused */); +- command.addUser(storage, creds); +- +- // password should have been zero-filled +- assertTrue(Arrays.equals(new char[] { '\0', '\0', '\0' }, password)); +- // First username, then password should get called. +- inOrder.verify(creds).getUsername(); +- inOrder.verify(creds).getPassword(); +- } +- +- /* +- * Verifies if the delegate can be retrieved from QueuedStorage since +- * AddUserCommand relies on this. In particular the delegate needs to be +- * a MongoStorage instance. +- */ +- @Test +- public void verifyGettingDelegateWorks() { +- DB db = PowerMockito.mock(DB.class); +- CountDownLatch latch = new CountDownLatch(1); +- // Delegate must be mongostorage +- MongoStorage storage = new MongoStorage(db, latch); +- +- QueuedStorage qStorage = new QueuedStorage(storage); +- AddUserCommand command = new AddUserCommand(null /* unused */); +- Storage actual = command.getDelegate(qStorage); +- +- assertSame(storage, actual); +- } +-} +diff --git a/storage/mongo/src/test/java/com/redhat/thermostat/storage/mongodb/internal/BaseAddUserCommandTest.java b/storage/mongo/src/test/java/com/redhat/thermostat/storage/mongodb/internal/BaseAddUserCommandTest.java +deleted file mode 100644 +--- a/storage/mongo/src/test/java/com/redhat/thermostat/storage/mongodb/internal/BaseAddUserCommandTest.java ++++ /dev/null +@@ -1,62 +0,0 @@ +-/* +- * Copyright 2012-2014 Red Hat, Inc. +- * +- * This file is part of Thermostat. +- * +- * Thermostat is free software; you can redistribute it and/or modify +- * it under the terms of the GNU General Public License as published +- * by the Free Software Foundation; either version 2, or (at your +- * option) any later version. +- * +- * Thermostat is distributed in the hope that it will be useful, but +- * WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with Thermostat; see the file COPYING. If not see +- * . +- * +- * Linking this code with other modules is making a combined work +- * based on this code. Thus, the terms and conditions of the GNU +- * General Public License cover the whole combination. +- * +- * As a special exception, the copyright holders of this code give +- * you permission to link this code with independent modules to +- * produce an executable, regardless of the license terms of these +- * independent modules, and to copy and distribute the resulting +- * executable under terms of your choice, provided that you also +- * meet, for each linked independent module, the terms and conditions +- * of the license of that module. An independent module is a module +- * which is not derived from or based on this code. If you modify +- * this code, you may extend this exception to your version of the +- * library, but you are not obligated to do so. If you do not wish +- * to do so, delete this exception statement from your version. +- */ +- +-package com.redhat.thermostat.storage.mongodb.internal; +- +-import static org.junit.Assert.assertFalse; +- +-import org.junit.Test; +- +-import com.redhat.thermostat.common.cli.CommandContext; +-import com.redhat.thermostat.common.cli.CommandException; +- +-public class BaseAddUserCommandTest { +- +- @Test +- public void storageRequiredFalse() { +- TestAddUserCommand cmd = new TestAddUserCommand(); +- assertFalse(cmd.isStorageRequired()); +- } +- +- private static class TestAddUserCommand extends BaseAddUserCommand { +- +- @Override +- public void run(CommandContext ctx) throws CommandException { +- // no-op +- } +- +- } +-} diff --git a/SOURCES/rhbz1221989.patch b/SOURCES/rhbz1221989.patch new file mode 100644 index 0000000..68bb7ec --- /dev/null +++ b/SOURCES/rhbz1221989.patch @@ -0,0 +1,469 @@ +diff --git a/distribution/scripts/thermostat-setup b/distribution/scripts/thermostat-setup +--- a/distribution/scripts/thermostat-setup ++++ b/distribution/scripts/thermostat-setup +@@ -122,7 +122,6 @@ + # in this script already, but failed somewhere + # down the line. + removeTempStampFile +- cleanupSedFiles + echo 'Thermostat setup failed!' 1>&2 + stty "$tty_flags" + exit 1 +@@ -137,18 +136,10 @@ + fi + } + +-cleanupSedFiles() { +- if [ ! -z "$SED_FILES_DIR" ] && +- [ -e $SED_FILES_DIR ]; then +- rm -rf "$SED_FILES_DIR" +- fi +-} +- + exitSuccess() { + # Remove temporary unlock file and create the actual setup-complete + # file. + removeTempStampFile +- cleanupSedFiles + echo $SETUP_UNLOCK_CONTENT_REGULAR > "$SETUP_COMPLETE_FILE" + echo -e "\nThermostat setup complete!\n" + echo -e "Be sure to configure thermostat-users.properties and" +@@ -206,45 +197,19 @@ + default_webapp="$THERMOSTAT_HOME/webapp" + THERMOSTAT_WEBAPP_LOCATION="$(readlink -f $default_webapp)" + fi +- TH_WEB_INF="$THERMOSTAT_WEBAPP_LOCATION/WEB-INF/web.xml" ++ TH_WEB_INF="$THERMOSTAT_WEBAPP_LOCATION/WEB-INF/web.auth" + + if [ ! -e $TH_WEB_INF ]; then + echo "File not found: $TH_WEB_INF" 1>&2 + exitFail + fi + +- # We use this var for cleaning up after sed has run and +- # the script exits. +- SED_FILES_DIR="$(mktemp -d)" +- setSedExprs "storage.username" "$USERNAME" +- writeSedFiles "$SED_FILES_DIR" "storage.username" +- SED_CMD_USER1="sed -i -f $SED_FILE_UNCOMMENTED $TH_WEB_INF" +- SED_CMD_USER2="sed -i -f $SED_FILE_COMMENTED $TH_WEB_INF" +- +- setSedExprs "storage.password" "$PASSWORD" +- writeSedFiles "$SED_FILES_DIR" "storage.password" +- SED_CMD_PWD1="sed -i -f $SED_FILE_UNCOMMENTED $TH_WEB_INF" +- SED_CMD_PWD2="sed -i -f $SED_FILE_COMMENTED $TH_WEB_INF" +- + if [ ! -w $TH_WEB_INF ]; then +- local sed_one_line_user="$SED_CMD_USER1 && $SED_CMD_USER2" +- local sed_one_line_pwd="$SED_CMD_PWD1 && $SED_CMD_PWD2" + echo -e "\n\nWARNING: $(readlink -f $TH_WEB_INF) is NOT writable.\n" +- echo -e "You have the following options:\n" +- echo -e " 1. Run the following command(s) as root:" +- echo -e " #> $sed_one_line_user" +- echo -e " #> $sed_one_line_pwd" +- echo -e " #> rm -r $SED_FILES_DIR" +- echo -e " 2. Modify the file manually and add the following" +- echo -e " credentials config snippet (in 'servlet'):" +- echo -e " " +- echo -e " storage.username" +- echo -e " $USERNAME" +- echo -e " " +- echo -e " " +- echo -e " storage.password" +- echo -e " $PASSWORD" +- echo -e " " ++ echo -e " Modify the file manually and add the following" ++ echo -e " credentials config snippet:" ++ echo -e " storage.username = $USERNAME" ++ echo -e " storage.password = $PASSWORD" + echo -e " The file in which you need to put this snippet" + echo -e " is:" + echo -e " $TH_WEB_INF" +@@ -252,9 +217,9 @@ + else + # Run the sed command(s) + local sedSuccess=0 +- $SED_CMD_USER1 && $SED_CMD_USER2 ++ echo "storage.username = $USERNAME" > "$TH_WEB_INF" + sedSuccess=$(( $sedSuccess + $? )) +- $SED_CMD_PWD1 && $SED_CMD_PWD2 ++ echo "storage.password = $PASSWORD" >> "$TH_WEB_INF" + sedSuccess=$(( $sedSuccess + $? )) + if [ $sedSuccess -eq 0 ]; then + exitSuccess +@@ -265,109 +230,6 @@ + fi + } + +-writeSedFiles() { +- local tmpDir="$1" +- local paramName="$2" +- SED_FILE_UNCOMMENTED="$tmpDir/uncommented-${paramName}.sed" +- SED_FILE_COMMENTED="$tmpDir/commented-${paramName}.sed" +- echo "$SED_EXPR_COMMENTED" > $SED_FILE_COMMENTED +- echo "$SED_EXPR_UNCOMMENTED" > $SED_FILE_UNCOMMENTED +-} +- +-setSedExprs() { +- local paramName=$1 +- local paramVal=$2 +- setSedExprUnCommented "$paramName" "$paramVal" +- setSedExprCommented "$paramName" "$paramVal" +-} +- +-setSedExprCommented() { +- local paramName=$1 +- local paramVal=$2 +- SED_EXPR_COMMENTED=" +- # Finds pattern A and replaces it with B. +- # +- # Pattern A is something like the following: +- # +- # +- # Replacement (B) would then be: +- # +- # +- # storage.username +- # foo-bar +- # +- # +- # In essence it removes the comments and sets +- # the param value we want. +- # +- /<[!]--/ { +- N +- // { +- N +- /$paramName<[/]param-name>/ { +- N +- /.*<[/]param-value>/ { +- N +- /<[/]init-param>/ { +- N +- /-->/ { +- N +- # Do the substitution with all matching lines in +- # current buffer +- s%.*<[!]--\n.*\n.*$paramName<[/]param-name>\n.*.*<[/]param-value>.*<[/]init-param>.*-->%\n$paramName\n$paramVal\n% +- } +- } +- } +- } +- } +- }" +-} +- +-setSedExprUnCommented() { +- paramName=$1 +- paramVal=$2 +- SED_EXPR_UNCOMMENTED=" +- # Finds pattern C and replaces it with D. +- # +- # Pattern C is something like the following: +- # +- # storage.username +- # something +- # +- # +- # Replacement (D) would then be: +- # +- # +- # storage.username +- # foo-bar +- # +- # +- # I.e. it changes the username to what we'd +- # like it to be. If that section is already +- # in place (not commented out) +- # +- // { +- N +- /$paramName<[/]param-name>/ { +- N +- /.*<[/]param-value>/ { +- N +- /<[/]init-param>/ { +- N +- # Do the substitution with all matching lines in +- # current buffer +- s%.*\n.*$paramName<[/]param-name>\n.*.*<[/]param-value>.*<[/]init-param>%\n$paramName\n$paramVal\n% +- } +- } +- } +- }" +-} +- + readUsername() { + dUsername="$1" + prompt="Please enter the desired Mongodb username (press return in order to use '$dUsername'): " +diff --git a/pom.xml b/pom.xml +--- a/pom.xml ++++ b/pom.xml +@@ -98,17 +98,11 @@ + mongodevpassword + + +- <init-param> +- <param-name>storage.username</param-name> +- <param-value>${mongodb.dev.username}</param-value> +- </init-param> ++storage.username=${mongodb.dev.username} + + + +- <init-param> +- <param-name>storage.password</param-name> +- <param-value>${mongodb.dev.password}</param-value> +- </init-param> ++storage.password=${mongodb.dev.password} + + + +- <!-- +- <init-param> +- <param-name>storage.username</param-name> +- <param-value>thermostat-mongodb-user</param-value> +- </init-param> +- --> ++#storage.username=thermostat-mongodb-user + + + +- <!-- +- <init-param> +- <param-name>storage.password</param-name> +- <param-value>supersecrit</param-value> +- </init-param> +- --> ++#storage.password=supersecrit + + + + + true + src/main/webapp + + **/web.xml ++ **/web.auth + + + +@@ -244,6 +244,7 @@ + src/main/webapp + + **/web.xml ++ **/web.auth + + + +diff --git a/web/war/src/main/webapp/WEB-INF/web.auth b/web/war/src/main/webapp/WEB-INF/web.auth +new file mode 100644 +--- /dev/null ++++ b/web/war/src/main/webapp/WEB-INF/web.auth +@@ -0,0 +1,11 @@ ++# Credentials to use for connecting to the backing storage ++# (currently mongodb). Uncomment the following two blocks in ++# order to use this username/password for the connection. ++ ++# Username to use for connecting to the backing storage ++# implementation ++${web.war.backingstorage.username.snippet} ++ ++# Password to use for connecting to the backing storage ++# implementation ++${web.war.backingstorage.password.snippet} +diff --git a/web/war/src/main/webapp/WEB-INF/web.xml b/web/war/src/main/webapp/WEB-INF/web.xml +--- a/web/war/src/main/webapp/WEB-INF/web.xml ++++ b/web/war/src/main/webapp/WEB-INF/web.xml +@@ -52,16 +52,6 @@ + storage.endpoint + mongodb://127.0.0.1:27518 + +- +- +- +- ${web.war.backingstorage.username.snippet} +- +- ${web.war.backingstorage.password.snippet} + + + token-manager-timeout diff --git a/SOURCES/scl-thermostat-tomcat-service-sysconfig b/SOURCES/scl-thermostat-tomcat-service-sysconfig index c398565..3b879b8 100644 --- a/SOURCES/scl-thermostat-tomcat-service-sysconfig +++ b/SOURCES/scl-thermostat-tomcat-service-sysconfig @@ -1,56 +1,6 @@ -# Service-specific configuration file for tomcat. This will be sourced by -# the SysV init script after the global configuration file -# /etc/tomcat/tomcat.conf, thus allowing values to be overridden in -# a per-service manner. +# Custom configuration for Thermostat's CATALINA_BASE based tomcat. # -# NEVER change the init script itself. To change values for all services make -# your changes in /etc/tomcat/tomcat.conf -# -# To change values for a specific service make your edits here. -# To create a new service create a link from /etc/init.d/ to -# /etc/init.d/tomcat (do not copy the init script) and make a copy of the -# /etc/sysconfig/tomcat file to /etc/sysconfig/ and change -# the property values so the two services won't conflict. Register the new -# service in the system as usual (see chkconfig and similars). -# - -# Where your java installation lives -#JAVA_HOME="/usr/lib/jvm/java" - # Where your tomcat installation lives CATALINA_BASE="__catalina_base__" CATALINA_HOME="/usr/share/tomcat" -#JASPER_HOME="/usr/share/tomcat" -#CATALINA_TMPDIR="/var/cache/tomcat/temp" - -# You can pass some parameters to java here if you wish to -#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3" - -# Use JAVA_OPTS to set java.library.path for libtcnative.so JAVA_OPTS="-Djava.security.auth.login.config=__jaas_config__" - -# What user should run tomcat -#TOMCAT_USER="tomcat" - -# You can change your tomcat locale here -#LANG="en_US" - -# Run tomcat under the Java Security Manager -#SECURITY_MANAGER="false" - -# Time to wait in seconds, before killing process -#SHUTDOWN_WAIT="30" - -# Whether to annoy the user with "attempting to shut down" messages or not -#SHUTDOWN_VERBOSE="false" - -# Set the TOMCAT_PID location -#CATALINA_PID="/var/run/thermostat-tomcat.pid" - -# Connector port is 8080 for this tomcat instance -#CONNECTOR_PORT="8080" - -# If you wish to further customize your tomcat environment, -# put your own definitions here -# (i.e. LD_LIBRARY_PATH for some jdbc drivers) - diff --git a/SOURCES/scl-tomcat-systemd.service b/SOURCES/scl-tomcat-systemd.service index 52fc81d..f3b359e 100644 --- a/SOURCES/scl-tomcat-systemd.service +++ b/SOURCES/scl-tomcat-systemd.service @@ -1,15 +1,8 @@ -# Thermostat tomcat systemd service file. +# Thermostat tomcat systemd service file for RHEL 7.0. # -# See tomcat's default systemd service file for -# details as to how this was created and why. -# -# In a nutshell, this allows us to start tomcat with -# some custom configuration: -# -# 1. Deploys the thermostat webapp in /opt on boot -# 2. Sets relevant JAAS config via -# /etc/sysconfig/${SERVICE_NAME}. - +# Please start tomcat via "service tomcat@thermostat start" or +# "systemctl start tomcat@thermostat" instead if you are using +# RHEL-7.1. [Unit] Description=Apache Tomcat for Thermostat Container After=syslog.target network.target diff --git a/SOURCES/servlet_api_jar.patch b/SOURCES/servlet_api_jar.patch new file mode 100644 index 0000000..2855f16 --- /dev/null +++ b/SOURCES/servlet_api_jar.patch @@ -0,0 +1,12 @@ +diff --git a/web/endpoint-plugin/distribution/thermostat-plugin.xml b/web/endpoint-plugin/distribution/thermostat-plugin.xml +--- a/web/endpoint-plugin/distribution/thermostat-plugin.xml ++++ b/web/endpoint-plugin/distribution/thermostat-plugin.xml +@@ -65,7 +65,7 @@ + org.eclipse.jetty.servlet${jetty.version} + org.eclipse.jetty.xml${jetty.version} + org.eclipse.jetty.jaas${jetty.version} +- javax.servlet-api${jetty.javax.servlet.osgi.version} ++ javax.servlet${jetty.javax.servlet.osgi.version} + + com.redhat.thermostat.agent.core${project.version} diff --git a/SOURCES/thermostat-sysconfig b/SOURCES/thermostat-sysconfig index 2b735b9..a72ad63 100644 --- a/SOURCES/thermostat-sysconfig +++ b/SOURCES/thermostat-sysconfig @@ -6,4 +6,4 @@ # Do not change this unless you know what you are doing THERMOSTAT_HOME=__thermostat_home__ USER_THERMOSTAT_HOME=__user_thermostat_home__ -THERMOSTAT1_SCLS_ENABLED="thermostat1 mongodb24" +THERMOSTAT1_SCLS_ENABLED="thermostat1 rh-mongodb26" diff --git a/SOURCES/thermostat_setup_ctrl_c.patch b/SOURCES/thermostat_setup_ctrl_c.patch new file mode 100644 index 0000000..832639a --- /dev/null +++ b/SOURCES/thermostat_setup_ctrl_c.patch @@ -0,0 +1,30 @@ +# HG changeset patch +# User Omair Majid +# Date 1426001971 14400 +# Tue Mar 10 11:39:31 2015 -0400 +# Node ID db706e3e09ed947ff77cbe75e23dd82c5d6b8b82 +# Parent 505bcac210496aadb32b9be4a0869260fe0a5005 +Don't break terminal on Ctrl-c when reading password +Reviewed-by: jerboaa +Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2015-March/013058.html + +diff --git a/distribution/scripts/thermostat-setup b/distribution/scripts/thermostat-setup +--- a/distribution/scripts/thermostat-setup ++++ b/distribution/scripts/thermostat-setup +@@ -56,6 +56,8 @@ + # For debugging + #set -xv + ++tty_flags="$(stty -g)" ++ + # Interruptions are failures + trap exitFail SIGINT + +@@ -122,6 +124,7 @@ + removeTempStampFile + cleanupSedFiles + echo 'Thermostat setup failed!' 1>&2 ++ stty "$tty_flags" + exit 1 + } + diff --git a/SOURCES/user_thermostat_home_new_default.patch b/SOURCES/user_thermostat_home_new_default.patch new file mode 100644 index 0000000..144b59f --- /dev/null +++ b/SOURCES/user_thermostat_home_new_default.patch @@ -0,0 +1,36 @@ +diff --git a/config/src/main/java/com/redhat/thermostat/shared/config/internal/CommonPathsImpl.java b/config/src/main/java/com/redhat/thermostat/shared/config/internal/CommonPathsImpl.java +--- a/config/src/main/java/com/redhat/thermostat/shared/config/internal/CommonPathsImpl.java ++++ b/config/src/main/java/com/redhat/thermostat/shared/config/internal/CommonPathsImpl.java +@@ -88,7 +88,7 @@ + private static final String THERMOSTAT_SYSTEM_USER = "THERMOSTAT_SYSTEM_USER"; + + +- private static final String THERMOSTAT_USER_DIR = ".thermostat"; ++ private static final String THERMOSTAT_USER_DIR = ".thermostat-1.2"; + + private static final Translate t = LocaleResources.createLocalizer(); + +diff --git a/distribution/scripts/thermostat-devsetup b/distribution/scripts/thermostat-devsetup +--- a/distribution/scripts/thermostat-devsetup ++++ b/distribution/scripts/thermostat-devsetup +@@ -49,7 +49,7 @@ + THERMOSTAT_SETUP="$THERMOSTAT_HOME/bin/thermostat-setup" + DEV_INPUT="$THERMOSTAT_HOME/etc/devsetup.input" + if [ "x$USER_THERMOSTAT_HOME" == "x" ]; then +- USER_THERMOSTAT_HOME="$HOME/.thermostat" ++ USER_THERMOSTAT_HOME="$HOME/.thermostat-1.2" + fi + + # Call the setup script +diff --git a/distribution/scripts/thermostat-setup b/distribution/scripts/thermostat-setup +--- a/distribution/scripts/thermostat-setup ++++ b/distribution/scripts/thermostat-setup +@@ -103,7 +103,7 @@ + export THERMOSTAT_HOME + # Thermostat user home + if [ "x$USER_THERMOSTAT_HOME" = "x" ]; then +- USER_THERMOSTAT_HOME="$HOME/.thermostat" ++ USER_THERMOSTAT_HOME="$HOME/.thermostat-1.2" + fi + export USER_THERMOSTAT_HOME + THERMOSTAT="$THERMOSTAT_HOME/bin/thermostat" diff --git a/SOURCES/webstorage_service_custom_jaas.patch b/SOURCES/webstorage_service_custom_jaas.patch new file mode 100644 index 0000000..6b5eb6d --- /dev/null +++ b/SOURCES/webstorage_service_custom_jaas.patch @@ -0,0 +1,59 @@ +diff --git a/distribution/config/thermostat_webstorageservice_jaas.conf b/distribution/config/thermostat_webstorageservice_jaas.conf +new file mode 100644 +--- /dev/null ++++ b/distribution/config/thermostat_webstorageservice_jaas.conf +@@ -0,0 +1,10 @@ ++ThermostatJAASLogin { ++ com.redhat.thermostat.web.server.auth.spi.DelegateLoginModule required debug=false; ++}; ++ ++ThermostatJAASDelegate { ++ com.redhat.thermostat.web.server.auth.spi.PropertiesUsernameRolesLoginModule required ++ debug=false ++ users.properties="\${user.home}/.thermostat-1.2/etc/thermostat-users.properties" ++ roles.properties="\${user.home}/.thermostat-1.2/etc/thermostat-roles.properties" ; ++}; +diff --git a/distribution/pom.xml b/distribution/pom.xml +--- a/distribution/pom.xml ++++ b/distribution/pom.xml +@@ -173,6 +173,7 @@ + thermostat-users.properties + thermostat-roles.properties + thermostat_jaas.conf ++ thermostat_webstorageservice_jaas.conf + devsetup.input + db.properties + logging.properties +@@ -186,6 +187,7 @@ + true + + ++ \ + + + +diff --git a/web/endpoint-plugin/web-service/src/main/java/com/redhat/thermostat/web/endpoint/internal/EmbeddedServletContainerConfiguration.java b/web/endpoint-plugin/web-service/src/main/java/com/redhat/thermostat/web/endpoint/internal/EmbeddedServletContainerConfiguration.java +--- a/web/endpoint-plugin/web-service/src/main/java/com/redhat/thermostat/web/endpoint/internal/EmbeddedServletContainerConfiguration.java ++++ b/web/endpoint-plugin/web-service/src/main/java/com/redhat/thermostat/web/endpoint/internal/EmbeddedServletContainerConfiguration.java +@@ -177,7 +177,7 @@ + + String getAbsolutePathToJaasConfig() throws InvalidConfigurationException { + File etcPath = paths.getSystemConfigurationDirectory(); +- File thermostatJaasConf = new File(etcPath, "thermostat_jaas.conf"); ++ File thermostatJaasConf = new File(etcPath, "thermostat_webstorageservice_jaas.conf"); + try { + return thermostatJaasConf.getCanonicalPath(); + } catch (IOException e) { +diff --git a/distribution/scripts/thermostat-setup b/distribution/scripts/thermostat-setup +--- a/distribution/scripts/thermostat-setup ++++ b/distribution/scripts/thermostat-setup +@@ -166,7 +166,8 @@ + echo -e "\nBe sure to configure $TH_WEB_INF as mentioned above." + echo -e "\nThen, make sure to configure thermostat-users.properties and" + echo -e "thermostat-roles.properties before you attempt connections" +- echo -e "with agent(s) and/or client(s)." ++ echo -e "with agent(s) and/or client(s). For web-storage-service these" ++ echo -e "files need to be in your home directory under .thermostat-1.2/etc/." + exit 0 + } + diff --git a/SPECS/thermostat.spec b/SPECS/thermostat.spec index 6113c3e..6f4255d 100644 --- a/SPECS/thermostat.spec +++ b/SPECS/thermostat.spec @@ -1,7 +1,7 @@ # Thermostat version %global major 1 -%global minor 0 -%global patchlevel 4 +%global minor 2 +%global patchlevel 0 # Real OSGi Bundle-Version is 3.6.6.Final %global netty_bundle_version 3.6.3 %global jcommon_bundle_version 1.0.18 @@ -16,9 +16,9 @@ %global logging_bundle_version 1.1.2 # Real OSGi Bundle-Version is 2.11.3.RELEASE %global mongo_bundle_version 2.11.3 -%global hc_core_bundle_version 4.2.4 -%global hc_client_bundle_version 4.2.5 -%global gson_bundle_version 2.2.4 +%global hc_core_bundle_version 4.3.3 +%global hc_client_bundle_version 4.3.6 +%global gson_bundle_version 2.2.2 # Base path to the JDK which will be used in boot scripts %global jdk_base /usr/lib/jvm/java-1.7.0-openjdk @@ -29,6 +29,9 @@ %{?scl:%scl_package thermostat} %{!?scl:%global pkg_name %{name}} +# Use java common's requires/provides generator +%{?java_common_find_provides_and_requires} + # Global directory definitions %global system_datadir %{_root_localstatedir}/lib/%{pkg_name} %global system_cachedir %{_root_localstatedir}/cache/%{pkg_name} @@ -85,7 +88,7 @@ Version: %{major}.%{minor}.%{patchlevel} # 60.X where X is an increasing int. 60 for rhel-6. We use # 70.X for rhel-7. For some reason we cannot rely on the # dist tag. -Release: 70.6%{?dist} +Release: 70.12%{?dist} Summary: A monitoring and serviceability tool for OpenJDK License: GPLv2+ with exceptions and OFL URL: http://icedtea.classpath.org/thermostat/ @@ -115,59 +118,87 @@ Patch0: fix_bundle_loading.patch # is 4.3 OSGi spec. Patch1: osgi_spec_fixes.patch # This is _NOT_ suitable for upstream at this point. -# Sets the default log level to something reasonable (if during release procedure -# it was forgotten to set it). Not upstream-able. -Patch2: fix_loglevel.patch -# This is _NOT_ suitable for upstream at this point. # It makes thermostat itself ignore bundle versions put into thermostat's files # at build-time. Over time versions of bundles may change. For packaged # thermostat we rely on RPM enforcing a working set of bundle<=>version pairs that # work. See: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1591 -Patch3: ignore_bundle_versions.patch -# This security fix is scheduled to be upstreamed in the next maintenance release -# of the 1.0 branch. -Patch4: agent_remove_rmi.patch - -BuildRequires: maven-local -BuildRequires: xmvn -BuildRequires: maven-dependency-plugin -BuildRequires: maven-surefire-plugin -BuildRequires: maven-surefire-provider-junit4 -BuildRequires: maven-war-plugin -BuildRequires: maven-clean-plugin -BuildRequires: maven-assembly-plugin -BuildRequires: maven-plugin-bundle -BuildRequires: maven-javadoc-plugin +Patch2: ignore_bundle_versions.patch +# Not suitable for upstream. Different OSGi version means some API compat issues. +Patch3: osgi_api_fixes.patch +# FIXME remove when upstream supports mongodb 2.6 ootb. +Patch4: mongodb26_setup_changes.patch +# Ditto (command does not work with 2.6) +Patch5: remove_adduser_command.patch +# FIXME: remove once rebased to >= 1.2.4 Upstream commit: +# http://icedtea.classpath.org/hg/release/thermostat-1.2/rev/0f250b6c47e8 +Patch6: fix_lucene_symbolic_name.patch +# FIXME: remove once rebased to >= 1.2.4, RHBZ#1199581, Upstream commit: +# http://icedtea.classpath.org/hg/release/thermostat-1.2/rev/1cfebde69814 +Patch7: thermostat_setup_ctrl_c.patch +# Set USER_THERMOSTAT_HOME default to ~/.thermostat-1.2 since this allows +# for better data migration from 1.0 Thermostat. +Patch8: user_thermostat_home_new_default.patch +# jetty provides the javax.servlet API +Patch9: servlet_api_jar.patch +# Allow 'thermostat web-storage-service' to read configs from +# ~/.thermostat, by using a custom jaas config. +Patch10: webstorage_service_custom_jaas.patch +# Remove when this lands in a release: +# http://icedtea.classpath.org/hg/thermostat/rev/296194a48778 +Patch11: non_existent_bundle.patch +# Upstream puts passwords in a world-readable location +Patch12: rhbz1221989.patch + BuildRequires: libgnome-keyring-devel -BuildRequires: felix-framework -BuildRequires: fusesource-pom # laf-utils JNI need pkconfig files for gtk2+ BuildRequires: gtk2-devel # Use tomcat only for web storage BuildRequires: tomcat-servlet-3.0-api # Bootstrap bundles (started via file name) -BuildRequires: apache-commons-cli -BuildRequires: jansi -BuildRequires: %{?scl_prefix}jline2 >= 2.5-7 +BuildRequires: rh-java-common-apache-commons-cli +BuildRequires: rh-java-common-jansi +BuildRequires: %{?scl_prefix}jline2 >= 2.10-3 # SCL-carried OSGi bundles BuildRequires: %{?scl_prefix}jfreechart >= 1.0.14-7 BuildRequires: %{?scl_prefix}jcommon >= 1.0.17-4 BuildRequires: %{?scl_prefix}netty -BuildRequires: %{?scl_prefix}lucene >= 3.6.0-6 -BuildRequires: %{?scl_prefix}google-gson BuildRequires: %{?scl_prefix}apache-commons-fileupload -BuildRequires: apache-commons-logging -BuildRequires: apache-commons-beanutils -BuildRequires: apache-commons-codec -BuildRequires: httpcomponents-core -BuildRequires: httpcomponents-client +# rh-java-common collection dependencies +BuildRequires: rh-java-common-apache-commons-beanutils +BuildRequires: rh-java-common-apache-commons-codec +BuildRequires: rh-java-common-apache-commons-logging +BuildRequires: rh-java-common-felix-framework +BuildRequires: rh-java-common-google-gson +BuildRequires: rh-java-common-httpcomponents-client +BuildRequires: rh-java-common-httpcomponents-core +BuildRequires: rh-java-common-lucene >= 4.8.0 +BuildRequires: rh-java-common-lucene-analysis >= 4.8.0 +BuildRequires: rh-java-common-maven-local +# thermostat web-storage-service BRs +BuildRequires: rh-java-common-jetty-server +BuildRequires: rh-java-common-jetty-jaas +BuildRequires: rh-java-common-jetty-webapp +# TODO schemas are needed for offline validation of some xml files +# BuildRequires: rh-java-common-jetty-schemas + +# maven30 collection dependencies +BuildRequires: maven30-xmvn +BuildRequires: maven30-maven-dependency-plugin +BuildRequires: maven30-maven-surefire-plugin +BuildRequires: maven30-maven-surefire-provider-junit +BuildRequires: maven30-maven-war-plugin +BuildRequires: maven30-maven-clean-plugin +BuildRequires: maven30-maven-assembly-plugin +BuildRequires: maven30-maven-plugin-bundle +BuildRequires: maven30-maven-javadoc-plugin +BuildRequires: maven30-fusesource-pom # Mongodb Java driver comes from the mongodb collection -BuildRequires: mongodb24 -BuildRequires: mongodb24-mongo-java-driver +BuildRequires: rh-mongodb26 +BuildRequires: rh-mongodb26-mongo-java-driver # The following BR is SCL only %{?scl:BuildRequires: tomcat} @@ -176,13 +207,10 @@ BuildRequires: mongodb24-mongo-java-driver Requires: java-1.7.0-openjdk-devel Requires: libgnome-keyring -# Things coming from the mongodb24 collection -Requires: mongodb24 -Requires: mongodb24-mongodb -Requires: mongodb24-mongodb-server - -# This module has been removed to fix RHBZ#1170141 -Obsoletes: %{scl_prefix}mvn(com.redhat.thermostat:thermostat-agent-proxy-common) <= %{version} +# Things coming from the mongodb26 collection +Requires: rh-mongodb26 +Requires: rh-mongodb26-mongodb +Requires: rh-mongodb26-mongodb-server Requires(post): systemd Requires(preun): systemd @@ -222,7 +250,7 @@ for Thermostat's Web layer. %prep -%{?scl:scl enable %{scl} - << "EOF"} +%{?scl:scl enable %{scl} maven30 rh-java-common rh-mongodb26 - << "EOF"} # When Source0 is released version. %setup -q -n %{pkg_name}-%{version} @@ -235,11 +263,25 @@ for Thermostat's Web layer. %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 # Fix up artifact names which have different name upstream # lucene -%pom_remove_dep "org.apache.servicemix.bundles:org.apache.servicemix.bundles.lucene" common/core -%pom_add_dep "org.apache.lucene:lucene-core:3.6.0" common/core +%pom_remove_dep "org.apache.servicemix.bundles:org.apache.servicemix.bundles.lucene" vm-heap-analysis/common +%pom_remove_dep "org.apache.servicemix.bundles:org.apache.servicemix.bundles.lucene" vm-heap-analysis/distribution +%pom_remove_dep "org.apache.servicemix.bundles:org.apache.servicemix.bundles.lucene-analyzers-common" vm-heap-analysis/common +%pom_remove_dep "org.apache.servicemix.bundles:org.apache.servicemix.bundles.lucene-analyzers-common" vm-heap-analysis/distribution +%pom_add_dep "org.apache.lucene:lucene-analyzers-common:4.8.0" vm-heap-analysis/common +%pom_add_dep "org.apache.lucene:lucene-analyzers:4.8.0" vm-heap-analysis/distribution +%pom_add_dep "org.apache.lucene:lucene-core:4.8.0" vm-heap-analysis/common +%pom_add_dep "org.apache.lucene:lucene-core:4.8.0" vm-heap-analysis/distribution # httpclient %pom_remove_dep org.apache.httpcomponents:httpclient-osgi web/client %pom_add_dep org.apache.httpcomponents:httpclient:4.1.2 web/client @@ -270,13 +312,24 @@ for Thermostat's Web layer. # Remove m2e's lifecyle plugin %pom_remove_plugin org.eclipse.m2e:lifecycle-mapping -# Disable dev and integation-tests modules +# Remove license-maven-plugin +%pom_remove_plugin com.mycila:license-maven-plugin + +# Disable dev and testing-only modules %pom_disable_module dev +%pom_disable_module test common %pom_disable_module integration-tests +%pom_disable_module testutils storage +%pom_remove_dep com.redhat.thermostat:thermostat-storage-testutils vm-cpu/common +%pom_remove_dep com.redhat.thermostat:thermostat-storage-testutils vm-profiler/common +%pom_remove_dep com.redhat.thermostat:thermostat-storage-testutils thread/collector -# Part of the disable webservice patch can be done with pom macros -%pom_remove_dep org.eclipse.jetty:jetty-server distribution -%pom_remove_dep org.eclipse.jetty:jetty-webapp distribution +# Remove depencency on the web archive for web-storage-service we'll make deps +# available manually +%pom_remove_dep "com.redhat.thermostat:thermostat-web-war" web/endpoint-plugin/web-service + +# jetty-schemas is not available +%pom_remove_dep org.eclipse.jetty.toolchain:jetty-schemas web/endpoint-plugin/distribution # Remove system scope and systemPath for com.sun:tools dependencies. # xmvn complains about those at install time. @@ -287,7 +340,9 @@ for Thermostat's Web layer. %pom_xpath_remove "pom:dependencies/pom:dependency[pom:groupId='com.sun']/pom:scope" vm-heap-analysis/client-swing %pom_xpath_remove "pom:dependencies/pom:dependency[pom:groupId='com.sun']/pom:scope" vm-heap-analysis/client-core %pom_xpath_remove "pom:dependencies/pom:dependency[pom:groupId='com.sun']/pom:systemPath" agent/core +%pom_xpath_remove "pom:dependencies/pom:dependency[pom:groupId='com.sun']/pom:scope" agent/proxy/common %pom_xpath_remove "pom:dependencies/pom:dependency[pom:groupId='com.sun']/pom:scope" agent/proxy/server +%pom_xpath_remove "pom:dependencies/pom:dependency[pom:groupId='com.sun']/pom:systemPath" agent/proxy/common %pom_xpath_remove "pom:dependencies/pom:dependency[pom:groupId='com.sun']/pom:systemPath" agent/proxy/server %pom_xpath_remove "pom:dependencies/pom:dependency[pom:groupId='com.sun']/pom:systemPath" common/core %pom_xpath_remove "pom:dependencies/pom:dependency[pom:groupId='com.sun']/pom:systemPath" thread/collector @@ -295,6 +350,8 @@ for Thermostat's Web layer. %pom_xpath_remove "pom:dependencies/pom:dependency[pom:groupId='com.sun']/pom:systemPath" vm-heap-analysis/client-swing %pom_xpath_remove "pom:dependencies/pom:dependency[pom:groupId='com.sun']/pom:systemPath" vm-heap-analysis/client-core +# Don't install the zip files created during the build +%mvn_package com.redhat.thermostat::zip: __noinstall # Skip automatic installation of the war module. # We install it manually. Without this "config" %mvn_build -f # fails. See RHBZ#963838 @@ -307,13 +364,21 @@ for Thermostat's Web layer. %mvn_package com.redhat.thermostat:thermostat-distribution __noinstall %mvn_package com.redhat.thermostat:thermostat-assembly __noinstall -# thermostat-web-server should be part of the webapp sub-package -# webapp +# The automatic requires generator gets confused by build-deps. We have +# to __noinstall it in order for mvn() requires generation to work. +%mvn_package com.redhat.thermostat:thermostat-build-deps __noinstall + +# thermostat-web-server and thermostat-web-endpoint should be part of the +# webapp sub-package webapp %mvn_package com.redhat.thermostat:thermostat-web-server webapp +%mvn_package "com.redhat.thermostat:thermostat-web-endpoint-plugin" webapp +%mvn_package "com.redhat.thermostat:thermostat-web-endpoint:pom:" webapp +%mvn_package "com.redhat.thermostat:thermostat-web-endpoint-distribution:pom:" webapp + %{?scl:EOF} %build -%{?scl:scl enable %{scl} - << "EOF"} +%{?scl:scl enable %{scl} maven30 rh-java-common rh-mongodb26 - << "EOF"} export CFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS" # Set JAVA_HOME. make uses this . /usr/share/java-utils/java-functions @@ -383,7 +448,11 @@ rm -rf %{buildroot}/%{_datarootdir}/java/%{?scl_prefix}%{pkg_name} -Dhttpcomponents.client.version=%{hc_client_bundle_version} \ -Dhttpcomponents.mime.version=%{hc_client_bundle_version} \ -Djcommon.osgi.version=%{jcommon_bundle_version} \ - -Djfreechart.osgi.version=%{jfreechart_bundle_version} + -Djfreechart.osgi.version=%{jfreechart_bundle_version} \ + -Dlucene-core.bundle.symbolic-name=org.apache.lucene.core \ + -Dlucene-analysis.bundle.symbolic-name=org.apache.lucene.analysis \ + -Dosgi.compendium.bundle.symbolic-name=org.osgi.compendium \ + -Dosgi.compendium.osgi-version=4.1.0 # the build puts all depdency jars into distribution/target/image/lib as well mv distribution/target/image/libs/thermostat-*jar . @@ -407,7 +476,7 @@ for i in *.jar; do done popd pushd distribution/target/image/plugins -for i in $(find -name '*.jar' | sed 's#^./##g'); do +for i in $(find -name 'thermostat-*.jar' | sed 's#^./##g'); do fname=$(basename $i) newFileName=$(echo $fname | sed 's/-\([0-9]\+\.\)\+[0-9]\+\(-[a-zA-Z0-9]\+\)\?//') echo "plugins/${i}#${newFileName}" >> ../../../symlink-map-filenames @@ -421,11 +490,11 @@ mv distribution/symlink-map-filenames-filtered distribution/symlink-map-filename pushd webstorage-webapp rm -rf WEB-INF/lib/* popd -mv distribution/target/image/libs/thermostat-web-server*.jar webstorage-webapp/WEB-INF/lib +mv distribution/target/image/webapp/WEB-INF/lib/thermostat-web-server*.jar webstorage-webapp/WEB-INF/lib %{?scl:EOF} %install -%{?scl:scl enable %{scl} - << "EOF"} +%{?scl:scl enable maven30 %{scl} - << "EOF"} ####################################################### # Thermostat core ####################################################### @@ -448,10 +517,8 @@ mkdir -p %{buildroot}%{_datarootdir}/applications # have the '-i' switch. %mvn_install -rm -rf %{buildroot}%{_datarootdir}/java/%{pkg_name} - # now make xmvn happy, it expects version-less thermostat jars in -# %{_datadir}/java/%{pkg_name} +rm -rf %{buildroot}%{_datarootdir}/java/%{pkg_name} mkdir -p %{buildroot}%{_datarootdir}/java/%{pkg_name} for i in $(cat distribution/symlink-map-filenames); do s=$(echo $i | cut -d'#' -f1) @@ -502,33 +569,43 @@ cp distribution/target/%{pkg_name}.desktop %{buildroot}%{_datarootdir}/applicati # Install the SVG icon cp %{SOURCE2} %{buildroot}%{_datarootdir}/icons/hicolor/scalable/apps/%{pkg_name}.svg + +# Install tmpfiles.d config file for /var/run/%{pkg_name} +mkdir -p %{buildroot}%{system_tmpfilesdir} +install -m 0644 distribution/target/tmpfiles.d/%{pkg_name}.conf %{buildroot}%{system_tmpfilesdir}/%{pkg_name}.conf + +# Don't want dev setup things +rm distribution/target/image/bin/thermostat-devsetup +rm distribution/target/image/etc/devsetup.input + # move everything else into $THERMOSTAT_HOME rm -rf distribution/target/image/bin/thermostat.orig +# Don't install webapp twice +rm -rf distribution/target/image/webapp cp -a distribution/target/image %{buildroot}%{thermostat_home} # symlink dependencies into the right directory -ln -s %{system_javadir}/felix/org.apache.felix.framework.jar %{buildroot}%{thermostat_home}/libs/org.apache.felix.framework.jar -ln -s %{system_javadir}/hawtjni-runtime.jar %{buildroot}%{thermostat_home}/libs/hawtjni-runtime.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/felix/org.apache.felix.framework.jar %{buildroot}%{thermostat_home}/libs/org.apache.felix.framework.jar +ln -s /opt/rh/rh-java-common/root/usr/lib/java/hawtjni-runtime.jar %{buildroot}%{thermostat_home}/libs/hawtjni-runtime.jar # All bundles with symbolic_name=version listed in # $THERMOSTAT_HOME/etc/commands/.properties or any thermostat-plugin.xml file # need to be symlinked from $THERMOSTAT_HOME/{libs,plugins//} # The following list is that set and will get started by the OSGi framework as # bundles in an OSGi sense. -ln -s %{system_javadir}/httpcomponents/httpcore.jar %{buildroot}%{thermostat_home}/libs/httpcomponents-core.jar -ln -s %{system_javadir}/httpcomponents/httpclient.jar %{buildroot}%{thermostat_home}/libs/httpcomponents-client.jar -ln -s %{system_javadir}/apache-commons-cli.jar %{buildroot}%{thermostat_home}/libs/commons-cli.jar -ln -s %{system_javadir}/apache-commons-collections.jar %{buildroot}%{thermostat_home}/libs/commons-collections.jar -ln -s %{system_javadir}/apache-commons-beanutils.jar %{buildroot}%{thermostat_home}/libs/commons-beanutils.jar -ln -s %{system_javadir}/apache-commons-logging.jar %{buildroot}%{thermostat_home}/libs/commons-logging.jar -# This comes from the mongodb24 collection. -ln -s /opt/rh/mongodb24/root/usr/share/java/mongo.jar %{buildroot}%{thermostat_home}/libs/mongo.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/apache-commons-beanutils.jar %{buildroot}%{thermostat_home}/libs/commons-beanutils.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/apache-commons-cli.jar %{buildroot}%{thermostat_home}/libs/commons-cli.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/apache-commons-collections.jar %{buildroot}%{thermostat_home}/libs/commons-collections.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/apache-commons-logging.jar %{buildroot}%{thermostat_home}/libs/commons-logging.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/google-gson.jar %{buildroot}%{thermostat_home}/libs/gson.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/httpcomponents/httpcore.jar %{buildroot}%{thermostat_home}/libs/httpcomponents-core.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/httpcomponents/httpclient.jar %{buildroot}%{thermostat_home}/libs/httpcomponents-client.jar +# This comes from the mongodb26 collection. +ln -s /opt/rh/rh-mongodb26/root/usr/share/java/mongo-java-driver/mongo.jar %{buildroot}%{thermostat_home}/libs/mongo.jar # The following deps are packaged as part of the thermostat-scl ln -s %{scl_javadir}/netty.jar %{buildroot}%{thermostat_home}/libs/netty.jar -ln -s %{scl_javadir}/jfreechart/jfreechart.jar %{buildroot}%{thermostat_home}/libs/jfreechart.jar +ln -s %{scl_javadir}/jfreechart.jar %{buildroot}%{thermostat_home}/libs/jfreechart.jar ln -s %{scl_javadir}/jcommon.jar %{buildroot}%{thermostat_home}/libs/jcommon.jar ln -s %{scl_javadir}/jline2/jline.jar %{buildroot}%{thermostat_home}/libs/jline2.jar -ln -s %{scl_javadir}/lucene.jar %{buildroot}%{thermostat_home}/libs/lucene.jar -ln -s %{scl_javadir}/google-gson/gson.jar %{buildroot}%{thermostat_home}/libs/gson.jar # The following are additional downstream specific symlinks for transitive deps # see fix_bundle_loading.patch # some of them have their deps embedded upstream (or whatever is available in the maven repos) @@ -536,9 +613,32 @@ ln -s %{scl_javadir}/google-gson/gson.jar %{buildroot}%{thermostat_home}/libs/gs # jline2 => jansi # httpclient => httpmime # httpclient => commons-codec -ln -s %{system_javadir}/jansi.jar %{buildroot}%{thermostat_home}/libs/jansi.jar -ln -s %{system_javadir}/httpcomponents/httpmime.jar %{buildroot}%{thermostat_home}/libs/httpcomponents-mime.jar -ln -s %{system_javadir}/apache-commons-codec.jar %{buildroot}%{thermostat_home}/libs/commons-codec.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/jansi.jar %{buildroot}%{thermostat_home}/libs/jansi.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/httpcomponents/httpmime.jar %{buildroot}%{thermostat_home}/libs/httpcomponents-mime.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/apache-commons-codec.jar %{buildroot}%{thermostat_home}/libs/commons-codec.jar + +# set up symlinks for vm-heap-analysis +rm %{buildroot}%{thermostat_home}/plugins/vm-heap-analysis/lucene*jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/lucene/lucene-core.jar %{buildroot}%{thermostat_home}/libs/lucene-core.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/lucene/lucene-analyzers-common.jar %{buildroot}%{thermostat_home}/libs/lucene-analyzers.jar + +# set up symlinks for vm-profiler plugin +rm %{buildroot}%{thermostat_home}/plugins/vm-profiler/asm*jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/objectweb-asm5/asm-all-5.jar %{buildroot}%{thermostat_home}/libs/asm-all.jar + +# set up symlinks for embedded-web-endpoint plugin +rm %{buildroot}%{thermostat_home}/plugins/embedded-web-endpoint/jetty*jar +rm %{buildroot}%{thermostat_home}/plugins/embedded-web-endpoint/javax.servlet*jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/tomcat-servlet-3.0-api.jar %{buildroot}%{thermostat_home}/libs/javax.servlet-3.0-api.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/jetty/jetty-http.jar %{buildroot}%{thermostat_home}/libs/jetty-http.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/jetty/jetty-io.jar %{buildroot}%{thermostat_home}/libs/jetty-io.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/jetty/jetty-jaas.jar %{buildroot}%{thermostat_home}/libs/jetty-jaas.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/jetty/jetty-security.jar %{buildroot}%{thermostat_home}/libs/jetty-security.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/jetty/jetty-server.jar %{buildroot}%{thermostat_home}/libs/jetty-server.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/jetty/jetty-servlet.jar %{buildroot}%{thermostat_home}/libs/jetty-servlet.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/jetty/jetty-util.jar %{buildroot}%{thermostat_home}/libs/jetty-util.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/jetty/jetty-webapp.jar %{buildroot}%{thermostat_home}/libs/jetty-webapp.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/jetty/jetty-xml.jar %{buildroot}%{thermostat_home}/libs/jetty-xml.jar pushd %{buildroot}%{_libdir}/%{pkg_name} # symlink JNI jars @@ -559,7 +659,11 @@ ln -s /usr/lib/jvm/java-1.7.0-openjdk/lib/tools.jar \ # Symlink the thermostat script in /bin ln -s %{thermostat_home}/bin/thermostat \ %{buildroot}%{_bindir}/thermostat +ln -s %{_datarootdir}/%{pkg_name}/bin/thermostat-setup \ + %{buildroot}%{_bindir}/thermostat-setup +# create required config directory +mkdir -p %{buildroot}%{thermostat_home}/etc/plugins.d/ # move config files to /etc and symlink stuff under $THERMOSTAT_HOME/etc to it mv %{buildroot}%{thermostat_home}/etc/* \ %{buildroot}%{_sysconfdir}/%{pkg_name} @@ -577,6 +681,9 @@ cp thermostat_sysconfig.env %{buildroot}%{_sysconfdir}/sysconfig/%{pkg_name} # Set up directory structure for running thermostat storage/ # thermostat agend via systemd %{__install} -d -m 0775 %{buildroot}%{system_datadir} +# Create a setup-complete.stamp file so as to prevent the launcher hook from +# successfully running the thermostat1-thermostat-storage service. +echo "setup-complete.stamp for thermostat1-thermostat-storage service" > %{buildroot}%{system_datadir}/setup-complete.stamp %{__install} -d -m 0775 %{buildroot}%{system_cachedir} %{__install} -d -m 0775 %{buildroot}%{system_logdir} %{__install} -d -m 0775 %{buildroot}%{system_statedir} @@ -598,6 +705,8 @@ pushd webstorage-webapp sed -i '/THERMOSTAT_HOME<[/]param-name>/,/.*<[/]param-value>/{ s$.*$%{thermostat_home}$ }' \ WEB-INF/web.xml popd +# create a symlink to webapp from THERMOSTAT_HOME +ln -s %{thermostat_catalina_base}/webapps/%{pkg_name} %{buildroot}%{thermostat_home}/webapp cp -r webstorage-webapp %{buildroot}%{thermostat_catalina_base}/webapps/%{pkg_name} # # Make xmvn happy. Give it a symlink in %{_datadir}/java/%{pkg_name} @@ -637,18 +746,23 @@ pushd %{buildroot}%{thermostat_catalina_base}/webapps/%{pkg_name}/WEB-INF/lib popd # Symlink other dependencies pushd %{buildroot}%{thermostat_catalina_base}/webapps/%{pkg_name}/WEB-INF/lib -ln -s %{system_javadir}/apache-commons-collections.jar -ln -s %{system_javadir}/apache-commons-beanutils.jar -ln -s %{system_javadir}/apache-commons-logging.jar -ln -s %{system_javadir}/apache-commons-io.jar -ln -s %{system_javadir}/apache-commons-codec.jar -# This comes from the mongodb24 collection. -ln -s /opt/rh/mongodb24/root/usr/share/java/mongo.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/apache-commons-beanutils.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/apache-commons-codec.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/apache-commons-collections.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/apache-commons-io.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/apache-commons-logging.jar +ln -s /opt/rh/rh-java-common/root/usr/share/java/google-gson.jar +# This comes from the mongodb26 collection. +ln -s /opt/rh/rh-mongodb26/root/usr/share/java/mongo-java-driver/mongo.jar # The following are SCL-ized in our collection ln -s %{scl_javadir}/apache-commons-fileupload/commons-fileupload.jar apache-commons-fileupload.jar -ln -s %{scl_javadir}/google-gson/gson.jar google-gson.jar popd +# Symlink webapp configuration +mv %{buildroot}%{thermostat_catalina_base}/webapps/%{pkg_name}/WEB-INF/web.auth \ + %{buildroot}%{_sysconfdir}/%{pkg_name}/ +ln -s %{_sysconfdir}/%{pkg_name}/web.auth %{buildroot}%{thermostat_catalina_base}/webapps/%{pkg_name}/WEB-INF/ + # We use a custom CATALINA_BASE with core tomcat directories # symlinked. This allows us to deploy the thermostat webapp # nicely configured without any configuration required prior @@ -659,7 +773,10 @@ cp systemd_tomcat_env_thermostat.txt %{buildroot}%{system_confdir}/sysconfig/${S sed 's#__catalina_base__#%{thermostat_catalina_base}#g' %{SOURCE3} > tomcat_service_thermostat.txt sed -i 's#__jaas_config__#%{_sysconfdir}/%{pkg_name}/%{pkg_name}_jaas.conf#g' tomcat_service_thermostat.txt +# Install file twice, since RHEL 7.0 and RHEL 7.1 have different tomcat versions. The first file is used +# by thermostat1-thermostat-tomcat's service. The second one is used by "tomcat@thermostat". cp tomcat_service_thermostat.txt %{buildroot}%{system_confdir}/sysconfig/%{?scl_prefix}%{pkg_name}-tomcat-service +cp tomcat_service_thermostat.txt %{buildroot}%{system_confdir}/sysconfig/tomcat@%{pkg_name} sed "s#__service_file_name__#${SERVICE_FILENAME}#g" %{SOURCE5} > systemd_tomcat_thermostat.service sed -i "s#__service_file_path__#%{system_confdir}/sysconfig#g" systemd_tomcat_thermostat.service @@ -750,6 +867,7 @@ fi %config(noreplace) %{_sysconfdir}/%{pkg_name}/commands %config(noreplace) %{_sysconfdir}/%{pkg_name}/db.properties %config(noreplace) %{_sysconfdir}/%{pkg_name}/logging.properties +%config(noreplace) %{_sysconfdir}/%{pkg_name}/plugins.d %config(noreplace) %{_sysconfdir}/%{pkg_name}/osgi-export.properties %config(noreplace) %{_sysconfdir}/%{pkg_name}/ssl.properties # Required for systemd services @@ -758,11 +876,41 @@ fi %{_datadir}/applications/%{pkg_name}.desktop # thermostat icon %{_datadir}/icons/hicolor/scalable/apps/%{pkg_name}.svg -%{_datadir}/%{pkg_name} -%{_libdir}/%{pkg_name} +%{_datadir}/%{pkg_name}/etc +%{_datadir}/%{pkg_name}/bin +%{_datadir}/%{pkg_name}/libs +%{_datadir}/%{pkg_name}/plugins/host-cpu +%{_datadir}/%{pkg_name}/plugins/host-memory +%{_datadir}/%{pkg_name}/plugins/host-overview +%{_datadir}/%{pkg_name}/plugins/killvm +%{_datadir}/%{pkg_name}/plugins/notes +%{_datadir}/%{pkg_name}/plugins/numa +%{_datadir}/%{pkg_name}/plugins/storage-profile +%{_datadir}/%{pkg_name}/plugins/thread +%{_datadir}/%{pkg_name}/plugins/validate +%{_datadir}/%{pkg_name}/plugins/vm-classstat +%{_datadir}/%{pkg_name}/plugins/vm-cpu +%{_datadir}/%{pkg_name}/plugins/vm-gc +%{_datadir}/%{pkg_name}/plugins/vm-heap-analysis +%{_datadir}/%{pkg_name}/plugins/vm-jmx +%{_datadir}/%{pkg_name}/plugins/vm-memory +%{_datadir}/%{pkg_name}/plugins/vm-overview +%{_datadir}/%{pkg_name}/plugins/vm-profiler +%{_datadir}/%{pkg_name}/cache +%{_datadir}/%{pkg_name}/data +%{_datadir}/%{pkg_name}/logs +%{_datadir}/%{pkg_name}/run %{_jnidir}/thermostat-*.jar %{_bindir}/thermostat +%{_bindir}/thermostat-setup %{_unitdir}/%{?scl_prefix}%{pkg_name}-storage.service +%{_libdir}/%{pkg_name}/libGTKThemeUtils.so +%{_libdir}/%{pkg_name}/libGnomeKeyringWrapper.so +%{_libdir}/%{pkg_name}/libHostNameWrapper.so +%{_libdir}/%{pkg_name}/libUserNameUtilWrapper.so +%{_libdir}/%{pkg_name}/thermostat-agent-core-1.2.0.jar +%{_libdir}/%{pkg_name}/thermostat-keyring-1.2.0.jar +%{_libdir}/%{pkg_name}/thermostat-laf-utils-1.2.0.jar # FIXME: install or not-to-install agent service running as root? # Currently: Don't install. #%{_unitdir}/%{pkg_name}-agent.service @@ -770,31 +918,91 @@ fi # To these directories get written to when thermostat storage/agent # run as systemd services %attr(0770,thermostat,thermostat) %dir %{system_datadir} +%attr(0770,thermostat,thermostat) %{system_datadir}/setup-complete.stamp %attr(0770,thermostat,thermostat) %dir %{system_cachedir} %attr(0770,thermostat,thermostat) %dir %{system_logdir} %attr(0770,thermostat,thermostat) %dir %{system_statedir} # Own directories we ship libs in. See RHBZ#1057169 -%dir %{_javadir}/%{pkg_name} +%{_javadir}/%{pkg_name} %files javadoc %doc LICENSE %doc COPYING -%{_datarootdir}/javadoc/%{?scl_prefix}%{pkg_name} +%{_datarootdir}/javadoc/%{pkg_name} %files webapp -f .mfiles-webapp %{thermostat_catalina_base} +%{_datadir}/%{pkg_name}/webapp +%{_datadir}/%{pkg_name}/plugins/embedded-web-endpoint %config(noreplace) %{_sysconfdir}/%{pkg_name}/%{pkg_name}_jaas.conf +%config(noreplace) %{_sysconfdir}/%{pkg_name}/web-storage-service.properties # Those files should be readable by root and tomcat only %attr(0640,root,tomcat) %config(noreplace) %{_sysconfdir}/%{pkg_name}/%{pkg_name}-users.properties %attr(0640,root,tomcat) %config(noreplace) %{_sysconfdir}/%{pkg_name}/%{pkg_name}-roles.properties -# We need some extra files in order to make thermostat-webapp work in an -# SCL setup. However, we only need them there. +%attr(0640,root,tomcat) %config(noreplace) %{_sysconfdir}/%{pkg_name}/web.auth + %config(noreplace) %{system_confdir}/sysconfig/%{?scl_prefix}%{pkg_name}-tomcat %config(noreplace) %{system_confdir}/sysconfig/%{thermostat_tomcat_service_name} %{_unitdir}/%{?scl_prefix}%{pkg_name}-tomcat.service %attr(0770,tomcat,tomcat) %dir %{_root_localstatedir}/log/%{thermostat_tomcat_service_name} +%config(noreplace) %{_sysconfdir}/%{pkg_name}/thermostat_webstorageservice_jaas.conf +# File used by RHEL-7.1's tomcat@thermostat service. +%config(noreplace) %{system_confdir}/sysconfig/tomcat@%{pkg_name} %changelog +* Mon May 18 2015 Severin Gehwolf - 1.2.0-70.12 +- Read mongodb credentials from separate file. +- Resolves: RHBZ#1222621 (CVE-2015-3201) + +* Tue Apr 28 2015 Severin Gehwolf - 1.2.0-70.11 +- Make deployment mechanism for the web endpoint using system + tomcat work on RHEL-7.0 and RHEL-7.1. For RHEL-7.0 tomcat needs + to get started via "service thermostat1-thermostat-tomcat start". + On RHEL-7.1 it's "service tomcat@thermostat start". +- Resolves: RHBZ#1215804 + +* Fri Apr 24 2015 Omair Majid - 1.2.0-70.10 +- Fix warnings printed on startup +- Resolves: RHBZ#1214921 + +* Thu Apr 23 2015 Omair Majid - 1.2.0-70.9 +- Fix dangling symlinks for plugins +- Resolves: RHBZ#1194599 + +* Wed Apr 22 2015 Omair Majid - 1.2.0-70.8 +- Enable web-storage-service +- Resolves: RHBZ#1194599 + +* Thu Apr 2 2015 Jon VanAlten - 1.2.0-70.7 +- Remove redundant symlinks to lucene jars +- Resolves: RHBZ#1193828 +- Replace mongodb's deprecated userAdd with userCreate in thermostat-setup +- Resolves: RHBZ#1193837 + +* Mon Mar 16 2015 Severin Gehwolf - 1.2.0-70.6 +- Use ~/.thermostat-1.2 as USER_THERMOSTAT_HOME per default. +- Resolves: RHBZ#1201257. + +* Mon Mar 16 2015 Severin Gehwolf - 1.2.0-70.5 +- Install setup complete stamp file for + thermostat1-thermostat-storage.service +- Resolves: RHBZ#1202300. + +* Mon Mar 16 2015 Severin Gehwolf - 1.2.0-70.4 +- Don't own webapp files in main package. +- Resolves: RHBZ#1198787. + +* Thu Feb 12 2015 Omair Majid - 1.2.0-70.3 +- Handle Ctrl-C in thermostat-setup gracefully +- Resolves: RHBZ#1199581 + +* Sun Feb 1 2015 Jon VanAlten - 1.2.0-70.2 +- Restore changelog entries mysteriously removed. + +* Fri Jan 30 2015 Jon VanAlten - 1.2.0-70.1 +- Update to 1.2.0 version +- Use rh-java-common, maven30, rh-mongodb26 collections for deps as needed. + * Mon Dec 08 2014 Elliott Baron - 1.0.4-70.6 - Add Obsoletes for agent-proxy-common module. - Resolves: RHBZ#1170141