1 /* |
1 /* |
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
77 * This definition reflects the Network Working Group RFC 4120 |
77 * This definition reflects the Network Working Group RFC 4120 |
78 * specification available at |
78 * specification available at |
79 * <a href="http://www.ietf.org/rfc/rfc4120.txt"> |
79 * <a href="http://www.ietf.org/rfc/rfc4120.txt"> |
80 * http://www.ietf.org/rfc/rfc4120.txt</a>. |
80 * http://www.ietf.org/rfc/rfc4120.txt</a>. |
81 */ |
81 */ |
82 |
82 // The instance fields not statically typed as Serializable are ASN.1 |
|
83 // encoded and written by the writeObject method. |
|
84 @SuppressWarnings("serial") |
83 public class KRBError implements java.io.Serializable { |
85 public class KRBError implements java.io.Serializable { |
84 static final long serialVersionUID = 3643809337475284503L; |
86 static final long serialVersionUID = 3643809337475284503L; |
85 |
87 |
86 private int pvno; |
88 private int pvno; |
87 private int msgType; |
89 private int msgType; |
88 private KerberosTime cTime; //optional |
90 private KerberosTime cTime; //optional |
89 private Integer cuSec; //optional |
91 private Integer cuSec; //optional |
90 private KerberosTime sTime; |
92 private KerberosTime sTime; |
91 private Integer suSec; |
93 private Integer suSec; |
92 private int errorCode; |
94 private int errorCode; |
|
95 private Realm crealm; //optional |
93 private PrincipalName cname; //optional |
96 private PrincipalName cname; //optional |
94 private PrincipalName sname; |
97 private PrincipalName sname; |
95 private String eText; //optional |
98 private String eText; //optional |
96 private byte[] eData; //optional |
99 private byte[] eData; //optional |
97 private Checksum eCksum; //optional |
100 private Checksum eCksum; //optional |
347 subDer = der.getData().getDerValue(); |
356 subDer = der.getData().getDerValue(); |
348 if ((subDer.getTag() & (byte)0x1F) == (byte)0x06) { |
357 if ((subDer.getTag() & (byte)0x1F) == (byte)0x06) { |
349 errorCode = subDer.getData().getBigInteger().intValue(); |
358 errorCode = subDer.getData().getBigInteger().intValue(); |
350 } |
359 } |
351 else throw new Asn1Exception(Krb5.ASN1_BAD_ID); |
360 else throw new Asn1Exception(Krb5.ASN1_BAD_ID); |
352 Realm crealm = Realm.parse(der.getData(), (byte)0x07, true); |
361 crealm = Realm.parse(der.getData(), (byte)0x07, true); |
353 cname = PrincipalName.parse(der.getData(), (byte)0x08, true, crealm); |
362 cname = PrincipalName.parse(der.getData(), (byte)0x08, true, crealm); |
354 Realm realm = Realm.parse(der.getData(), (byte)0x09, false); |
363 Realm realm = Realm.parse(der.getData(), (byte)0x09, false); |
355 sname = PrincipalName.parse(der.getData(), (byte)0x0A, false, realm); |
364 sname = PrincipalName.parse(der.getData(), (byte)0x0A, false, realm); |
356 eText = null; |
365 eText = null; |
357 eData = null; |
366 eData = null; |
391 System.out.println("\t sTime is " + sTime.toDate().toString |
400 System.out.println("\t sTime is " + sTime.toDate().toString |
392 () + " " + sTime.toDate().getTime()); |
401 () + " " + sTime.toDate().getTime()); |
393 System.out.println("\t suSec is " + suSec); |
402 System.out.println("\t suSec is " + suSec); |
394 System.out.println("\t error code is " + errorCode); |
403 System.out.println("\t error code is " + errorCode); |
395 System.out.println("\t error Message is " + Krb5.getErrorMessage(errorCode)); |
404 System.out.println("\t error Message is " + Krb5.getErrorMessage(errorCode)); |
|
405 if (crealm != null) { |
|
406 System.out.println("\t crealm is " + crealm.toString()); |
|
407 } |
396 if (cname != null) { |
408 if (cname != null) { |
397 System.out.println("\t cname is " + cname.toString()); |
409 System.out.println("\t cname is " + cname.toString()); |
398 } |
410 } |
399 if (sname != null) { |
411 if (sname != null) { |
400 System.out.println("\t sname is " + sname.toString()); |
412 System.out.println("\t sname is " + sname.toString()); |
440 bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x05), temp); |
452 bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x05), temp); |
441 temp = new DerOutputStream(); |
453 temp = new DerOutputStream(); |
442 temp.putInteger(BigInteger.valueOf(errorCode)); |
454 temp.putInteger(BigInteger.valueOf(errorCode)); |
443 bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x06), temp); |
455 bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x06), temp); |
444 |
456 |
|
457 if (crealm != null) { |
|
458 bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x07), crealm.asn1Encode()); |
|
459 } |
445 if (cname != null) { |
460 if (cname != null) { |
446 bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x07), cname.getRealm().asn1Encode()); |
|
447 bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x08), cname.asn1Encode()); |
461 bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x08), cname.asn1Encode()); |
448 } |
462 } |
449 |
463 |
450 bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x09), sname.getRealm().asn1Encode()); |
464 bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x09), sname.getRealm().asn1Encode()); |
451 bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x0A), sname.asn1Encode()); |
465 bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x0A), sname.asn1Encode()); |
486 isEqual(cTime, other.cTime) && |
500 isEqual(cTime, other.cTime) && |
487 isEqual(cuSec, other.cuSec) && |
501 isEqual(cuSec, other.cuSec) && |
488 isEqual(sTime, other.sTime) && |
502 isEqual(sTime, other.sTime) && |
489 isEqual(suSec, other.suSec) && |
503 isEqual(suSec, other.suSec) && |
490 errorCode == other.errorCode && |
504 errorCode == other.errorCode && |
|
505 isEqual(crealm, other.crealm) && |
491 isEqual(cname, other.cname) && |
506 isEqual(cname, other.cname) && |
492 isEqual(sname, other.sname) && |
507 isEqual(sname, other.sname) && |
493 isEqual(eText, other.eText) && |
508 isEqual(eText, other.eText) && |
494 java.util.Arrays.equals(eData, other.eData) && |
509 java.util.Arrays.equals(eData, other.eData) && |
495 isEqual(eCksum, other.eCksum); |
510 isEqual(eCksum, other.eCksum); |
506 if (cTime != null) result = 37 * result + cTime.hashCode(); |
521 if (cTime != null) result = 37 * result + cTime.hashCode(); |
507 if (cuSec != null) result = 37 * result + cuSec.hashCode(); |
522 if (cuSec != null) result = 37 * result + cuSec.hashCode(); |
508 if (sTime != null) result = 37 * result + sTime.hashCode(); |
523 if (sTime != null) result = 37 * result + sTime.hashCode(); |
509 if (suSec != null) result = 37 * result + suSec.hashCode(); |
524 if (suSec != null) result = 37 * result + suSec.hashCode(); |
510 result = 37 * result + errorCode; |
525 result = 37 * result + errorCode; |
|
526 if (crealm != null) result = 37 * result + crealm.hashCode(); |
511 if (cname != null) result = 37 * result + cname.hashCode(); |
527 if (cname != null) result = 37 * result + cname.hashCode(); |
512 if (sname != null) result = 37 * result + sname.hashCode(); |
528 if (sname != null) result = 37 * result + sname.hashCode(); |
513 if (eText != null) result = 37 * result + eText.hashCode(); |
529 if (eText != null) result = 37 * result + eText.hashCode(); |
514 result = 37 * result + Arrays.hashCode(eData); |
530 result = 37 * result + Arrays.hashCode(eData); |
515 if (eCksum != null) result = 37 * result + eCksum.hashCode(); |
531 if (eCksum != null) result = 37 * result + eCksum.hashCode(); |