Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 195644 | Differences between
and this patch

Collapse All | Expand All

(-)src-common-internal/org/eclipse/tptp/platform/common/ui/internal/CommonUIPlugin.java (+4 lines)
Lines 27-32 Link Here
27
import org.eclipse.jface.preference.IPreferenceStore;
27
import org.eclipse.jface.preference.IPreferenceStore;
28
import org.eclipse.swt.widgets.Shell;
28
import org.eclipse.swt.widgets.Shell;
29
import org.eclipse.tptp.platform.common.internal.CommonPlugin;
29
import org.eclipse.tptp.platform.common.internal.CommonPlugin;
30
import org.eclipse.tptp.platform.common.ui.internal.util.UIAgentControllerFactory;
31
import org.eclipse.tptp.platform.execution.util.internal.AgentControllerPool;
30
import org.eclipse.ui.IPerspectiveDescriptor;
32
import org.eclipse.ui.IPerspectiveDescriptor;
31
import org.eclipse.ui.IPerspectiveRegistry;
33
import org.eclipse.ui.IPerspectiveRegistry;
32
import org.eclipse.ui.IPluginContribution;
34
import org.eclipse.ui.IPluginContribution;
Lines 101-106 Link Here
101
		{
103
		{
102
			SDImages.initializeImages(SDImages.INSTANCE, this);
104
			SDImages.initializeImages(SDImages.INSTANCE, this);
103
		}
105
		}
106
		
107
		AgentControllerPool.setAgentControllerFactory(new UIAgentControllerFactory());
104
	}
108
	}
