public byte[] asn1Encode() throws Asn1Exception, IOException {
  DerOutputStream bytes=new DerOutputStream();
  DerOutputStream temp=new DerOutputStream();
  temp.putOctetString(userData);
  bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,true,(byte)0x00),temp);
  if (timestamp != null)   bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,true,(byte)0x01),timestamp.asn1Encode());
  if (usec != null) {
    temp=new DerOutputStream();
    temp.putInteger(BigInteger.valueOf(usec.intValue()));
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,true,(byte)0x02),temp);
  }
  if (seqNumber != null) {
    temp=new DerOutputStream();
    temp.putInteger(BigInteger.valueOf(seqNumber.longValue()));
    bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,true,(byte)0x03),temp);
  }
  bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT,true,(byte)0x04),sAddress.asn1Encode());
  if (rAddress != null)   temp=new DerOutputStream();
  temp.write(DerValue.tag_Sequence,bytes);
  return temp.toByteArray();
}

public byte [ ] asn1Encode ( ) throws Asn1Exception , IOException { DerOutputStream bytes = new DerOutputStream ( ) ; DerOutputStream temp = new DerOutputStream ( ) ; temp . putOctetString ( userData ) ; bytes . write ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , ( byte ) 0x00 ) , temp ) ; if ( timestamp != null ) bytes . write ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , ( byte ) 0x01 ) , timestamp . asn1Encode ( ) ) ; if ( usec != null ) { temp = new DerOutputStream ( ) ; temp . putInteger ( BigInteger . valueOf ( usec . intValue ( ) ) ) ; bytes . write ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , ( byte ) 0x02 ) , temp ) ; } if ( seqNumber != null ) { temp = new DerOutputStream ( ) ; temp . putInteger ( BigInteger . valueOf ( seqNumber . longValue ( ) ) ) ; bytes . write ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , ( byte ) 0x03 ) , temp ) ; } bytes . write ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , ( byte ) 0x04 ) , sAddress . asn1Encode ( ) ) ; if ( rAddress != null ) temp = new DerOutputStream ( ) ; temp . write ( DerValue . tag_Sequence , bytes ) ; return temp . toByteArray ( ) ; }
encodes an krbsafebody object .
