private IdentityToken createIdToken(java.lang.Object cred, Class cls, ORB orb)
throws Exception {
IdentityToken idtok = null;
DerOutputStream dos = new DerOutputStream();
DerValue[] derval = null ; // DER encoding buffer
//byte[] cdrval ; // CDR encoding buffer
Any any = orb.create_any();
idtok = new IdentityToken();
if (X500Name.class.isAssignableFrom(cls)) {
_logger.log(Level.FINE,"Constructing an X500 DN Identity Token");
X500Name credname = (X500Name) cred;
credname.encode(dos); // ASN.1 encoding
X501DistinguishedNameHelper.insert(any, dos.toByteArray());
/* IdentityToken with CDR encoded X501 name */
idtok.dn(codec.encode_value(any));
} else if (X509CertificateCredential.class.isAssignableFrom(cls)) {
_logger.log(Level.FINE,"Constructing an X509 Certificate Chain Identity Token");
/* create a DER encoding */
X509CertificateCredential certcred = (X509CertificateCredential) cred;
X509Certificate[] certchain = certcred.getX509CertificateChain();
_logger.log(Level.FINE,"Certchain length = " + certchain.length);
derval = new DerValue[certchain.length];
for (int i = 0; i < certchain.length ; i++)
derval[i] = new DerValue(certchain[i].getEncoded());
dos.putSequence(derval);
X509CertificateChainHelper.insert(any, dos.toByteArray());
/* IdentityToken with CDR encoded certificate chain */
idtok.certificate_chain(codec.encode_value(any));
} else if (AnonCredential.class.isAssignableFrom(cls)) {
_logger.log(Level.FINE,"Constructing an Anonymous Identity Token");