Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Jury2019-05-02 23:00:58 +0000
committerAndy Jury2019-05-02 23:00:58 +0000
commit4c32ee08df050b0eb445df41d7cfa70587bf52e0 (patch)
tree4417bf360e86ccc42558804226a5b71f5f1dc030
parent529f74bcf0fd609581b32680a368b60159e11996 (diff)
parenta787a04a43ce710d3db9394197d505beb4d75b74 (diff)
downloadorg.eclipse.ote-4c32ee08df050b0eb445df41d7cfa70587bf52e0.tar.gz
org.eclipse.ote-4c32ee08df050b0eb445df41d7cfa70587bf52e0.tar.xz
org.eclipse.ote-4c32ee08df050b0eb445df41d7cfa70587bf52e0.zip
-rw-r--r--org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/ConnectionEvent.java17
-rw-r--r--org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/ClientSession.java14
-rw-r--r--org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/TestClientServiceImpl.java23
-rw-r--r--org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/TestHostConnection.java29
-rw-r--r--org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/ReturnStatus.java8
-rw-r--r--org.eclipse.osee.ote.properties/src/org/eclipse/osee/ote/properties/OtePropertiesCore.java1
-rw-r--r--org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OTEServerCreationComponent.java9
-rw-r--r--org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteService.java49
8 files changed, 108 insertions, 42 deletions
diff --git a/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/ConnectionEvent.java b/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/ConnectionEvent.java
index f9f2f179e..325845625 100644
--- a/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/ConnectionEvent.java
+++ b/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/ConnectionEvent.java
@@ -28,15 +28,22 @@ public final class ConnectionEvent {
private final UUID sessionKey;
private final OteServiceProperties props;
private final IHostTestEnvironment hostTestEnvironment;
+ private final boolean isUnauthorizedUser;
- public ConnectionEvent(IHostTestEnvironment hostTestEnvironment, IServiceConnector connector, ITestEnvironment environment, UUID sessionKey) {
- if (connector == null) {
- throw new NullPointerException("connector cannot be null");
+ public ConnectionEvent(IHostTestEnvironment hostTestEnvironment, IServiceConnector connector, ITestEnvironment environment,
+ UUID sessionKey, boolean isUnauthorizedUser) {
+
+ if (!isUnauthorizedUser) {
+ if (connector == null) {
+ throw new NullPointerException("connector cannot be null");
+ }
}
+
this.environment = environment;
this.connector = connector;
this.sessionKey = sessionKey;
this.hostTestEnvironment = hostTestEnvironment;
+ this.isUnauthorizedUser = isUnauthorizedUser;
props = new OteServiceProperties(connector);
}
@@ -75,4 +82,8 @@ public final class ConnectionEvent {
return hostTestEnvironment;
}
+ public boolean isUnauthorizedUser() {
+ return isUnauthorizedUser;
+ }
+
}
diff --git a/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/ClientSession.java b/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/ClientSession.java
index c850a25d8..1196269f5 100644
--- a/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/ClientSession.java
+++ b/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/ClientSession.java
@@ -56,7 +56,7 @@ public class ClientSession extends AbstractRemoteSession {
}
@Override
- public String getAddress() throws RemoteException {
+ public String getAddress() {
return address.getHostAddress();
}
@@ -101,7 +101,7 @@ public class ClientSession extends AbstractRemoteSession {
}
@Override
- public void initiateInformationalPrompt(String message) throws RemoteException {
+ public void initiateInformationalPrompt(String message) {
assert sessionDelegate != null : "delegate is null";
try {
sessionDelegate.handleInformationPrompt(message);
@@ -162,12 +162,12 @@ public class ClientSession extends AbstractRemoteSession {
* closes this session
*/
void close() {
-
+ // INTENTIONALLY EMPTY BLOCK
}
TestHostConnection connect(IServiceConnector connector, IHostTestEnvironment testHost, TestEnvironmentConfig config) throws Exception {
// intentionally package-private
- if (lock.tryLock(TIMEOUT, TimeUnit.MINUTES)) {
+ if (lock.tryLock(TIMEOUT, TimeUnit.MINUTES)) {
try {
IRemoteUserSession exportedSession = (IRemoteUserSession) connector.export(this);
UUID id = UUID.randomUUID();
@@ -175,10 +175,12 @@ public class ClientSession extends AbstractRemoteSession {
ConnectionRequestResult result = testHost.requestEnvironment(exportedSession, id, config);
if (result != null && result.getStatus().getStatus()) {
connector.setConnected(true);
- return new TestHostConnection(connector, testHost, result.getEnvironment(), result.getSessionKey());
+ return new TestHostConnection(connector, testHost, result.getEnvironment(), result.getSessionKey(), false);
+ } else if (result != null && result.getStatus().isUnauthorizedUser()) {
+ return new TestHostConnection(null, testHost, null, null, true);
} else {
OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, "Error Connecting to the OTE Test Server.",
- new Exception(result.getStatus().getMessage()));
+ new Exception(result.getStatus().getMessage()));
}
return null;
} finally {
diff --git a/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/TestClientServiceImpl.java b/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/TestClientServiceImpl.java
index 176d3d3f7..24db862ac 100644
--- a/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/TestClientServiceImpl.java
+++ b/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/TestClientServiceImpl.java
@@ -89,7 +89,7 @@ public class TestClientServiceImpl implements IOteClientService, IConnectorListe
}
@Override
- public ConnectionEvent connect(IHostTestEnvironment testHost, IEnvironmentConfigurer configurer, TestEnvironmentConfig config, IProgressMonitor monitor) throws IllegalArgumentException, TestSessionException {
+ public ConnectionEvent connect(IHostTestEnvironment testHost, IEnvironmentConfigurer configurer, TestEnvironmentConfig config, IProgressMonitor monitor) throws IllegalArgumentException {
checkState();
final IServiceConnector connector;
final ClientSession localSession;
@@ -113,14 +113,20 @@ public class TestClientServiceImpl implements IOteClientService, IConnectorListe
if(configurer.configure(testHost, new SubProgressMonitor(monitor, 95)) && !monitor.isCanceled()){
testConnection = localSession.connect(connector, testHost, config);
if (testConnection != null) {
- // success
- ConnectionEvent event = new ConnectionEvent(testHost, connector, testConnection.getConnectEnvironment(), testConnection.getSessionKey());
- listenerNotifier.notifyPostConnection(event);
- return event;
+ if (testConnection.isUnauthorizedUser()) {
+ ConnectionEvent event = new ConnectionEvent(null, null, null, null, true);
+ testConnection = null; //Not really connected after this.
+ return event;
+ } else {
+ // success
+ ConnectionEvent event = new ConnectionEvent(testHost, connector, testConnection.getConnectEnvironment(), testConnection.getSessionKey(), false);
+ listenerNotifier.notifyPostConnection(event);
+ return event;
+ }
}
}
} catch (Exception e) {
- Activator.log(Level.SEVERE, "failed to establish connection", e);
+ Activator.log(Level.SEVERE, "failed to establish connection", e);
testConnection = null;
}
return null;
@@ -165,7 +171,7 @@ public class TestClientServiceImpl implements IOteClientService, IConnectorListe
} else {
ConnectionEvent event =
new ConnectionEvent(this.getConnectedHost(), testConnection.getConnectedTestHost(), envirnonment,
- testConnection.getSessionKey());
+ testConnection.getSessionKey(), false);
listenerNotifier.notifyDisconnect(event);
try {
session.disconnect(testConnection);
@@ -215,7 +221,7 @@ public class TestClientServiceImpl implements IOteClientService, IConnectorListe
if (testConnection != null) {
event = new ConnectionEvent(this.getConnectedHost(),
testConnection.getServiceConnector(), testConnection.getConnectEnvironment(),
- testConnection.getSessionKey());
+ testConnection.getSessionKey(), false);
} else {
event = null;
}
@@ -347,6 +353,7 @@ public class TestClientServiceImpl implements IOteClientService, IConnectorListe
@Override
public void onConnectionServiceStopped() {
+ // INTENTIONALLY EMPTY BLOCK
}
@Override
diff --git a/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/TestHostConnection.java b/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/TestHostConnection.java
index 6680b6b0f..d1ba198c1 100644
--- a/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/TestHostConnection.java
+++ b/org.eclipse.osee.ote.client/src/org/eclipse/osee/ote/service/core/TestHostConnection.java
@@ -30,18 +30,24 @@ class TestHostConnection {
private final UUID sessionKey;
private final IHostTestEnvironment host;
private String serverId;
+ private final boolean isUnauthorizedUser;
- TestHostConnection(IServiceConnector connector, IHostTestEnvironment host, ITestEnvironment connectEnvironment, UUID uuid) {
+ TestHostConnection(IServiceConnector connector, IHostTestEnvironment host, ITestEnvironment connectEnvironment,
+ UUID uuid, boolean isUnauthorizedUser) {
// intentionally package-private
- if (connector == null) {
- throw new NullPointerException("service connector cannot be null");
- }
- if (connectEnvironment == null) {
- throw new NullPointerException("test environment cannot be null");
- }
- if (uuid == null) {
- throw new NullPointerException("session key cannot be null");
+
+ if (!isUnauthorizedUser) {
+ if (connector == null) {
+ throw new NullPointerException("service connector cannot be null");
+ }
+ if (connectEnvironment == null) {
+ throw new NullPointerException("test environment cannot be null");
+ }
+ if (uuid == null) {
+ throw new NullPointerException("session key cannot be null");
+ }
}
+
this.serviceConnector = connector;
this.host = host;
this.connectEnvironment = connectEnvironment;
@@ -51,6 +57,7 @@ class TestHostConnection {
} catch (RemoteException e) {
this.serverId = "";
}
+ this.isUnauthorizedUser = isUnauthorizedUser;
}
/**
@@ -90,4 +97,8 @@ class TestHostConnection {
host.disconnect(sessionKey);
}
+
+ public boolean isUnauthorizedUser() {
+ return isUnauthorizedUser;
+ }
}
diff --git a/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/ReturnStatus.java b/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/ReturnStatus.java
index 164db8510..53188f44a 100644
--- a/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/ReturnStatus.java
+++ b/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/ReturnStatus.java
@@ -20,11 +20,13 @@ public class ReturnStatus implements Serializable {
private static final long serialVersionUID = -7774073812320127561L;
private final boolean status;
+ private final boolean unauthorizedUser;
private final String message;
- public ReturnStatus(String message, boolean status) {
+ public ReturnStatus(String message, boolean status, boolean unauthorizedUser) {
this.status = status;
this.message = message;
+ this.unauthorizedUser = unauthorizedUser;
}
public boolean getStatus() {
@@ -34,4 +36,8 @@ public class ReturnStatus implements Serializable {
public String getMessage() {
return message;
}
+
+ public boolean isUnauthorizedUser() {
+ return unauthorizedUser;
+ }
}
diff --git a/org.eclipse.osee.ote.properties/src/org/eclipse/osee/ote/properties/OtePropertiesCore.java b/org.eclipse.osee.ote.properties/src/org/eclipse/osee/ote/properties/OtePropertiesCore.java
index 45c2cfda3..5f7650175 100644
--- a/org.eclipse.osee.ote.properties/src/org/eclipse/osee/ote/properties/OtePropertiesCore.java
+++ b/org.eclipse.osee.ote.properties/src/org/eclipse/osee/ote/properties/OtePropertiesCore.java
@@ -2,6 +2,7 @@ package org.eclipse.osee.ote.properties;
public enum OtePropertiesCore implements OteProperties {
+ authorizedUser("ote.authorized.user"),
batchFolderDays("ote.batchfolder.days"),
brokerUriPort("ote.server.broker.uri.port"),
endpointPort("ote.endpoint.port"),
diff --git a/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OTEServerCreationComponent.java b/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OTEServerCreationComponent.java
index 1a797f702..7e34c3b9c 100644
--- a/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OTEServerCreationComponent.java
+++ b/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OTEServerCreationComponent.java
@@ -45,7 +45,14 @@ public class OTEServerCreationComponent {
if (outfileLocation == null) {
outfileLocation = OtePropertiesCore.javaIoTmpdir.getValue();
}
- String title = OtePropertiesCore.serverTitle.getValue();
+
+ String title;
+ if (OtePropertiesCore.authorizedUser.getValue() != null) {
+ title = OtePropertiesCore.serverTitle.getValue() + "[AUTHORIZED USER:" + OtePropertiesCore.authorizedUser.getValue() + "]";
+ } else {
+ title = OtePropertiesCore.serverTitle.getValue();
+ }
+
String name = OtePropertiesCore.userName.getValue();
String keepEnvAliveWithNoUsersStr = OtePropertiesCore.serverKeepalive.getValue();
boolean keepEnvAliveWithNoUsers = true;
diff --git a/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteService.java b/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteService.java
index a5c3ce38a..2c103652d 100644
--- a/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteService.java
+++ b/org.eclipse.osee.ote.server/src/org/eclipse/osee/ote/server/internal/OteService.java
@@ -77,7 +77,7 @@ public class OteService implements IHostTestEnvironment {
enhancedProperties.setProperty(HostServerProperties.owner.name(), OtePropertiesCore.userName.getValue());
enhancedProperties.setProperty(HostServerProperties.id.name(), serviceID.toString());
enhancedProperties.setProperty(HostServerProperties.isSim.name(), Boolean.toString(environmentCreation.isSimulated()));
-// enhancedProperties.setProperty(HostServerProperties.activeMq.name(), environmentCreation.getBroker().getUri().toString());
+ // enhancedProperties.setProperty(HostServerProperties.activeMq.name(), environmentCreation.getBroker().getUri().toString());
try {
String format = String.format("tcp://%s:%d", receiver.getLocalEndpoint().getAddress().getHostAddress(), receiver.getLocalEndpoint().getPort());
if(OtePropertiesCore.httpPort.getValue() == null){
@@ -115,7 +115,7 @@ public class OteService implements IHostTestEnvironment {
// }
@Override
- public EnhancedProperties getProperties() throws RemoteException {
+ public EnhancedProperties getProperties() {
return enhancedProperties;
}
@@ -123,14 +123,20 @@ public class OteService implements IHostTestEnvironment {
public ConnectionRequestResult requestEnvironment(IRemoteUserSession session, UUID sessionId, TestEnvironmentConfig config) throws RemoteException {
try {
OseeLog.log(OteService.class, Level.INFO,
- "received request for test environment from user " + session.getUser().getName());
- if (!isEnvironmentAvailable()) {
- createEnvironment();
+ "received request for test environment from user " + session.getUser().getName());
+
+ if (isAuthorizedUser(session)) {
+ if (!isEnvironmentAvailable()) {
+ createEnvironment();
+ }
+
+ oteSessions.add(sessionId, session);
+ updateDynamicInfo();
+ return new ConnectionRequestResult(remoteEnvironment, sessionId, new ReturnStatus("Success", true, false));
+ }
+ else {
+ return new ConnectionRequestResult(null, null, new ReturnStatus("Failure", false, true));
}
-
- oteSessions.add(sessionId, session);
- updateDynamicInfo();
- return new ConnectionRequestResult(remoteEnvironment, sessionId, new ReturnStatus("Success", true));
} catch (Throwable ex) {
OseeLog.log(OteService.class, Level.SEVERE,
"Exception while requesting environment for user " + session.getUser().getName(), ex);
@@ -138,6 +144,21 @@ public class OteService implements IHostTestEnvironment {
}
}
+ private boolean isAuthorizedUser(IRemoteUserSession session) throws RemoteException {
+
+ if (OtePropertiesCore.authorizedUser.getValue() == null) {
+ return true;
+ } else {
+ String [] authorizedUsers = OtePropertiesCore.authorizedUser.getValue().split(",");
+ for (int i = 0; i < authorizedUsers.length; i++) {
+ if (authorizedUsers[i].equals(session.getUser().getName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
private void createEnvironment() throws Throwable {
currentEnvironment = environmentCreation.createEnvironment();
remoteEnvironment = environmentCreation.createRemoteTestEnvironment(currentEnvironment);
@@ -148,7 +169,7 @@ public class OteService implements IHostTestEnvironment {
return remoteEnvironment != null;
}
- public void updateDynamicInfo() throws RemoteException {
+ public void updateDynamicInfo() {
Collection<OSEEPerson1_4> userList = new LinkedList<>();
StringBuilder sb = new StringBuilder();
if (isEnvironmentAvailable()) {
@@ -176,11 +197,11 @@ public class OteService implements IHostTestEnvironment {
// }
}
- public ServiceID getServiceID() throws RemoteException {
+ public ServiceID getServiceID() {
return serviceID;
}
- public void kill() throws RemoteException {
+ public void kill() {
if(currentEnvironment != null){
currentEnvironment.shutdown();
}
@@ -191,7 +212,7 @@ public class OteService implements IHostTestEnvironment {
// }
@Override
- public void disconnect(UUID sessionId) throws RemoteException {
+ public void disconnect(UUID sessionId) {
if (currentEnvironment != null) {
oteSessions.remove(sessionId);
updateDynamicInfo();
@@ -199,7 +220,7 @@ public class OteService implements IHostTestEnvironment {
}
@Override
- public String getHttpURL() throws RemoteException {
+ public String getHttpURL() {
return (String)enhancedProperties.getProperty("appServerURI");
}

Back to the top