net.sf.fikin.classmarshaling.util
Class CertificateBasedClassSelector

java.lang.Object
  extended by net.sf.fikin.classmarshaling.util.CertificateBasedClassSelector
All Implemented Interfaces:
ClassSelector

public class CertificateBasedClassSelector
extends java.lang.Object
implements ClassSelector

Class selector based on certificates

It selects all classes except:

This class is useful when you have an environment where each "system" class is signed with some certificate, while all "other" (external) classes are not.
This class will check if the signature of the class has been signed by the given certificate and select only those which have not been signed.

The certificate will be loaded from a given keystore (password-less read access) or it should be given explicitly.

Example:
Create a private-public keys pair and signed with it the application jars.
Pass the same certificate to this selector and then all classes which has not been signed (and not being JDK) will be selected.

      Selector selector = new CertificateBasedClassSelector();
      selector.setCertificate( myBuildCert );
      MarshaledObject mo = new MarshaledObject( myObj, selector );
      // not serialize the "mo" instead of "myObj"
 
created on Aug 2, 2005

Since:
Version:
$Revision: 1.1 $
Author:
fiykov

Constructor Summary
CertificateBasedClassSelector()
           
 
Method Summary
 void init()
           Before calling this methof one has to set one of these two options: setKeystoreUrl(URL) and setCertificateName(String) setCertificate(Certificate) If it has been provided keystore URL and certificate name, this method will read the certificate.
 boolean isClassToBeMarshaled(java.lang.Class cl)
          looks to find if the given class: is system (no code source object) it has been signed with cluster's build certificate In either if these two cases it will return "false".
 void setCertificate(java.security.cert.Certificate cert)
          set the certificate One has to set one of these two options: setKeystoreUrl(URL) and setCertificateName(String) this property
 void setCertificateName(java.lang.String name)
          set the certificate's name One has to set one of these two options: this and setKeystoreUrl(URL) setCertificate(Certificate)
 void setKeystoreUrl(java.net.URL ks)
          set certificate's keystore location One has to set one of these two options: this and setCertificateName(String) setCertificate(Certificate)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CertificateBasedClassSelector

public CertificateBasedClassSelector()
Method Detail

setKeystoreUrl

public void setKeystoreUrl(java.net.URL ks)
set certificate's keystore location

One has to set one of these two options:

Parameters:
ks - url of the keystore

setCertificateName

public void setCertificateName(java.lang.String name)
set the certificate's name

One has to set one of these two options:

Parameters:
name - of the certificate

setCertificate

public void setCertificate(java.security.cert.Certificate cert)
set the certificate

One has to set one of these two options:

Parameters:
cert - is the certificate to be used

init

public void init()
          throws java.security.KeyStoreException,
                 java.io.IOException,
                 java.security.NoSuchAlgorithmException,
                 java.security.cert.CertificateException

Before calling this methof one has to set one of these two options:

If it has been provided keystore URL and certificate name, this method will read the certificate. Keystore access must be password-less.

If certificate itself has been given, this method will do nothing.

Throws:
java.security.KeyStoreException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException

isClassToBeMarshaled

public boolean isClassToBeMarshaled(java.lang.Class cl)
looks to find if the given class: In either if these two cases it will return "false".

In all other cases it will return "true".

Specified by:
isClassToBeMarshaled in interface ClassSelector
Parameters:
cl - is the class to check
Returns:
false if any of the aforementioned cases, otherwise true.


Copyright © 2007 Nikolay Fiykov. All Rights Reserved.