Key unseal(SealedObject so) throws NoSuchAlgorithmException, UnrecoverableKeyException {
  try {
    PBEKeySpec pbeKeySpec=new PBEKeySpec(this.password);
    SecretKey skey=new PBEKey(pbeKeySpec,"PBEWithMD5AndTripleDES");
    pbeKeySpec.clearPassword();
    SealedObjectForKeyProtector soForKeyProtector=null;
    if (!(so instanceof SealedObjectForKeyProtector)) {
      soForKeyProtector=new SealedObjectForKeyProtector(so);
    }
 else {
      soForKeyProtector=(SealedObjectForKeyProtector)so;
    }
    AlgorithmParameters params=soForKeyProtector.getParameters();
    if (params == null) {
      throw new UnrecoverableKeyException("Cannot get " + "algorithm parameters");
    }
    PBEWithMD5AndTripleDESCipher cipherSpi;
    cipherSpi=new PBEWithMD5AndTripleDESCipher();
    Cipher cipher=new CipherForKeyProtector(cipherSpi,SunJCE.getInstance(),"PBEWithMD5AndTripleDES");
    cipher.init(Cipher.DECRYPT_MODE,skey,params);
    return (Key)soForKeyProtector.getObject(cipher);
  }
 catch (  NoSuchAlgorithmException ex) {
    throw ex;
  }
catch (  IOException ioe) {
    throw new UnrecoverableKeyException(ioe.getMessage());
  }
catch (  ClassNotFoundException cnfe) {
    throw new UnrecoverableKeyException(cnfe.getMessage());
  }
catch (  GeneralSecurityException gse) {
    throw new UnrecoverableKeyException(gse.getMessage());
  }
}

Key unseal ( SealedObject so ) throws NoSuchAlgorithmException , UnrecoverableKeyException { try { PBEKeySpec pbeKeySpec = new PBEKeySpec ( this . password ) ; SecretKey skey = new PBEKey ( pbeKeySpec , "PBEWithMD5AndTripleDES" ) ; pbeKeySpec . clearPassword ( ) ; SealedObjectForKeyProtector soForKeyProtector = null ; if ( ! ( so instanceof SealedObjectForKeyProtector ) ) { soForKeyProtector = new SealedObjectForKeyProtector ( so ) ; } else { soForKeyProtector = ( SealedObjectForKeyProtector ) so ; } AlgorithmParameters params = soForKeyProtector . getParameters ( ) ; if ( params == null ) { throw new UnrecoverableKeyException ( "Cannot get " + "algorithm parameters" ) ; } PBEWithMD5AndTripleDESCipher cipherSpi ; cipherSpi = new PBEWithMD5AndTripleDESCipher ( ) ; Cipher cipher = new CipherForKeyProtector ( cipherSpi , SunJCE . getInstance ( ) , "PBEWithMD5AndTripleDES" ) ; cipher . init ( Cipher . DECRYPT_MODE , skey , params ) ; return ( Key ) soForKeyProtector . getObject ( cipher ) ; } catch ( NoSuchAlgorithmException ex ) { throw ex ; } catch ( IOException ioe ) { throw new UnrecoverableKeyException ( ioe . getMessage ( ) ) ; } catch ( ClassNotFoundException cnfe ) { throw new UnrecoverableKeyException ( cnfe . getMessage ( ) ) ; } catch ( GeneralSecurityException gse ) { throw new UnrecoverableKeyException ( gse . getMessage ( ) ) ; } }
unseals the sealed key .
