Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## spki
Class BaseObj

    java.lang.Object
      |
      +--spki.BaseObj

Direct Known Subclasses:
  AuthorizationRequest, CertBody, Certificate, Date, Empowerment, Escrow, Hash, Issuer, Name, PrivateKey, PublicKey, RegistrationRequest, Sequence, SequenceDef, SequenceRef, Signature, Subject, Tag, URIs, Validity, ValidOffline, ValidOnline

public abstract class BaseObj
extends Object
implements SPKIObject

Top-level spki abstract class.

all classes in spki package extend from this abstract class.

Version:
  $Id: BaseObj.java,v 1.19 2002/06/24 18:03:20 tep Exp $
Author:
  Tep Narula <tep@win.trlabs.ca>, adapted from SPKI.SPKIBase by Per Harald Myrvang <perm@pasta.cs.uit.no>

Field Summary
`private static String` | `__ME` This class's full name.
`private boolean` | `cache_sexp` Is S-Expression caching enabled? `true` by default.
`private SExpression` | `cached_sexp` Cached S-Expression of this object.
`static String` | `DEFAULT_HASH_ALG` Default hash algorithm (sha1).
`private boolean` | `locked` is this object immutable? `false` by default.
`static String` | `SEXP_NAME` This class S-Expression type name, used by toSExpression() and other methods.

Constructor Summary
`protected` | `BaseObj()` Default constructor.
`protected` | `BaseObj(SExpression sexp)` Create an immutable SPKI object from an S-Expression.

Method Summary
`void` | `disableSExpressionCaching()` Disable caching of SExpression.
`void` | `enableSExpressionCaching()` Enable caching of SExpression given by the constructor or built by a called to the toSExpression() method.
`static String` | `extractHashAlgId(String id)` Extracts the hash-alg-id from a SPKI sig-alg-id.
`protected SExpression` | `getCachedSExpression()` Get this object's cached SExpression list.
`boolean` | `isLocked()` See if this object is locked, i.e immutable.
`static boolean` | `isSListOfType(SExpression sexp, String type, boolean doException)` Checks that an SExpression is both a list and of the given type.
`void` | `lock()` Make this object immutable.
`static String` | `providerToSPKI(String id)` Converts a [I]JCA provider string to a SPKI sig-alg-id.
`protected void` | `setCachedSExpression(SExpression sexp)` Cache this object's SExpression list if caching is enabled and a) this object is not immutable or b) the cache is still empty.
`static String` | `spkiToProvider(String id)` Converts a SPKI sig-alg-id to the [I]JCL provider string.
`abstract SExpression` | `toSExpression()` Build an SExpression representing this object.
`String` | `toString()` Return this object as a string, or `null`.

Methods inherited from class java.lang.Object
`, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait`

Field Detail

### __ME

    private static final String __ME

  This class's full name.

### SEXP_NAME

    public static final String SEXP_NAME

  This class S-Expression type name, used by toSExpression() and other methods. Must be overridden by all subclasses.
  See Also:
    `toSExpression()`

### DEFAULT_HASH_ALG

    public static final String DEFAULT_HASH_ALG

  Default hash algorithm (sha1).

### cache_sexp

    private boolean cache_sexp

  Is S-Expression caching enabled? `true` by default.
  See Also:
    `enableSExpressionCaching()`, `disableSExpressionCaching()`

### cached_sexp

    private SExpression cached_sexp

  Cached S-Expression of this object.
  See Also:
    `setCachedSExpression(SExpression)`, `getCachedSExpression()`

### locked

    private boolean locked

  is this object immutable? `false` by default.
  See Also:
    `lock()`, `isLocked()`

Constructor Detail

### BaseObj

    protected BaseObj()

  Default constructor.

### BaseObj

    protected BaseObj(SExpression sexp)
               throws ParseException,
                      SPKIException

  Create an immutable SPKI object from an S-Expression. Must be overridden by all subclasses.
  Parameters:
    `sexp` - SExpression object containing existing SPKI object.
  Throws:
    ParseException - if some error occured during parsing.
    SPKIException - if some error occured during creation.

