|
|||||||||
| Home >> All >> com >> synaptics >> [ elvis overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.synaptics.elvis
Class Elvis

java.lang.Objectcom.synaptics.elvis.Elvis
- All Implemented Interfaces:
- java.io.Serializable
- public class Elvis
- extends java.lang.Object
- implements java.io.Serializable
- extends java.lang.Object
Elvis is a package for implementing a singleton, not only within a JVM, but for a given user on a particular machine.
Principles of operation. The model of use for Elvis is simple.
An Elvis-enabled program calls Elvis.get()
with a program name and a command handler. This name is used to (hopefully) uniquely
identify the Elvis-enabled program and its functions. If Elvis can establish that he
is indeed the only running instance of that particular program (for that user, on that machine),
he will become the One True Elvis, and establish a thread that will listen for requests
from other Elvis's (also known as Elvis impersonators or Elvis clients).
Once the call to Elvis.get() returns, the program can call isTheOneTrueElvis()
to determine if their
Elvis is the One True Elvis. If it isn't they probably just want to send the other Elvis
some messages indicating what it wants to do, and then leave the building (exit gracefully).
KNOWN SECURITY HOLES The current version of Elvis is most emphatically not secure. The most prominent holes are:
- On multi-user systems (such as Linux/Unix), the Elvis information file
may be created readable by users other than the creator. An attacker to could read the Elvis
information file to determine the port, key, and user. This information could
be used to:
- Submit bogus requests to the One True Elvis;
- Spoof responses from the One True Elvis.
- If the attacker could determine that the One True Elvis is not running, he could use this information to set up his own fraudlent Elvis.
- On multi-user systems (such as Linux/Unix), the Elvis information file may be created writable by users other than the creator. An attacker to could substitute his own information in the file, and redirect requests to his own fraudulent Elvis.
- In almost all cases, things that are symptomatic of an attack or probe of Elvis are simply logged, and no further actions are taken.
Right now, my use of Elvis is in a trusted environment, where these situations are considered very unlikely to occur. Although updates are planned for upcoming releases of Elvis, if you are planning to use this release of Elvis in a less secure environment, you should seriously consider beefing up Elvis's security.
- Version:
- $Id: Elvis.java,v 1.1 2002/05/09 07:17:17 clheiny Exp $
| Nested Class Summary | |
private class |
Elvis.StatusListener
This is used to monitor the status of the ElvisComm, and adjust the feedback string as necessary (among other possible, not yet implemented, actions. |
| Field Summary | |
private java.lang.String |
feedback
A handy dandy feedback string that the Elvis application can consult. |
private ElvisHandler |
handler
The request handler, provided by the Elvis application |
private boolean |
inTheBuilding
Indicates whether this Elvis is active or not. |
private ElvisComm |
listener
The listener handles most of Elvis's communication. |
private int |
port
The port associated with this instance of Elvis |
private java.lang.String |
program
This is the name of the Elvis program associated with this instance of Elvis |
private java.beans.PropertyChangeSupport |
propertyChangeSupport
Utility field used by bound properties. |
private java.beans.PropertyChangeSupport |
propertySupport
|
private boolean |
theOneTrueElvis
A flag indicating whether we really are the King or not. |
| Constructor Summary | |
private |
Elvis(java.lang.String program,
int port,
ElvisHandler handler,
java.beans.PropertyChangeListener propListener)
Creates a new Elvis. |
| Method Summary | |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a PropertyChangeListener to the listener list. |
static Elvis |
get(java.lang.String program,
int port,
ElvisHandler handler)
Get an instance of the specified Elvis program on the specified port. |
static Elvis |
get(java.lang.String program,
int port,
ElvisHandler handler,
java.beans.PropertyChangeListener propListener)
Get an instance of the specified Elvis program on the specified port. |
java.lang.String |
getFeedback()
The feedback property provides information about the state and activities of Elvis. |
ElvisHandler |
getHandler()
Returns the handler associated with this Elvis. |
int |
getPort()
Get the port number that this Elvis is (or should be) listening on. |
java.lang.String |
getProgram()
The program name is the unique identifier for this Elvis's functionality. |
boolean |
hasLeftTheBuilding()
Returns true if Elvis has left the building; false if he
is still around and ready to perform. |
boolean |
isTheOneTrueElvis()
theOneTrueElvis indicates whether this Elvis is The King (true)
or just an impersonator (false). |
void |
leaveTheBuilding()
Calling leaveTheBuilding() will result in the Elvis listener thread
being cancelled (if this Elvis is the one true Elvis) and most Elvis related infrastructure
being dismantled. |
ElvisResult |
perform(java.lang.String data)
Calling this will cause Elvis to do something. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a PropertyChangeListener from the listener list. |
private void |
setFeedback(java.lang.String feedback)
Update the feedback string and notify any listeners. |
void |
setHandler(ElvisHandler handler)
Set the Handler for this Elvis. |
private void |
setHandlerInternal(ElvisHandler handler)
Internal worker that actually does the handler setting. |
private void |
setPort(int port)
setPort should only be called at class instantiation time. |
private void |
setProgram(java.lang.String program)
The program name can only be set internally, preferably at creation time. |
private void |
setTheOneTrueElvis(boolean theOneTrueElvis)
We can only set this ourselves. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
propertySupport
private java.beans.PropertyChangeSupport propertySupport
theOneTrueElvis
private boolean theOneTrueElvis
- A flag indicating whether we really are the King or not.
port
private int port
- The port associated with this instance of Elvis
program
private java.lang.String program
- This is the name of the Elvis program associated with this instance of Elvis
inTheBuilding
private boolean inTheBuilding
- Indicates whether this Elvis is active or not. If Elvis has left the building,
the Elvis listen thread has been cancelled, and most method invocations will throw
an ElvisException.
handler
private ElvisHandler handler
- The request handler, provided by the Elvis application
listener
private ElvisComm listener
- The listener handles most of Elvis's communication.
feedback
private java.lang.String feedback
- A handy dandy feedback string that the Elvis application can consult.
propertyChangeSupport
private java.beans.PropertyChangeSupport propertyChangeSupport
- Utility field used by bound properties.
| Constructor Detail |
Elvis
private Elvis(java.lang.String program, int port, ElvisHandler handler, java.beans.PropertyChangeListener propListener)
- Creates a new Elvis. This is private to force folks to use the factory method. We
want them to use the factory, so we can catch attempts to create multiple Elvises on
the same port.
We presume the parameters have already been vetted by the factory, and don't check them here.
| Method Detail |
get
public static final Elvis get(java.lang.String program, int port, ElvisHandler handler)
- Get an instance of the specified Elvis program on the specified port. The
program name may not contain the
':'or end of line characters.If we are indeed the one true Elvis, the specified ElvisHandler will be used to handle requests.
get
public static final Elvis get(java.lang.String program, int port, ElvisHandler handler, java.beans.PropertyChangeListener propListener)
- Get an instance of the specified Elvis program on the specified port. The
program name may not contain the
':'or end of line characters.If we are indeed the one true Elvis, the specified ElvisHandler will be used to handle requests.
isTheOneTrueElvis
public boolean isTheOneTrueElvis()
theOneTrueElvisindicates whether this Elvis is The King (true) or just an impersonator (false).If we are indeed the One True Elvis, then we will be handling all Elvis based interactions for all JVMs. The client must be ready to deal with this.
setTheOneTrueElvis
private void setTheOneTrueElvis(boolean theOneTrueElvis)
- We can only set this ourselves. This will prevent someone from deciding they want to
impersonate Elvis.
getPort
public int getPort()
- Get the port number that this Elvis is (or should be) listening on.
getProgram
public java.lang.String getProgram()
- The program name is the unique identifier for this Elvis's functionality.
It is unique (hopefully) across all Elvis-capable programs in all JVMs.
This uniqueness is actually subject to the discipline exercised by the various Elvis client programmers. There is nothing in the Elvis implementation that prevents two different programmers from attempting to implement two very different Elvis programs using the name
Splat. The best advice I can offer is Don't do this! Instead, try using the fully qualified (package name and class name) for the class implementing the Elvis-based functionality.
setPort
private void setPort(int port)
- setPort should only be called at class instantiation time.
setProgram
private void setProgram(java.lang.String program)
- The program name can only be set internally, preferably at creation time.
leaveTheBuilding
public void leaveTheBuilding()
- Calling
leaveTheBuilding()will result in the Elvis listener thread being cancelled (if this Elvis is the one true Elvis) and most Elvis related infrastructure being dismantled. Once Elvis has left the building, most method calls will through an ElvisException.
hasLeftTheBuilding
public boolean hasLeftTheBuilding()
- Returns
trueif Elvis has left the building;falseif he is still around and ready to perform.
getHandler
public ElvisHandler getHandler()
- Returns the handler associated with this Elvis. This will be
nullif we are not the One True Elvis.
setHandler
public void setHandler(ElvisHandler handler)
- Set the Handler for this Elvis.
setHandlerInternal
private void setHandlerInternal(ElvisHandler handler)
- Internal worker that actually does the handler setting.
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
- Add a PropertyChangeListener to the listener list.
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
- Removes a PropertyChangeListener from the listener list.
getFeedback
public java.lang.String getFeedback()
- The feedback property provides information about the state and activities of Elvis. For
example, various stages of establishing the ports we listen to are reported.
This is not intended to be a definitive means of determining the status of Elvis. It's more intended to give useful text information that can be presented in status bars and stuff like that.
setFeedback
private void setFeedback(java.lang.String feedback)
- Update the feedback string and notify any listeners.
perform
public ElvisResult perform(java.lang.String data)
- Calling this will cause Elvis to do something. If we are the one true Elvis, the local
ElvisHandler will be called with the specified data. If we are not the one true Elvis, the
remote Elvis will be requested to perform and passed the specified data.
|
|||||||||
| Home >> All >> com >> synaptics >> [ elvis overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.synaptics.elvis.Elvis