//Create and encrypt an AuthBundle.
AuthBundle aB = new AuthBundle(user, password);
try {
//Encrypt the auth bundle
(new BlowfishSealer()).seal(aB);
} catch(KeyNotFoundException knfe) {
...
}
服务器端的解密过程:
...use the sealed bundle to logon to a chosen repository.
..
// Unseal the auth bundle if sealed.
if(authBundle.isSealed()) {
// Instantiate an unsealer proxy.
UnsealerProxy uP = new UnsealerProxy();
try {
// Attempt to unseal the bundle.
// The UnsealerProxy will delegate unsealing
// to a new instance of "my.magic.Unsealer"
uP.unseal(authBundle);
} catch(UnsealerNotFoundException unfe) {
throw new LogonException("Unable … unsealer.", unfe);
} catch(KeyNotFoundException knfe) {
throw new LogonException("Unable ….", knfe);
} catch(InvalidKeyClassException ikce) {
throw new LogonException("Invalid decryption...", ikce);
} catch(EncryptionException ee) {
throw new LogonException("An error ….", ee);
}
}