com.ibm.aglets
Class AgletRuntime

java.lang.Object
  |
  +--com.ibm.aglet.system.AgletRuntime
        |
        +--com.ibm.aglets.AgletRuntime

public final class AgletRuntime
extends AgletRuntime


Field Summary
static int AGLET_MAGIC
          Magic number of Aglet
static byte AGLET_STREAM_VERSION
          Version of Aglet Trasfer Format
 
Constructor Summary
AgletRuntime()
           
 
Method Summary
 java.security.cert.Certificate authenticateOwner(java.lang.String username, java.lang.String password)
          Authenticate an user with password.
static java.security.cert.Certificate authenticateUser(java.lang.String username, java.lang.String password)
          Authenticate an user with password.
static void clearCache()
          Clear cache
 AgletProxy createAglet(java.lang.String contextName, java.net.URL codebase, java.lang.String classname, java.lang.Object init)
          Creates an aglet remotely within the specified context.
 AgletContext createAgletContext(java.lang.String name)
          AgletContext managements in this runtime
static Persistence createPersistenceFor(AgletContext cxt)
           
 AgletContext getAgletContext(java.lang.String name)
          Returns the AgletContext which has the specified name.
 AgletContext[] getAgletContexts()
          Gets the contexts in the environment.
 AgletProxy[] getAgletProxies(java.lang.String contextName)
          Gets an enumeration of aglet proxies of all aglets residing in the context specified by contextAddress.
 AgletProxy getAgletProxy(java.lang.String contextName, AgletID aid)
          Obtains a proxy reference the remote aglet.
 java.lang.String getAgletsProperty(java.lang.String key)
          Returns aglets property of the user who owns the runtime.
 java.lang.String getAgletsProperty(java.lang.String key, java.lang.String def)
          Returns aglets property of the user who owns the runtime.
static java.security.cert.Certificate getCertificate(byte[] encoded)
          Returns certificate of a user.
static java.security.cert.Certificate getCertificate(java.lang.String username)
          Returns certificate of a user.
static java.lang.String getCertificateAlias(java.security.cert.Certificate cert)
           
static ResourceManagerFactory getDefaultResourceManagerFactory()
           
 java.security.cert.Certificate getOwnerCertificate()
          Returns certificate of the user who owns the runtime.
 java.lang.String getOwnerName()
          Returns name of the user who owns the runtime.
static java.security.PrivateKey getPrivateKey(java.security.cert.Certificate cert, char[] passwd)
           
 java.lang.String getProperty(java.lang.String prop, java.lang.String key)
          Returns property of the user who owns the runtime.
 java.lang.String getProperty(java.lang.String prop, java.lang.String key, java.lang.String def)
          Returns property of the user who owns the runtime.
static java.security.cert.Certificate getRegisteredCertificate(java.lang.String username)
          Returns certificate of a registered user.
 java.lang.String getServerAddress()
          Gets an address of the server
protected  void initialize(java.lang.String[] args)
          Initializes an AgletRuntime object with the given array of string.
static boolean isVerbose()
          Verbose message
 void killAglet(AgletProxy proxy)
          Kill the specified aglet.
 void removeAgletContext(AgletContext cxt)
          Removes the specified aglet context from the runtime environment.
 void setAgletsProperty(java.lang.String key, java.lang.String value)
          Sets aglets property of the user who owns the runtime.
static void setDefaultResourceManagerFactory(ResourceManagerFactory factory)
           
static void setPersistenceFactory(PersistenceFactory p_factory)
           
 void setProperty(java.lang.String prop, java.lang.String key, java.lang.String value)
          Sets property of the user who owns the runtime.
 void shutdown()
          Shutdown
 void shutdown(Message msg)
          Shutdown all contexts in the current runtime with the specific message object.
static void verboseOut(java.lang.String msg)
           
 
Methods inherited from class com.ibm.aglet.system.AgletRuntime
getAgletRuntime, init, init, isSecure, setSecure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AGLET_MAGIC

public static final int AGLET_MAGIC
Magic number of Aglet

AGLET_STREAM_VERSION

public static final byte AGLET_STREAM_VERSION
Version of Aglet Trasfer Format
Constructor Detail

AgletRuntime

public AgletRuntime()
Method Detail

authenticateOwner

public java.security.cert.Certificate authenticateOwner(java.lang.String username,
                                                        java.lang.String password)
Authenticate an user with password. When the password is correct, the user owns the runtime and returns the owner's certificate.
Overrides:
authenticateOwner in class AgletRuntime
Parameters:
username - username of the user who will own the runtime
password - password of the user
Returns:
the owner's certificate when authentication of the user succeeds

authenticateUser

public static java.security.cert.Certificate authenticateUser(java.lang.String username,
                                                              java.lang.String password)
Authenticate an user with password. When the password is correct, returns the Certificate.
Parameters:
username - username of the user
password - password of the user
Returns:
Certificate of the user, null if the authentication was in fail. ????NEED IMPL (HT)

clearCache

public static void clearCache()
Clear cache

createAglet

public AgletProxy createAglet(java.lang.String contextName,
                              java.net.URL codebase,
                              java.lang.String classname,
                              java.lang.Object init)
                       throws java.io.IOException
Description copied from class: AgletRuntime
Creates an aglet remotely within the specified context.
Overrides:
createAglet in class AgletRuntime
Following copied from class: com.ibm.aglet.system.AgletRuntime
Parameters:
contextAddress - an address of context.
codebase - an codebase for the aglet.
name - name of aglets' class.
init - an object passed as an initialize argument.
See Also:
Aglet.onCreation(java.lang.Object), AgletContext.createAglet(java.net.URL, java.lang.String, java.lang.Object)

createAgletContext

public AgletContext createAgletContext(java.lang.String name)
AgletContext managements in this runtime
Overrides:
createAgletContext in class AgletRuntime
Following copied from class: com.ibm.aglet.system.AgletRuntime
Throws:
java.lang.SecurityException - if the current execution is not allowed to create an AgletContext.

createPersistenceFor

public static Persistence createPersistenceFor(AgletContext cxt)

getAgletContext

public AgletContext getAgletContext(java.lang.String name)
Description copied from class: AgletRuntime
Returns the AgletContext which has the specified name.
Overrides:
getAgletContext in class AgletRuntime
Following copied from class: com.ibm.aglet.system.AgletRuntime
Parameters:
name - the name of the context
Throws:
java.lang.SecurityException - if the current execution is not allowed to acccess the AgletContext.

getAgletContexts

public AgletContext[] getAgletContexts()
Description copied from class: AgletRuntime
Gets the contexts in the environment.
Overrides:
getAgletContexts in class AgletRuntime

getAgletProxies

public AgletProxy[] getAgletProxies(java.lang.String contextName)
                             throws java.io.IOException
Gets an enumeration of aglet proxies of all aglets residing in the context specified by contextAddress.
Overrides:
getAgletProxies in class AgletRuntime
Parameters:
contextAddress -  

getAgletProxy

public AgletProxy getAgletProxy(java.lang.String contextName,
                                AgletID aid)
                         throws java.io.IOException
Obtains a proxy reference the remote aglet.
Overrides:
getAgletProxy in class AgletRuntime
Following copied from class: com.ibm.aglet.system.AgletRuntime
Parameters:
contextAddress - specify context URL with a string.
id - target aglet identifyer.

getAgletsProperty

public java.lang.String getAgletsProperty(java.lang.String key)
Returns aglets property of the user who owns the runtime. It needs PropertyPermission for the key of aglets property.
Overrides:
getAgletsProperty in class AgletRuntime
Parameters:
key - key of aglets property
Returns:
aglets property of the user who owns the runtime. If the property for the key does not exist, return null.
Throws:
java.lang.SecurityException - if PropertyPermission for the key is not give.

getAgletsProperty

public java.lang.String getAgletsProperty(java.lang.String key,
                                          java.lang.String def)
Returns aglets property of the user who owns the runtime. It needs PropertyPermission for the key of aglets property.
Overrides:
getAgletsProperty in class AgletRuntime
Parameters:
key - key of aglets property
def - default value of aglets property
Returns:
aglets property of the user who owns the runtime. If the property for the key does not exist, return def.
Throws:
java.lang.SecurityException - if PropertyPermission for the key is not given.

getCertificate

public static java.security.cert.Certificate getCertificate(byte[] encoded)
Returns certificate of a user. If the user's certificate is not found, returns the certificate of anonymous user whose alias is indicated by "aglets.keystore.anonymousAlias" property. Certificate is read from the keystore located by "aglets.keystore.file" property.
Parameters:
encoded - an encoded byte array of a certificate.
Returns:
certificate which has the same byte array as the parameter.

getCertificate

public static java.security.cert.Certificate getCertificate(java.lang.String username)
Returns certificate of a user. If the user's certificate is not found, returns the certificate of anonymous user whose alias is indicated by "aglets.keystore.anonymousAlias" property. Certificate is read from the keystore located by "aglets.keystore.file" property.
Parameters:
username - an certificate alias in the keystore.
Returns:
certificate of the user

getCertificateAlias

public static java.lang.String getCertificateAlias(java.security.cert.Certificate cert)
Parameters:
cert - java.security.cert.Certificate
Returns:
java.lang.String

getDefaultResourceManagerFactory

public static ResourceManagerFactory getDefaultResourceManagerFactory()

getOwnerCertificate

