171 * Encodes this object to a byte array.
172 * @return a byte array of encoded data.
173 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
174 * @exception IOException if an I/O error occurs while reading encoded data.
175 */
176 public byte[] asn1Encode() throws Asn1Exception, IOException {
177 DerOutputStream out = new DerOutputStream();
178 out.putGeneralizedTime(this.toDate());
179 return out.toByteArray();
180 }
181
182 public long getTime() {
183 return kerberosTime;
184 }
185
186 public Date toDate() {
187 return new Date(kerberosTime);
188 }
189
190 public int getMicroSeconds() {
191 Long temp_long = new Long((kerberosTime % 1000L) * 1000L);
192 return temp_long.intValue() + microSeconds;
193 }
194
195 /**
196 * Returns a new KerberosTime object with the original seconds
197 * and the given microseconds.
198 */
199 public KerberosTime withMicroSeconds(int usec) {
200 return new KerberosTime(
201 kerberosTime - kerberosTime%1000L + usec/1000L,
202 usec%1000);
203 }
204
205 private boolean inClockSkew(int clockSkew) {
206 return java.lang.Math.abs(kerberosTime - System.currentTimeMillis())
207 <= clockSkew * 1000L;
208 }
209
210 public boolean inClockSkew() {
211 return inClockSkew(getDefaultSkew());
233 }
234
235 if (!(obj instanceof KerberosTime)) {
236 return false;
237 }
238
239 return kerberosTime == ((KerberosTime)obj).kerberosTime &&
240 microSeconds == ((KerberosTime)obj).microSeconds;
241 }
242
243 public int hashCode() {
244 int result = 37 * 17 + (int)(kerberosTime ^ (kerberosTime >>> 32));
245 return result * 17 + microSeconds;
246 }
247
248 public boolean isZero() {
249 return kerberosTime == 0 && microSeconds == 0;
250 }
251
252 public int getSeconds() {
253 Long temp_long = new Long(kerberosTime / 1000L);
254 return temp_long.intValue();
255 }
256
257 /**
258 * Parse (unmarshal) a kerberostime from a DER input stream. This form
259 * parsing might be used when expanding a value which is part of
260 * a constructed sequence and uses explicitly tagged type.
261 *
262 * @exception Asn1Exception on error.
263 * @param data the Der input stream value, which contains
264 * one or more marshaled value.
265 * @param explicitTag tag number.
266 * @param optional indicates if this data field is optional
267 * @return an instance of KerberosTime.
268 *
269 */
270 public static KerberosTime parse(
271 DerInputStream data, byte explicitTag, boolean optional)
272 throws Asn1Exception, IOException {
273 if ((optional) && (((byte)data.peekByte() & (byte)0x1F)!= explicitTag))
|
171 * Encodes this object to a byte array.
172 * @return a byte array of encoded data.
173 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
174 * @exception IOException if an I/O error occurs while reading encoded data.
175 */
176 public byte[] asn1Encode() throws Asn1Exception, IOException {
177 DerOutputStream out = new DerOutputStream();
178 out.putGeneralizedTime(this.toDate());
179 return out.toByteArray();
180 }
181
182 public long getTime() {
183 return kerberosTime;
184 }
185
186 public Date toDate() {
187 return new Date(kerberosTime);
188 }
189
190 public int getMicroSeconds() {
191 Long temp_long = (kerberosTime % 1000L) * 1000L;
192 return temp_long.intValue() + microSeconds;
193 }
194
195 /**
196 * Returns a new KerberosTime object with the original seconds
197 * and the given microseconds.
198 */
199 public KerberosTime withMicroSeconds(int usec) {
200 return new KerberosTime(
201 kerberosTime - kerberosTime%1000L + usec/1000L,
202 usec%1000);
203 }
204
205 private boolean inClockSkew(int clockSkew) {
206 return java.lang.Math.abs(kerberosTime - System.currentTimeMillis())
207 <= clockSkew * 1000L;
208 }
209
210 public boolean inClockSkew() {
211 return inClockSkew(getDefaultSkew());
233 }
234
235 if (!(obj instanceof KerberosTime)) {
236 return false;
237 }
238
239 return kerberosTime == ((KerberosTime)obj).kerberosTime &&
240 microSeconds == ((KerberosTime)obj).microSeconds;
241 }
242
243 public int hashCode() {
244 int result = 37 * 17 + (int)(kerberosTime ^ (kerberosTime >>> 32));
245 return result * 17 + microSeconds;
246 }
247
248 public boolean isZero() {
249 return kerberosTime == 0 && microSeconds == 0;
250 }
251
252 public int getSeconds() {
253 Long temp_long = kerberosTime / 1000L;
254 return temp_long.intValue();
255 }
256
257 /**
258 * Parse (unmarshal) a kerberostime from a DER input stream. This form
259 * parsing might be used when expanding a value which is part of
260 * a constructed sequence and uses explicitly tagged type.
261 *
262 * @exception Asn1Exception on error.
263 * @param data the Der input stream value, which contains
264 * one or more marshaled value.
265 * @param explicitTag tag number.
266 * @param optional indicates if this data field is optional
267 * @return an instance of KerberosTime.
268 *
269 */
270 public static KerberosTime parse(
271 DerInputStream data, byte explicitTag, boolean optional)
272 throws Asn1Exception, IOException {
273 if ((optional) && (((byte)data.peekByte() & (byte)0x1F)!= explicitTag))
|