GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members  

SecurityContext.java

Go to the documentation of this file.
00001 package org.gridlab.gat.security;
00002 
00003 import java.net.URI;
00004 
00005 
00006 /**
00007  * A container for security Information.  Each context has a name and a
00008  * type, and a data object associated with it.  The data object is opaque
00009  * to the GAT API and is used and manipulated by adaptors based upon
00010  * their interpretation of the type.
00011  * <p>
00012  * Currently we provide additional auxiliary methods to create a context
00013  * based upon password information or upon credentials stored in a file.
00014  * Contexts based upon these mechanisms can be used by adaptors to create
00015  * further contexts containing opaque data objects, e.g. GSSAPI credentials.
00016  */
00017 public class SecurityContext implements Cloneable {
00018     /**
00019      * This member variables holds the name of the SecurityContext
00020      */
00021     private String name = null;
00022     
00023     /**
00024      * This member variables holds the type of the SecurityContext
00025      */    
00026     private String type = null;
00027     
00028     /**
00029      * This member variables holds the object of the SecurityContext
00030      */    
00031     private Object object = null;
00032     
00033     /**
00034      * This member variables holds the username of the SecurityContext
00035      */    
00036     private String username = null;
00037     
00038     /**
00039      * This member variables holds the password of the SecurityContext
00040      */    
00041     private String password = null;
00042     
00043     /**
00044      * This member variables holds the URI of the keyfile of the 
00045      * SecurityContext
00046      */    
00047     private URI keyfile = null;
00048     
00049     /**
00050      * This member variables holds the URI of the certificate of 
00051      * the SecurityContext
00052      */        
00053     private URI certificate = null;
00054     
00055     /**
00056      * This member variables holds the passphrase of the SecurityContext
00057      */        
00058     private String passphrase = null;
00059     
00060     
00061     /**
00062      * Creates a new security context.
00063      *
00064      * @param name A java.lang.String description
00065      */
00066     public SecurityContext(String name) {
00067         this.name = name;
00068     }
00069     
00070     /**
00071      * Creates a new security context with a specific name, type 
00072      * and data object associated with it.
00073      *
00074      * @param name A java.lang.String description
00075      * @param type A java.lang.String description
00076      * @param object An Object associated with this data
00077      */
00078     public SecurityContext(String name, String type, Object object) {
00079         this.name = name;
00080         this.type = type;
00081         this.object = object;
00082     }
00083 
00084     /** 
00085   Check two SecurityContexts for equality.
00086      */
00087     public boolean equals(Object obj) {
00088   if(! (obj instanceof SecurityContext)) return false;
00089 
00090   SecurityContext other = (SecurityContext) obj;
00091 
00092   return other.name.equals(name) && other.type.equals(type);
00093     }
00094 
00095     /**
00096      * Returns a clone of this context.
00097      */
00098     public Object clone() {
00099   return null;
00100     }
00101 
00102     /**
00103      *  Makes this a "Password" type security context and stores 
00104      *  the username and password in the context.
00105      *
00106      * @param username A username, a java.lang.String,  associated 
00107      * with password.
00108      * @param password A password, a java.lang.String.
00109      */
00110     public void passwordAuthenticate(String username, String password) {
00111         this.username = username;
00112         this.password = password;
00113     }
00114     
00115     /**
00116      *  Makes this a "Certificate" type security context and stores 
00117      * the information about the location of keyfile and certificate 
00118      * file in the context.
00119      *
00120      * @param keyfile The URI of keyfile
00121      * @param certificate The URI of certificate file
00122      */
00123     public void certificateAuthenticate(URI keyfile, URI certificate) {
00124         this.keyfile = keyfile;
00125         this.certificate = certificate;
00126     }
00127    
00128     /**
00129      *  Makes this a "Certificate" type security context and stores 
00130      * the information about the location of keyfile and certificate 
00131      * file in the context.
00132      *
00133      * @param keyfile The URI of keyfile
00134      * @param certificate The URI of certificate file
00135      * @param passphrase The passphrase a java.lang.String
00136      */
00137     public void certificateAuthenticate(URI keyfile, URI certificate, String passphrase) {
00138         this.keyfile = keyfile;
00139         this.certificate = certificate;
00140         this.passphrase = passphrase;
00141     }
00142     
00143     /**
00144      *  Gets the name associated with the security context.
00145      *
00146      * @return The name, a java.lang.String, associated with the context.
00147      */
00148     public String getName() {
00149         return name;
00150     }
00151     
00152     /**
00153      *  Gets the type associated with the security context.
00154      *
00155      * @return The type associated with the context, a java.lang.String
00156      */
00157     public String getType() {
00158         return type;
00159     }
00160 
00161     /**
00162      *  Gets the username associated with the security context.
00163      *
00164      * @return The type associated with the context, a java.lang.String
00165      */
00166     public String getUsername() {
00167   return username;
00168     }
00169 
00170     /**
00171      *  Gets the type associated with the security context.
00172      *
00173      * @return The password associated with the context, a java.lang.String
00174      */
00175     public String getPassword() {
00176   return password;
00177     }
00178 
00179     /**
00180      *  Gets the type associated with the security context.
00181      *
00182      * @return The location of the keyfile associated with the context.
00183      */
00184     public URI getKeyfile() {
00185   return keyfile;
00186     }
00187 }