public java.security.cert.Certificate getOwnerCertificate()
Returns certificate of the user who owns the runtime.
Overrides:
getOwnerCertificate in class AgletRuntime
Returns:
Certificate of the user who owns the runtime

getOwnerName

public java.lang.String getOwnerName()
Returns name of the user who owns the runtime.
Overrides:
getOwnerName in class AgletRuntime
Returns:
name of the user who owns the runtime

getPrivateKey

public static java.security.PrivateKey getPrivateKey(java.security.cert.Certificate cert,
                                                     char[] passwd)
Parameters:
cert - java.security.cert.Certificate
passwd - byte[]
Returns:
java.security.PrivateKey

getProperty

public java.lang.String getProperty(java.lang.String prop,
                                    java.lang.String key)
Returns property of the user who owns the runtime. It needs PropertyPermission for the key of specified property, and FilePermission for the property file.
Overrides:
getProperty in class AgletRuntime
Parameters:
prop - name of properties
key - key of property
Returns:
property of the user who owns the runtime. If the property for the key does not exist, return null.
Throws:
java.lang.SecurityException - if PropertyPermission for the key is not given.

getProperty

public java.lang.String getProperty(java.lang.String prop,
                                    java.lang.String key,
                                    java.lang.String def)
Returns property of the user who owns the runtime. It needs PropertyPermission for the key of specified property, and FilePermission for the property file.
Overrides:
getProperty in class AgletRuntime
Parameters:
prop - name of properties
key - key of property
def - default value of property
Returns:
property of the user who owns the runtime. If the property for the key does not exist, return def.
Throws:
java.lang.SecurityException - if PropertyPermission for the key is not given.

getRegisteredCertificate

public static java.security.cert.Certificate getRegisteredCertificate(java.lang.String username)
Returns certificate of a registered user. If the user's certificate is not found, returns null. Certificate is read from the keystore located by "aglets.keystore.file" property.
Parameters:
username - an certificate alias in the keystore.
Returns:
certificate of the user, null if the user was not found.

getServerAddress

public java.lang.String getServerAddress()
Description copied from class: AgletRuntime
Gets an address of the server
Overrides:
getServerAddress in class AgletRuntime
Following copied from class: com.ibm.aglet.system.AgletRuntime
Returns:
the address of the server

initialize

protected void initialize(java.lang.String[] args)
Description copied from class: AgletRuntime
Initializes an AgletRuntime object with the given array of string. This is typically an argument of main(String args[]) function.
Overrides:
initialize in class AgletRuntime
Following copied from class: com.ibm.aglet.system.AgletRuntime
Parameters:
args - arguments used to initialize
Throws:
java.lang.IllegalAccessException - if the instance has been already initialized.

isVerbose

public static final boolean isVerbose()
Verbose message

killAglet

public void killAglet(AgletProxy proxy)
               throws InvalidAgletException
Kill the specified aglet.
Overrides:
killAglet in class AgletRuntime
Following copied from class: com.ibm.aglet.system.AgletRuntime
Parameters:
proxy - the aglet proxy object to kill.

removeAgletContext

public void removeAgletContext(AgletContext cxt)
Description copied from class: AgletRuntime
Removes the specified aglet context from the runtime environment. It is also removed from export list if it's exported.
Overrides:
removeAgletContext in class AgletRuntime
Following copied from class: com.ibm.aglet.system.AgletRuntime
Parameters:
cxt - the context to remove

setAgletsProperty

public void setAgletsProperty(java.lang.String key,
                              java.lang.String value)
Sets aglets property of the user who owns the runtime. It needs PropertyPermission for the key of aglets property, and FilePermission for the aglets property file.
Overrides:
setAgletsProperty in class AgletRuntime
Parameters:
key - key of aglets property
value - value of specified aglets property
Throws:
java.lang.SecurityException - if permissions for the key are not given.

setDefaultResourceManagerFactory

public static void setDefaultResourceManagerFactory(ResourceManagerFactory factory)

setPersistenceFactory

public static void setPersistenceFactory(PersistenceFactory p_factory)

setProperty

public void setProperty(java.lang.String prop,
                        java.lang.String key,
                        java.lang.String value)
Sets property of the user who owns the runtime. It needs PropertyPermission for the key of property, and FilePermission for the property file.
Overrides:
setProperty in class AgletRuntime
Parameters:
prop - name of properties
key - key of property
value - value of specified property
Throws:
java.lang.SecurityException - if permissions for the key are not given.

shutdown

public void shutdown()
Shutdown
Overrides:
shutdown in class AgletRuntime

shutdown

public void shutdown(Message msg)
Description copied from class: AgletRuntime
Shutdown all contexts in the current runtime with the specific message object. This messag object is delivered to all aglets in all contexts before all aglets are killed.
Overrides:
shutdown in class AgletRuntime

verboseOut

public static final void verboseOut(java.lang.String msg)