com.ibm.aglets
Class AgletRuntime

java.lang.Object
  extended bycom.ibm.aglet.system.AgletRuntime
      extended bycom.ibm.aglets.AgletRuntime

public final class AgletRuntime
extends AgletRuntime


Field Summary
private static java.security.KeyStore _keyStore
           
private  java.lang.String _ownerAlias
           
private  java.security.cert.Certificate _ownerCertificate
           
private static java.util.Random _randomGenerator
           
static int AGLET_MAGIC
          Magic number of Aglet
static byte AGLET_STREAM_VERSION
          Version of Aglet Trasfer Format
private static java.security.cert.Certificate ANONYMOUS_USER
           
private static java.util.ResourceBundle bundle
           
private static java.lang.Object[][] contents
           
(package private) static java.util.Hashtable contexts
           
(package private) static AgletRuntime currentRuntime
           
private static java.lang.String DEFAULT_VIEWER
           
private static ResourceManagerFactory defaultResourceManagerFactory
          Gets User Authenticator.
private static boolean initialized
           
private static LogCategory log
           
(package private) static Opt[] option_defs
           
private static PersistenceFactory persistenceFactory
           
private static boolean verbose
           
private static Version VERSION
           
 
Fields inherited from class com.ibm.aglet.system.AgletRuntime
 
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.
(package private) static void check()
           
(package private)  void checkPermission(java.security.Permission p)
           
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.
(package private) static java.security.cert.Certificate getAnonymousUserCertificate()
           
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)
           
(package private) static java.security.cert.Certificate getCurrentCertificate()
          This was getCurrentIdentity
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.
(package private) static Name newName(java.security.cert.Certificate authority)
           
 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.
private  void startup()
           
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

See Also:
Constant Field Values

AGLET_STREAM_VERSION

public static final byte AGLET_STREAM_VERSION
Version of Aglet Trasfer Format

See Also:
Constant Field Values

VERSION

private static Version VERSION

bundle

private static java.util.ResourceBundle bundle

log

private static final LogCategory log

contents

private static java.lang.Object[][] contents

DEFAULT_VIEWER

private static final java.lang.String DEFAULT_VIEWER
See Also:
Constant Field Values

option_defs

static final Opt[] option_defs

currentRuntime

static AgletRuntime currentRuntime

contexts

static java.util.Hashtable contexts

ANONYMOUS_USER

private static java.security.cert.Certificate ANONYMOUS_USER

verbose

private static boolean verbose

initialized

private static boolean initialized

defaultResourceManagerFactory

private static ResourceManagerFactory defaultResourceManagerFactory
Gets User Authenticator. private static UserAuthenticator _authenticator = null;


persistenceFactory

private static PersistenceFactory persistenceFactory

_randomGenerator

private static java.util.Random _randomGenerator

_ownerAlias

private java.lang.String _ownerAlias

_ownerCertificate

private java.security.cert.Certificate _ownerCertificate

_keyStore

private static java.security.KeyStore _keyStore
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.

Specified by:
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)

check

static void check()

checkPermission

void checkPermission(java.security.Permission p)

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.

Specified by:
createAglet in class AgletRuntime
Parameters:
contextName - an address of context.
codebase - an codebase for the aglet.
classname - name of aglets' class.
init - an object passed as an initialize argument.
Throws:
java.io.IOException
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

Specified by:
createAgletContext in class AgletRuntime

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.

Specified by:
getAgletContext in class AgletRuntime
Parameters:
name - the name of the context

getAgletContexts

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

Specified by:
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.

Specified by:
getAgletProxies in class AgletRuntime
Parameters:
contextName - specify context URL with a string.
Throws:
java.io.IOException

getAgletProxy

public AgletProxy getAgletProxy(java.lang.String contextName,
                                AgletID aid)
                         throws java.io.IOException
Obtains a proxy reference the remote aglet.

Specified by:
getAgletProxy in class AgletRuntime
Parameters:
contextName - specify context URL with a string.
aid - target aglet identifyer.
Throws:
java.io.IOException

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.

Specified by:
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.

Specified by:
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.

getAnonymousUserCertificate

static java.security.cert.Certificate getAnonymousUserCertificate()

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

getCurrentCertificate

static java.security.cert.Certificate getCurrentCertificate()
This was getCurrentIdentity


getDefaultResourceManagerFactory

public static ResourceManagerFactory getDefaultResourceManagerFactory()

getOwnerCertificate

public java.security.cert.Certificate getOwnerCertificate()
Returns certificate of the user who owns the runtime.

Specified by:
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.

Specified by:
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.

Specified by:
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.

Specified by:
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

Specified by:
getServerAddress in class 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.

Specified by:
initialize in class AgletRuntime
Parameters:
args - arguments used to initialize

isVerbose

public static final boolean isVerbose()
Verbose message


killAglet

public void killAglet(AgletProxy proxy)
               throws InvalidAgletException
Kill the specified aglet.

Specified by:
killAglet in class AgletRuntime
Parameters:
proxy - the aglet proxy object to kill.
Throws:
InvalidAgletException

newName

static Name newName(java.security.cert.Certificate authority)

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.

Specified by:
removeAgletContext in class 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.

Specified by:
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.

Specified by:
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

Specified by:
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.

Specified by:
shutdown in class AgletRuntime

startup

private void startup()

verboseOut

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