Issue #440 username/password logging fixes, synchronize all times collaboratorShapes are manipulated

Former-commit-id: f1ea85ea44 [formerly f1ea85ea44 [formerly 9255532085a1d43955345092d567e04222bbb06d]]
Former-commit-id: 096b526e7a
Former-commit-id: 9c36b710dc
This commit is contained in:
Matt Nash 2012-05-15 15:59:08 -05:00
parent 660334e023
commit 8022bb6e79
5 changed files with 124 additions and 37 deletions

View file

@ -0,0 +1,51 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 15, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class UsernamePasswordException extends CollaborationException {
private static final long serialVersionUID = 3124620509180835631L;
/**
* @param message
* @param cause
*/
public UsernamePasswordException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -28,8 +28,6 @@ import org.eclipse.ecf.core.ContainerConnectException;
import org.eclipse.ecf.core.ContainerCreateException;
import org.eclipse.ecf.core.ContainerFactory;
import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.IContainerListener;
import org.eclipse.ecf.core.events.IContainerEvent;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.IDFactory;
@ -58,6 +56,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager;
import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.comm.identity.UsernamePasswordException;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent;
@ -167,16 +166,6 @@ public class CollaborationConnection implements IEventPublisher {
container = ContainerFactory.getDefault().createContainer(PROVIDER);
if (container != null) {
container.addListener(new IContainerListener() {
@Override
public void handleEvent(IContainerEvent event) {
// TODO?
System.out.println("ContainerEvent.Type = "
+ event.getClass().getName());
}
});
// add the listeners before we connect so we don't potentially
// miss something
presenceAdapter = Tools.getPresenceContainerAdapter(container,
@ -195,7 +184,7 @@ public class CollaborationConnection implements IEventPublisher {
connectToContainer();
} catch (ContainerConnectException e) {
closeInternals();
throw new CollaborationException(
throw new UsernamePasswordException(
"Login failed. Invalid username or password", e);
}
ID id = container.getConnectedID();
@ -204,6 +193,7 @@ public class CollaborationConnection implements IEventPublisher {
String host = Tools.parseHost(id.getName());
String resource = Tools.parseResource(id.getName());
user = new UserId(name, host, resource);
user.setId(id);
}
setupAccountManager();
@ -513,12 +503,15 @@ public class CollaborationConnection implements IEventPublisher {
UserId id = IDConverter.convertFrom(fromId);
if (rosterManager != null) {
IRosterEntry entry = contactsMgr.getUsersMap().get(
id);
if (contactsMgr != null
&& contactsMgr.getUsersMap() != null) {
IRosterEntry entry = contactsMgr.getUsersMap()
.get(id);
((RosterEntry) entry).setPresence(presence);
eventBus.post(entry);
}
}
}
});
presenceAdapter.getRosterManager().addRosterListener(

View file

@ -49,6 +49,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
import com.raytheon.uf.viz.collaboration.comm.identity.UsernamePasswordException;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.ui.Activator;
@ -373,10 +374,26 @@ public class LoginDialog extends CaveSWTDialog {
};
});
} catch (CollaborationException e) {
statusHandler.handle(Priority.PROBLEM,
if (e instanceof UsernamePasswordException) {
VizApp.runAsync(new Runnable() {
public void run() {
MessageBox messageBox = new MessageBox(
getShell(),
SWT.ERROR);
messageBox
.setText("Login Error");
messageBox
.setMessage("Wrong username/password entered");
messageBox.open();
};
});
} else {
statusHandler
.handle(Priority.PROBLEM,
"Unable to create connection",
e);
}
}
return Status.OK_STATUS;
};
};

View file

@ -23,6 +23,7 @@ import java.util.Collection;
import java.util.Iterator;
import org.eclipse.swt.graphics.RGB;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.LinkedHashMultimap;
@ -220,8 +221,12 @@ public class CollaborationDrawingLayer extends DrawingLayer {
while (itr.hasNext()) {
lastElement = itr.next();
}
synchronized (deletedCollaboratorShapes) {
deletedCollaboratorShapes.put(userName, lastElement);
}
synchronized (collaboratorShapes) {
collaboratorShapes.get(userName).remove(lastElement);
}
break;
case REDO:
userName = event.getUserName();
@ -234,8 +239,12 @@ public class CollaborationDrawingLayer extends DrawingLayer {
while (itr.hasNext()) {
lastElement = itr.next();
}
synchronized (collaboratorShapes) {
collaboratorShapes.put(userName, lastElement);
}
synchronized (deletedCollaboratorShapes) {
deletedCollaboratorShapes.get(userName).remove(lastElement);
}
break;
case CLEAR:
resetTemp();
@ -300,8 +309,9 @@ public class CollaborationDrawingLayer extends DrawingLayer {
containers.put(userName, cont);
}
}
collaboratorShapes.clear();
collaboratorShapes.putAll(containers);
}
collaboratorShapes = containers;
break;
}
issueRefresh();
@ -320,16 +330,20 @@ public class CollaborationDrawingLayer extends DrawingLayer {
for (ShapeContainer shape : map.get(cont)) {
shape.getShape().dispose();
}
synchronized (collaboratorShapes) {
collaboratorShapes.removeAll(cont);
}
}
}
// this is what i was thinking of for clearing all shapes
// for (ShapeContainer cont : collaboratorShapes.get(userName)) {
// cont.getShape().dispose();
// }
synchronized (collaboratorShapes) {
collaboratorShapes.removeAll(userName);
}
}
/*
* (non-Javadoc)
@ -529,4 +543,16 @@ public class CollaborationDrawingLayer extends DrawingLayer {
// deletedCollaboratorShapes.clear();
// }
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.drawing.DrawingLayer#project(org.opengis.referencing
* .crs.CoordinateReferenceSystem)
*/
@Override
public void project(CoordinateReferenceSystem crs) throws VizException {
super.project(crs);
}
}