Method Detail

### toString

    public String toString()

  Return this object as a string, or `null`. The default action of this method is to call `return this.toSExpression().toString()`.
  Overrides:
    toString in class Object
  Returns:
    SExpression list containing this object in Advanced form, or `null` if something went wrong.
  See Also:
    `toSExpression()`

### lock

    public final void lock()

  Description copied from interface: SPKIObject
  Make this object immutable. This is supposed to be non-reversible, so don't implement something stupid like unLock() ok?. Multiple locks are allowed, though.
  Specified by:
    lock in interface SPKIObject
  Tags copied from interface: SPKIObject
  See Also:
    `SPKIObject.isLocked()`

### isLocked

    public final boolean isLocked()

  Description copied from interface: SPKIObject
  See if this object is locked, i.e immutable.
  Specified by:
    isLocked in interface SPKIObject
  Tags copied from interface: SPKIObject
  Returns:
    `true` if this object is locked, or `false` otherwise.
  See Also:
    `SPKIObject.lock()`

### toSExpression

    public abstract SExpression toSExpression()
                                       throws SPKIException

  Description copied from interface: SPKIObject
  Build an SExpression representing this object.
  Specified by:
    toSExpression in interface SPKIObject
  Tags copied from interface: SPKIObject
  Returns:
    SExpression object representing this object, or `null`.
  Throws:
    SPKIException - if something went wrong during conversion.

### isSListOfType

    public static final boolean isSListOfType(SExpression sexp,
                                              String type,
                                              boolean doException)
                                       throws SPKIException

  Checks that an SExpression is both a list and of the given type. Where by "type" we mean a match of the element at index 0.
  Parameters:
    `sexp` - SExpression to check
    `type` - String containing the type to check for
    `doException` - `true` if this method is allowed to throw exceptions when matching fails, `false` if the caller wants to handle it herself (in that case, check the return value).
  Returns:
    `true` if all is ok, false if not.
  Throws:
    ParseException - if both doException was set to `true` and the match failed.

### extractHashAlgId

    public static final String extractHashAlgId(String id)

  Extracts the hash-alg-id from a SPKI sig-alg-id.

### spkiToProvider

    public static final String spkiToProvider(String id)

  Converts a SPKI sig-alg-id to the [I]JCL provider string.

### providerToSPKI

    public static final String providerToSPKI(String id)

  Converts a [I]JCA provider string to a SPKI sig-alg-id.

### enableSExpressionCaching

    public final void enableSExpressionCaching()

  Enable caching of SExpression given by the constructor or built by a called to the toSExpression() method. This trades off memory consumption for faster processing.
  See Also:
    `disableSExpressionCaching()`, `BaseObj(SExpression)`, `toSExpression()`, `setCachedSExpression(SExpression)`, `getCachedSExpression()`

### disableSExpressionCaching

    public final void disableSExpressionCaching()

  Disable caching of SExpression. This trades off processing time for lower memory consumption.
  See Also:
    `enableSExpressionCaching()`, `setCachedSExpression(SExpression)`, `getCachedSExpression()`

### setCachedSExpression

    protected final void setCachedSExpression(SExpression sexp)

  Cache this object's SExpression list if caching is enabled and a) this object is not immutable or b) the cache is still empty. It clones the passed SExpression and store the copy to prevent external tampering.
  Parameters:
    `sexp` - the SExpression to be cached.
  See Also:
    `enableSExpressionCaching()`, `disableSExpressionCaching()`, `getCachedSExpression()`

### getCachedSExpression

    protected final SExpression getCachedSExpression()

  Get this object's cached SExpression list. It returns a copy of the cached SExpression list (stored by an earlier call to setCachedSExpression()) to prevent external tampering, or `null` if the cache is empty.
  Returns:
    SExpression list containing this object, or `null`.
  See Also:
    `enableSExpressionCaching()`, `disableSExpressionCaching()`, `setCachedSExpression(SExpression)`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD