• Main Page
  • Related Pages
  • Packages
  • Classes
  • Files
  • File List

ui/JSecState.java

Go to the documentation of this file.
00001 
00002 /**
00003  *  Package with components extending Swing GUI 
00004  */
00005 package ui;
00006 
00007 import java.awt.Dimension;
00008 
00009 import javax.swing.ImageIcon;
00010 import javax.swing.JLabel;
00011 
00012 /**
00013  *  Image indicating security state (unsecured/secured-unverified/secured-trusted). 
00014  *
00015  *  @author Mikica B Kocic
00016  */
00017 public class JSecState extends JLabel 
00018 {
00019     private static final long serialVersionUID = 1853852857708971435L;
00020 
00021     /**
00022      *  Possible security states
00023      */
00024     public enum State
00025     {
00026         /** Not secured (un-encrypted) */
00027         UNSECURED,
00028         
00029         /** Untrusted secured (remote party is not verified) */
00030         VERIFIED,
00031         
00032         /** Trusted secured (remote party is verified) */
00033         UNVERIFIED
00034     };
00035     
00036     /**
00037      *  Current security state
00038      */
00039     private State state;
00040     
00041     /*  Security state icons
00042      */
00043     private ImageIcon iconUnsecured;
00044     private ImageIcon iconVerified;
00045     private ImageIcon iconUnverified;
00046     
00047     /**
00048      *  Constructs object in UNSECURED state by default
00049      */
00050     public JSecState( Object resourceOwner )
00051     {
00052         iconUnsecured  = JImageButton.loadIcon( resourceOwner, "unsecured.png" );
00053         iconVerified   = JImageButton.loadIcon( resourceOwner, "verified.png" );
00054         iconUnverified = JImageButton.loadIcon( resourceOwner, "unverified.png" );
00055         
00056         setState( State.UNSECURED );
00057         setMinimumSize( new Dimension( 32, 32 ) );
00058         setMaximumSize( new Dimension( 32, 32 ) );
00059     }
00060     
00061     /**
00062      *  Gets current security state
00063      */
00064     public State getState ()
00065     {
00066         return this.state;
00067     }
00068 
00069     /**
00070      *  Stes new security state
00071      */
00072     public void setState( State newState )
00073     {
00074         this.state = newState;
00075         switch( this.state )
00076         {
00077         case UNSECURED:
00078             setIcon( iconUnsecured );
00079             setToolTipText( 
00080                     "<html><head></head><body><p><span style='color:red'>"
00081                     + "Unsecured and untrusted communication.</span>"
00082                     + "<br/>Instant messages will be unciphered and broadcasted to public."
00083                     + "</p></body></html>"
00084                     );
00085             break;
00086         case UNVERIFIED:
00087             setIcon( iconUnverified );
00088             setToolTipText( 
00089                     "<html><head></head><body><p><span style='color:#8000FF'>"
00090                     + "Secured (encrypted) communication with unverified peer.</span>"
00091                     + "<br/>Instant messages will be ciphered and sent to peer only."
00092                     + "</p></body></html>"
00093                     );
00094             break;
00095         case VERIFIED:
00096             setIcon( iconVerified );
00097             setToolTipText( 
00098                     "<html><head></head><body><p><span style='color:green'>"
00099                     + "Secured communication with the trusted peer.</span>"
00100                     + "<br/>Instant messages will be ciphered and sent to peer only."
00101                     + "</p></body></html>"
00102                     );
00103             break;
00104         }
00105     }
00106 }

Generated on Thu Dec 16 2010 14:44:42 for VoIP Kryptofon by  doxygen 1.7.2