YYMMDDhhmmss{Z|+hhmm|-hhmm} ... emits only using Zulu time * and with seconds (even if seconds=0) as per RFC 5280. */ - public void putUTCTime(Date d) throws IOException { - putTime(d, DerValue.tag_UtcTime); + public DerOutputStream putUTCTime(Date d) throws IOException { + return putTime(d, DerValue.tag_UtcTime); } /** @@ -489,8 +502,8 @@ extends ByteArrayOutputStream implements DerEncoder { *
YYYYMMDDhhmmss{Z|+hhmm|-hhmm} ... emits only using Zulu time
* and with seconds (even if seconds=0) as per RFC 5280.
*/
- public void putGeneralizedTime(Date d) throws IOException {
- putTime(d, DerValue.tag_GeneralizedTime);
+ public DerOutputStream putGeneralizedTime(Date d) throws IOException {
+ return putTime(d, DerValue.tag_GeneralizedTime);
}
/**
@@ -500,7 +513,7 @@ extends ByteArrayOutputStream implements DerEncoder {
* @param d the date to be marshalled
* @param tag the tag for UTC Time or Generalized Time
*/
- private void putTime(Date d, byte tag) throws IOException {
+ private DerOutputStream putTime(Date d, byte tag) throws IOException {
/*
* Format the date.
@@ -527,6 +540,7 @@ extends ByteArrayOutputStream implements DerEncoder {
write(tag);
putLength(time.length);
write(time);
+ return this;
}
/**
@@ -563,23 +577,6 @@ extends ByteArrayOutputStream implements DerEncoder {
}
}
- /**
- * Put the tag of the attribute in the stream.
- *
- * @param tagClass the tag class type, one of UNIVERSAL, CONTEXT,
- * APPLICATION or PRIVATE
- * @param form if true, the value is constructed, otherwise it is
- * primitive.
- * @param val the tag value
- */
- public void putTag(byte tagClass, boolean form, byte val) {
- byte tag = (byte)(tagClass | val);
- if (form) {
- tag |= (byte)0x20;
- }
- write(tag);
- }
-
/**
* Write the current contents of this DerOutputStream
* to an OutputStream
.
@@ -590,6 +587,16 @@ extends ByteArrayOutputStream implements DerEncoder {
out.write(toByteArray());
}
+ /**
+ * Write a DerEncoder onto the output stream.
+ * @param encoder the DerEncoder
+ * @throws IOException on output error
+ */
+ public DerOutputStream write(DerEncoder encoder) throws IOException {
+ encoder.derEncode(this);
+ return this;
+ }
+
byte[] buf() {
return buf;
}