Author: rob.stryker(a)jboss.com
Date: 2011-11-29 14:04:50 -0500 (Tue, 29 Nov 2011)
New Revision: 36742
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/INeedCredentials.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IProvideCredentials.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/launch/UserPassCredentialProvider.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/WebPortPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IPollerFailureHandler.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/v7/management/AS7ManagementDetails.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/pollerFailureHandler.exsd
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JMXPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/SecurityFailureHandler.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/internal/management/as7/AS7Manager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as71/src/org/jboss/ide/eclipse/as/internal/management/as71/AS71Manager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
JBIDE-10224 - further work on credential callback usecase, required changes to poller API
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -30,9 +30,9 @@
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerType;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
-import org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler;
+import org.jboss.ide.eclipse.as.core.server.IProvideCredentials;
import org.jboss.ide.eclipse.as.core.server.IServerAlreadyStartedHandler;
-import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
+import org.jboss.ide.eclipse.as.core.server.IServerProvider;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
/**
@@ -55,7 +55,7 @@
private HashMap<String, ServerStatePollerType> pollers;
/** The map of pollerID -> PollerObject */
- private HashMap<String, IPollerFailureHandler> pollerFailureHandlers;
+ private HashMap<String, IProvideCredentials> credentialProviders;
/** The method used to load / instantiate the pollers */
public void loadPollers() {
@@ -123,14 +123,14 @@
}
/** The method used to load / instantiate the failure handlers */
- public void loadFailureHandler() {
- pollerFailureHandlers = new HashMap<String, IPollerFailureHandler>();
+ public void loadCredentialProviders() {
+ credentialProviders = new HashMap<String, IProvideCredentials>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] cf =
registry.getConfigurationElementsFor(JBossServerCorePlugin.PLUGIN_ID,
"pollerFailureHandler"); //$NON-NLS-1$
for( int i = 0; i < cf.length; i++ ) {
try {
- pollerFailureHandlers.put(cf[i].getAttribute("id"), //$NON-NLS-1$
- (IPollerFailureHandler)cf[i].createExecutableExtension("class"));
//$NON-NLS-1$
+ credentialProviders.put(cf[i].getAttribute("id"), //$NON-NLS-1$
+ (IProvideCredentials)cf[i].createExecutableExtension("class"));
//$NON-NLS-1$
} catch( CoreException e ) {
// TODO ERROR LOG
} catch( ClassCastException cce ) {
@@ -139,17 +139,17 @@
}
}
- public IPollerFailureHandler[] getPollerFailureHandlers() {
- if( pollerFailureHandlers == null )
- loadFailureHandler();
- Collection<IPollerFailureHandler> c = pollerFailureHandlers.values();
- return c.toArray(new IPollerFailureHandler[c.size()]);
+ public IProvideCredentials[] getCredentialProviders() {
+ if( credentialProviders == null )
+ loadCredentialProviders();
+ Collection<IProvideCredentials> c = credentialProviders.values();
+ return c.toArray(new IProvideCredentials[c.size()]);
}
- public IPollerFailureHandler getFirstPollFailureHandler(IServerStatePoller poller,
String action, List<String> requiredProperties) {
- IPollerFailureHandler[] handlers = getPollerFailureHandlers();
+ public IProvideCredentials getFirstCredentialProvider(IServerProvider serverProvider,
List<String> requiredProperties) {
+ IProvideCredentials[] handlers = getCredentialProviders();
for( int i = 0; i < handlers.length; i++ ) {
- if( handlers[i].accepts(poller, action, requiredProperties)) {
+ if( handlers[i].accepts(serverProvider, requiredProperties)) {
return handlers[i];
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2011 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -18,7 +18,6 @@
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.internal.DelegatingServerBehavior;
import org.jboss.ide.eclipse.as.core.server.internal.IProcessProvider;
-import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
/**
@@ -37,10 +36,6 @@
private ServerStatePollerType type;
private IServer server;
- @Deprecated
- public void beginPolling(IServer server, boolean expectedState, PollThread pollThread)
{
- }
-
public void beginPolling(IServer server, boolean expectedState) {
this.server = server;
}
@@ -71,10 +66,10 @@
return false;
}
- public void failureHandled(Properties properties) {
+ public void provideCredentials(Properties properties) {
}
- public List getRequiredProperties() {
+ public List<String> getRequiredProperties() {
return null;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2011 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -32,10 +32,6 @@
private IServer server;
private ServerStatePollerType type;
- @Deprecated
- public void beginPolling(IServer server, boolean expectedState, PollThread pollThread)
{
- }
-
public void beginPolling(IServer server, boolean expectedState) {
this.expectedState = expectedState;
this.server = server;
@@ -69,18 +65,10 @@
return (getServer().getStopTimeout()-3) * 1000;
}
- public boolean supportsShutdown() {
- return true;
+ public void provideCredentials(Properties properties) {
}
- public boolean supportsStartup() {
- return true;
- }
-
- public void failureHandled(Properties properties) {
- }
-
- public List getRequiredProperties() {
+ public List<String> getRequiredProperties() {
return null;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/WebPortPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/WebPortPoller.java 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/WebPortPoller.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.core.extensions.polling;
import java.io.FileNotFoundException;
@@ -16,7 +26,6 @@
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller2;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
-import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
@@ -29,10 +38,6 @@
private boolean state;
private boolean expectedState;
- @Deprecated
- public void beginPolling(IServer server, boolean expectedState, PollThread pollTread)
throws Exception {
- }
-
public void beginPolling(IServer server, boolean expectedState) {
this.server = server;
this.canceled = done = false;
@@ -59,6 +64,9 @@
done = true;
state = expectedState;
}
+ try {
+ Thread.sleep(100);
+ } catch(InterruptedException ie) {} // ignore
}
}
@@ -75,21 +83,26 @@
}
private static boolean onePing(String url) {
+ URLConnection conn = null;
try {
URL pingUrl = new URL(url);
- URLConnection conn = pingUrl.openConnection();
+ conn = pingUrl.openConnection();
((HttpURLConnection)conn).getResponseCode();
return true;
} catch( FileNotFoundException fnfe ) {
return true;
} catch (MalformedURLException e) {
- // Should NEVER happen since hte URL's are hand-crafted, but whatever
+ // Should NEVER happen since the URL's are hand-crafted, but whatever
Status s = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, e.getMessage(),
e);
JBossServerCorePlugin.getDefault().log(s);
} catch (IOException e) {
// Does not need to be logged
return false;
- }
+ } finally {
+ if( conn != null ) {
+ ((HttpURLConnection)conn).disconnect();
+ }
+ }
return false;
}
@@ -120,7 +133,7 @@
return new ArrayList<String>();
}
- public void failureHandled(Properties properties) {
+ public void provideCredentials(Properties properties) {
}
public void cancel(int type) {
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/INeedCredentials.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/INeedCredentials.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/INeedCredentials.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server;
+
+import java.util.List;
+import java.util.Properties;
+
+public interface INeedCredentials extends IServerProvider {
+
+ /**
+ * Get a list of required properties for these credentials
+ * Ex: username, password, security realm, etc
+ * @return
+ */
+ public List<String> getRequiredProperties();
+
+ /**
+ * Provides the required credentials to the INeedCredentials object
+ * @param credentials A property map, mapping each String property to a String value
+ */
+ public void provideCredentials(Properties credentials);
+
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IPollerFailureHandler.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IPollerFailureHandler.java 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IPollerFailureHandler.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -10,13 +10,10 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server;
-import java.util.List;
/**
* @author rob.stryker <rob.stryker(a)redhat.com>
- *
+ * @deprecated
*/
-public interface IPollerFailureHandler {
- public boolean accepts(IServerStatePoller poller, String action, List<String>
requiredProperties);
- public void handle(IServerStatePoller poller, String action, List<String>
requiredProperties);
+public interface IPollerFailureHandler extends IProvideCredentials {
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IProvideCredentials.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IProvideCredentials.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IProvideCredentials.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server;
+
+import java.util.List;
+
+public interface IProvideCredentials {
+ /**
+ * Acknowledges whether the provider can or cannot provide credentials for this server
+ *
+ * @param serverProvider an object to provide a server
+ * @param requiredProperties a list of required properties
+ *
+ * @return true if this provider can handle this server; false otherwise
+ */
+ public boolean accepts(IServerProvider serverProvider, List<String>
requiredProperties);
+
+ /**
+ * Handles the fetching / requesting and subsequent delivery of these credentials
+ *
+ * @param inNeed the object requiring access to the credentials
+ * @param requiredProperties a list of required properties
+ *
+ */
+ public void handle(INeedCredentials inNeed, List<String> requiredProperties);
+}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerProvider.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerProvider.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server;
+
+import org.eclipse.wst.server.core.IServer;
+
+public interface IServerProvider {
+ public IServer getServer();
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -10,9 +10,6 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server;
-import java.util.List;
-import java.util.Properties;
-
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
@@ -22,7 +19,7 @@
* @author Rob Stryker
*
*/
-public interface IServerStatePoller {
+public interface IServerStatePoller extends INeedCredentials {
public static final int POLLING_CODE = IEventCodes.POLLING_CODE;
public static final int POLLER_MASK = IEventCodes.POLLER_MASK;
@@ -55,7 +52,6 @@
* expected to launch own thread
*/
public void beginPolling(IServer server, boolean expectedState) throws PollingException;
- public IServer getServer();
public boolean isComplete() throws PollingException, RequiresInfoException;
/**
@@ -71,9 +67,7 @@
* clean up any resources / processes. Will ALWAYS be called
*/
public void cleanup();
- public List<String> getRequiredProperties();
- public void failureHandled(Properties properties);
-
+
/**
* Cancel the polling.
* @param type CANCEL or TIMEOUT_REACHED
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -19,7 +19,7 @@
import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
-import org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler;
+import org.jboss.ide.eclipse.as.core.server.IProvideCredentials;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller.PollingException;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller.RequiresInfoException;
@@ -137,7 +137,7 @@
// This way each request for new info is checked only once.
if (!rie.getChecked()) {
rie.setChecked();
- firePollerFailureHandler(expectedState, poller);
+ fireRequestCredentials(expectedState, poller);
}
}
stateStartedOrStopped = checkServerState();
@@ -307,12 +307,10 @@
return STATE_STOPPED;
}
- public static void firePollerFailureHandler(boolean expectedState, IServerStatePoller
poller) {
- String action = expectedState == IServerStatePoller.SERVER_UP ? SERVER_STARTING
- : SERVER_STOPPING;
- IPollerFailureHandler handler = ExtensionManager
- .getDefault().getFirstPollFailureHandler(poller,
- action, poller.getRequiredProperties());
- handler.handle(poller, action, poller.getRequiredProperties());
+ public static void fireRequestCredentials(boolean expectedState, IServerStatePoller
poller) {
+ IProvideCredentials handler = ExtensionManager
+ .getDefault().getFirstCredentialProvider(poller,
+ poller.getRequiredProperties());
+ handler.handle(poller, poller.getRequiredProperties());
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -55,8 +55,8 @@
public void beginPolling(IServer server, boolean expectedState) throws PollingException
{
try {
this.service = JBoss7ManagerUtil.getService(server);
+ this.server = server;
this.managementDetails = createManagementDetails();
- this.server = server;
this.expectedState = expectedState;
launchPollingThread();
} catch(InvalidSyntaxException e) {
@@ -177,7 +177,7 @@
return requiredProperties == null ? new ArrayList<String>() :
requiredProperties;
}
- public void failureHandled(Properties properties) {
+ public void provideCredentials(Properties properties) {
requiredPropertiesReturned = properties;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/v7/management/AS7ManagementDetails.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/v7/management/AS7ManagementDetails.java 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/v7/management/AS7ManagementDetails.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -10,11 +10,20 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.v7.management;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
+import org.jboss.ide.eclipse.as.core.server.INeedCredentials;
+import org.jboss.ide.eclipse.as.core.server.IProvideCredentials;
+import org.jboss.ide.eclipse.as.core.server.IServerProvider;
import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7Server;
-public class AS7ManagementDetails {
+public class AS7ManagementDetails implements IServerProvider {
private IServer server;
private String hardHost = null;
private int hardPort = -1;
@@ -50,6 +59,50 @@
}
public String[] handleCallbacks(String[] prompts) throws UnsupportedOperationException
{
- return new String[0];
+ ArrayList<String> requiredProperties = new ArrayList<String>();
+ requiredProperties.addAll(Arrays.asList(prompts));
+ IProvideCredentials handler = ExtensionManager
+ .getDefault().getFirstCredentialProvider(this, requiredProperties);
+ if( handler == null )
+ throw new UnsupportedOperationException();
+ final Properties[] returnedProps = new Properties[1];
+ final Boolean[] gotProps = new Boolean[1];
+ returnedProps[0] = null;
+ gotProps[0] = false;
+
+ INeedCredentials needs = new INeedCredentials() {
+ public IServer getServer() {
+ return AS7ManagementDetails.this.getServer();
+ }
+ public List<String> getRequiredProperties() {
+ // ignore
+ return null;
+ }
+ public void provideCredentials(Properties credentials) {
+ returnedProps[0] = credentials;
+ gotProps[0] = true;
+ }
+ };
+ handler.handle(needs, requiredProperties);
+
+ while( !gotProps[0]) {
+ try {
+ Thread.sleep(100);
+ } catch(InterruptedException ie) {
+ // ignore
+ }
+ }
+
+ if( returnedProps[0] == null )
+ return new String[0];
+
+ String[] rets = new String[prompts.length];
+ for( int i = 0; i < rets.length; i++ ) {
+ rets[i] = (String)returnedProps[0].get(prompts[i]);
+ }
+ return rets;
}
+ public IServer getServer() {
+ return server;
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/pollerFailureHandler.exsd
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/pollerFailureHandler.exsd 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/pollerFailureHandler.exsd 2011-11-29
19:04:50 UTC (rev 36742)
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
-<schema targetNamespace="org.jboss.ide.eclipse.as.core">
+<schema targetNamespace="org.jboss.ide.eclipse.as.core"
xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.jboss.ide.eclipse.as.core"
id="pollerFailureHandler"
name="org.jboss.ide.eclipse.as.core.runtime.server."/>
@@ -11,6 +11,11 @@
</annotation>
<element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
<complexType>
<sequence>
<element ref="pollerHandler" minOccurs="1"
maxOccurs="unbounded"/>
@@ -57,7 +62,7 @@
</documentation>
<appInfo>
- <meta.attribute kind="java"
basedOn=":org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler"/>
+ <meta.attribute kind="java"
basedOn=":org.jboss.ide.eclipse.as.core.server.IProvideCredentials"/>
</appInfo>
</annotation>
</attribute>
@@ -100,13 +105,5 @@
</documentation>
</annotation>
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
</schema>
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/plugin.xml 2011-11-29
18:11:06 UTC (rev 36741)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/plugin.xml 2011-11-29
19:04:50 UTC (rev 36742)
@@ -25,6 +25,13 @@
supportsStartup="true"/>
</extension>
+ <extension
+ point="org.jboss.ide.eclipse.as.core.pollerFailureHandler">
+ <pollerHandler
+
class="org.jboss.ide.eclipse.as.jmx.integration.SecurityFailureHandler"
+
id="org.jboss.ide.eclipse.as.ui.launch.jmxSecurityCredentialProvider">
+ </pollerHandler>
+ </extension>
<extension
point="org.eclipse.ui.navigator.navigatorContent">
@@ -42,9 +49,9 @@
id="org.jboss.ide.eclipse.as.ui.extensions.jmx"
icon="$nl$/icons/jmeth_obj.gif"
activeByDefault="false"
- priority="low">
+ priority="low"
contentProvider="org.jboss.ide.eclipse.as.jmx.integration.JMXProvider$ContentProvider"
-
labelProvider="org.jboss.ide.eclipse.as.jmx.integration.JMXProvider$LabelProvider"
+
labelProvider="org.jboss.ide.eclipse.as.jmx.integration.JMXProvider$LabelProvider">
<triggerPoints>
<instanceof
value="org.eclipse.wst.server.core.IServer">
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JMXPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JMXPoller.java 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JMXPoller.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -30,7 +30,6 @@
import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller2;
-import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
import org.jboss.tools.jmx.core.IJMXRunnable;
@@ -213,7 +212,7 @@
return done;
}
- public void failureHandled(Properties properties) {
+ public void provideCredentials(Properties properties) {
if( properties == null ) {
requiredPropertiesReturned = IGNORED_PROPERTIES;
} else
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/SecurityFailureHandler.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/SecurityFailureHandler.java 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/SecurityFailureHandler.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -11,62 +11,28 @@
package org.jboss.ide.eclipse.as.jmx.integration;
import java.util.List;
-import java.util.Properties;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler;
-import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
+import org.jboss.ide.eclipse.as.core.server.IProvideCredentials;
+import org.jboss.ide.eclipse.as.core.server.IServerProvider;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
-import org.jboss.ide.eclipse.as.ui.Messages;
-import org.jboss.ide.eclipse.as.ui.dialogs.RequiredCredentialsDialog;
+import org.jboss.ide.eclipse.as.ui.launch.UserPassCredentialProvider;
/**
*
* @author rob.stryker <rob.stryker(a)redhat.com>
*
*/
-public class SecurityFailureHandler implements IPollerFailureHandler {
+public class SecurityFailureHandler extends UserPassCredentialProvider implements
IProvideCredentials {
- public boolean accepts(IServerStatePoller poller, String action,
- List requiredProperties) {
- if( poller.getPollerType().getId().equals(JMXPoller.POLLER_ID))
+ @Override
+ public boolean accepts(IServerProvider serverProvider,
+ List<String> requiredProperties) {
+ IServer s = serverProvider.getServer();
+ JBossServer jbs = ServerConverter.getJBossServer(s);
+ if( jbs != null && jbs.hasJMXProvider())
return true;
return false;
}
-
- public void handle(final IServerStatePoller poller, String action, List
requiredProperties) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- IServer server = poller.getServer();
- IServerWorkingCopy copy = server.createWorkingCopy();
- JBossServer jbs = ServerConverter.getJBossServer(copy);
- RequiredCredentialsDialog d = new RequiredCredentialsDialog(new Shell(), jbs);
- if( d.open() == Window.OK) {
- if( d.getSave() ) {
- jbs.setPassword(d.getPass());
- jbs.setUsername(d.getUser());
- try {
- copy.save(false, null);
- } catch( CoreException ce ) {
- JBossServerUIPlugin.log(Messages.ServerSaveFailed, ce);
- }
- }
-
- Properties p = new Properties();
- p.put(JMXPoller.REQUIRED_USER, d.getUser());
- p.put(JMXPoller.REQUIRED_PASS, d.getPass());
- poller.failureHandled(p);
- } else {
- poller.failureHandled(null);
- }
- }
- });
- }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/internal/management/as7/AS7Manager.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/internal/management/as7/AS7Manager.java 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/internal/management/as7/AS7Manager.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -60,6 +60,7 @@
private ServerDeploymentManager manager;
private AS7ManagementDetails details;
+ @Deprecated
public AS7Manager(String host) throws UnknownHostException {
this(new AS7ManagementDetails(host, MGMT_PORT));
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as71/src/org/jboss/ide/eclipse/as/internal/management/as71/AS71Manager.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as71/src/org/jboss/ide/eclipse/as/internal/management/as71/AS71Manager.java 2011-11-29
18:11:06 UTC (rev 36741)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as71/src/org/jboss/ide/eclipse/as/internal/management/as71/AS71Manager.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -38,6 +38,7 @@
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.sasl.RealmChoiceCallback;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;
@@ -66,6 +67,7 @@
private ServerDeploymentManager manager;
private AS7ManagementDetails details;
+ @Deprecated
public AS71Manager(String host) throws UnknownHostException {
this(new AS7ManagementDetails(host, MGMT_PORT));
}
@@ -92,7 +94,10 @@
NameCallback name = null;
PasswordCallback pass = null;
for (Callback current : callbacks) {
- if (current instanceof NameCallback) {
+ if (current instanceof RealmChoiceCallback) {
+ throw new UnsupportedCallbackException(current, "Realm choice not
currently supported.");
+ }
+ if (current instanceof NameCallback) {
name = (NameCallback) current;
} else if (current instanceof PasswordCallback) {
pass = (PasswordCallback) current;
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/launch/UserPassCredentialProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/launch/UserPassCredentialProvider.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/launch/UserPassCredentialProvider.java 2011-11-29
19:04:50 UTC (rev 36742)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.launch;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.server.INeedCredentials;
+import org.jboss.ide.eclipse.as.core.server.IProvideCredentials;
+import org.jboss.ide.eclipse.as.core.server.IServerProvider;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
+import org.jboss.ide.eclipse.as.ui.Messages;
+import org.jboss.ide.eclipse.as.ui.dialogs.RequiredCredentialsDialog;
+
+/**
+ *
+ * @author rob.stryker <rob.stryker(a)redhat.com>
+ *
+ */
+public class UserPassCredentialProvider implements IProvideCredentials {
+
+ @Override
+ public boolean accepts(IServerProvider serverProvider,
+ List<String> requiredProperties) {
+ IServer s = serverProvider.getServer();
+ JBossServer jbs = ServerConverter.getJBossServer(s);
+ if( jbs != null && !jbs.hasJMXProvider())
+ return true;
+ return false;
+ }
+
+ /**
+ * This class assumes that the first two required credentials will be
+ * a simple user / pass combination
+ *
+ */
+ public void handle(final INeedCredentials inNeed,
+ final List<String> requiredProperties) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ IServer server = inNeed.getServer();
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ JBossServer jbs = ServerConverter.getJBossServer(copy);
+ RequiredCredentialsDialog d = new RequiredCredentialsDialog(new Shell(), jbs);
+ if( d.open() == Window.OK) {
+ if( d.getSave() ) {
+ jbs.setPassword(d.getPass());
+ jbs.setUsername(d.getUser());
+ try {
+ copy.save(false, null);
+ } catch( CoreException ce ) {
+ JBossServerUIPlugin.log(Messages.ServerSaveFailed, ce);
+ }
+ }
+
+ Properties p = new Properties();
+ p.put(requiredProperties.get(0), d.getUser());
+ p.put(requiredProperties.get(1), d.getPass());
+ inNeed.provideCredentials(p);
+ } else {
+ inNeed.provideCredentials(null);
+ }
+ }
+ });
+ }
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2011-11-29 18:11:06 UTC (rev
36741)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2011-11-29 19:04:50 UTC (rev
36742)
@@ -241,7 +241,7 @@
<extension
point="org.jboss.ide.eclipse.as.core.pollerFailureHandler">
<pollerHandler
- class="org.jboss.ide.eclipse.as.ui.launch.SecurityFailureHandler"
+
class="org.jboss.ide.eclipse.as.ui.launch.UserPassCredentialProvider"
id="org.jboss.ide.eclipse.as.ui.launch.securityPollerHandler">
</pollerHandler>
</extension>