105
109
106
	/*
110
	/*
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 11-17 Link Here
11
 org.eclipse.tptp.platform.common;bundle-version="[4.3.0,5.0.0)",
11
 org.eclipse.tptp.platform.common;bundle-version="[4.3.0,5.0.0)",
12
 org.eclipse.tptp.platform.models;bundle-version="[4.1.0,5.0.0)",
12
 org.eclipse.tptp.platform.models;bundle-version="[4.1.0,5.0.0)",
13
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
13
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
14
 org.eclipse.hyades.execution;bundle-version="[4.1.0,5.0.0)"
14
 org.eclipse.hyades.execution;bundle-version="[4.1.0,5.0.0)",
15
 org.eclipse.tptp.platform.execution
15
Eclipse-LazyStart: true
16
Eclipse-LazyStart: true
16
Export-Package: org.eclipse.hyades.execution.security,
17
Export-Package: org.eclipse.hyades.execution.security,
17
 org.eclipse.hyades.security.internal.util,
18
 org.eclipse.hyades.security.internal.util,
(-)src-common-internal/org/eclipse/tptp/platform/common/ui/internal/util/UIAgentControllerFactory.java (+107 lines)
Added Link Here
1
package org.eclipse.tptp.platform.common.ui.internal.util;
2
3
import java.io.IOException;
4
import java.net.InetAddress;
5
6
import org.eclipse.hyades.internal.execution.local.common.ControlMessage;
7
import org.eclipse.hyades.internal.execution.local.control.CommandHandler;
8
import org.eclipse.hyades.internal.execution.local.control.ConnectionListener;
9
import org.eclipse.hyades.internal.execution.local.control.Node;
10
import org.eclipse.hyades.internal.execution.security.AuthenticationListener;
11
import org.eclipse.hyades.internal.execution.security.LoginFailedException;
12
import org.eclipse.hyades.internal.execution.security.SecureConnectionRequiredException;
13
import org.eclipse.hyades.internal.execution.security.UntrustedAgentControllerException;
14
import org.eclipse.hyades.security.internal.util.ConnectUtilUI;
15
import org.eclipse.hyades.security.internal.util.IConnectUtilUser;
16
import org.eclipse.tptp.platform.execution.security.User;
17
import org.eclipse.tptp.platform.execution.util.internal.AgentControllerFactory;
18
19
public class UIAgentControllerFactory extends AgentControllerFactory {
20
	public User promptAuthentication(String hostName, String userName) {
21
		ConnectUtilUI cui = new ConnectUtilUI();
22
		IConnectUtilUser cuUser = cui.promptAuthentication(hostName, userName);
23
		if(cuUser == null) return null;
24
		
25
		return new User(null, cuUser.getName(), cuUser.getPassword());
26
	}
27
	
28
	public User findUser(String hostName) {
29
		User user = findUserForHost (hostName);
30
		if (user != null) return user;
31
		
32
		if ("localhost".equals(hostName))
33
			return findUserForHost (null);
34
		
35
		return null;
36
	}
37
	
38
	private User findUserForHost (String hostName) {
39
		org.eclipse.hyades.internal.execution.local.control.Node node;
40
		
41
		try {
42
			if (hostName != null)
43
				node = org.eclipse.hyades.internal.execution.local.control.NodeFactory.getNode(hostName, null);
44
			else
45
				node = org.eclipse.hyades.internal.execution.local.control.NodeFactory.getNode(InetAddress.getLocalHost(), null);
46
		} catch (Exception e) {
47
			node = null;
48
		}
49
		
50
		if (node == null || !node.isConnected()) {
51
			return null;
52
		}
53
		
54
		org.eclipse.hyades.internal.execution.security.User hyadesUser = node.getUser();
55
		if (hyadesUser == null) {
56
			return null;
57
		}
58
							// just to extract the password, saving current hyades.User API
59
		HyadesConnection con = new HyadesConnection();
60
		try { hyadesUser.login(con); } catch (Exception e) {}
61
		
62
		return con.getUser();
63
	}
64
65
	class HyadesConnection implements org.eclipse.hyades.internal.execution.local.control.Connection {
66
		public User user = null;
67
68
		public void sendMessage(ControlMessage msg, CommandHandler handler)	throws IOException {
69
			int count = msg.getSize();
70
			if (count <= 1) return;
71
72
			org.eclipse.hyades.internal.execution.local.common.CommandElement ce = msg.getCommand(0);
73
			if (!(ce instanceof org.eclipse.hyades.internal.execution.local.common.AuthenticateCommand)) return;
74
			
75
			org.eclipse.hyades.internal.execution.local.common.AuthenticateCommand acmd =
76
				(org.eclipse.hyades.internal.execution.local.common.AuthenticateCommand) ce;
77
			
78
			byte buf[] = new byte[acmd.getSize()];
79
			acmd.writeToBuffer(buf, 0);
80
81
			org.eclipse.hyades.internal.execution.local.common.RAString hyadesName = 
82
				new org.eclipse.hyades.internal.execution.local.common.RAString();
83
			
84
			org.eclipse.hyades.internal.execution.local.common.RAString hyadesPsw = 
85
				new org.eclipse.hyades.internal.execution.local.common.RAString();
86
87
			int offset = org.eclipse.hyades.internal.execution.local.common.Message.readRAStringFromBuffer(buf, 4, hyadesName);
88
			org.eclipse.hyades.internal.execution.local.common.Message.readRAStringFromBuffer(buf, offset, hyadesPsw);
89
			
90
			user = new User(null, hyadesName.getData(), hyadesPsw.getData());
91
		}
92
93
		public void addAuthenticationListener(AuthenticationListener listener) {}
94
		public void addConnectionListener(ConnectionListener listener) {}
95
		public void connect(Node node, int port) throws IOException,SecureConnectionRequiredException, LoginFailedException,
96
				UntrustedAgentControllerException {
97
		}
98
		public void disconnect() {}
99
		public Node getNode() { return null; }
100
		public int getPort() { return 0; }
101
		public boolean isActive() {	return false; }
102
		public void removeAuthenticationListener(AuthenticationListener listener) {}
103
		public void removeConnectionListener(ConnectionListener listener) {}
104
		
105
		public User getUser() { return user; }
106
	}
107
}

Return to bug 195644