sun.security.krb5.internal.crypto.EType Java Examples
The following examples show how to use
sun.security.krb5.internal.crypto.EType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WeakCrypto.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String conf = "[libdefaults]\n" + (args.length > 0 ? ("allow_weak_crypto = " + args[0]) : ""); Files.write(Paths.get("krb5.conf"), conf.getBytes()); System.setProperty("java.security.krb5.conf", "krb5.conf"); boolean expected = args.length != 0 && args[0].equals("true"); int[] etypes = EType.getBuiltInDefaults(); boolean found = false; for (int i=0, length = etypes.length; i<length; i++) { if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) { found = true; } } if (expected != found) { throw new Exception(); } }
Example #2
Source File: ETypeOrder.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // File does not exist, so that the system-default one won't be used System.setProperty("java.security.krb5.conf", "no_such_file"); int[] etypes = EType.getBuiltInDefaults(); // Reference order, note that 2 is not implemented in Java int correct[] = { 18, 17, 16, 23, 1, 3, 2 }; int match = 0; loopi: for (int i=0; i<etypes.length; i++) { for (; match < correct.length; match++) { if (etypes[i] == correct[match]) { System.out.println("Find " + etypes[i] + " at #" + match); continue loopi; } } throw new Exception("No match or bad order for " + etypes[i]); } }
Example #3
Source File: WeakCrypto.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String conf = "[libdefaults]\n" + (args.length > 0 ? ("allow_weak_crypto = " + args[0]) : ""); Files.write(Paths.get("krb5.conf"), conf.getBytes()); System.setProperty("java.security.krb5.conf", "krb5.conf"); boolean expected = args.length != 0 && args[0].equals("true"); int[] etypes = EType.getBuiltInDefaults(); boolean found = false; for (int i=0, length = etypes.length; i<length; i++) { if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) { found = true; } } if (expected != found) { throw new Exception(); } }
Example #4
Source File: KrbAsRep.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab. * @param ktab the keytab, not null * @param asReq the original AS-REQ sent, used to validate AS-REP * @param cname the user principal name, used to locate keys in ktab */ void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname) throws KrbException, Asn1Exception, IOException { EncryptionKey dkey = null; int encPartKeyType = rep.encPart.getEType(); Integer encPartKvno = rep.encPart.kvno; try { dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } catch (KrbException ke) { if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) { // Fallback to no kvno. In some cases, keytab is generated // not by sysadmin but Java's ktab command dkey = EncryptionKey.findKey(encPartKeyType, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } } if (dkey == null) { throw new KrbException(Krb5.API_INVALID_ARG, "Cannot find key for type/kvno to decrypt AS REP - " + EType.toString(encPartKeyType) + "/" + encPartKvno); } decrypt(dkey, asReq, cname); }
Example #5
Source File: KrbAsRep.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab. * @param ktab the keytab, not null * @param asReq the original AS-REQ sent, used to validate AS-REP * @param cname the user principal name, used to locate keys in ktab */ void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname) throws KrbException, Asn1Exception, IOException { EncryptionKey dkey = null; int encPartKeyType = rep.encPart.getEType(); Integer encPartKvno = rep.encPart.kvno; try { dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } catch (KrbException ke) { if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) { // Fallback to no kvno. In some cases, keytab is generated // not by sysadmin but Java's ktab command dkey = EncryptionKey.findKey(encPartKeyType, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } } if (dkey == null) { throw new KrbException(Krb5.API_INVALID_ARG, "Cannot find key for type/kvno to decrypt AS REP - " + EType.toString(encPartKeyType) + "/" + encPartKvno); } decrypt(dkey, asReq); }
Example #6
Source File: WeakCrypto.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String conf = "[libdefaults]\n" + (args.length > 0 ? ("allow_weak_crypto = " + args[0]) : ""); Files.write(Paths.get("krb5.conf"), conf.getBytes()); System.setProperty("java.security.krb5.conf", "krb5.conf"); boolean expected = args.length != 0 && args[0].equals("true"); int[] etypes = EType.getBuiltInDefaults(); boolean found = false; for (int i=0, length = etypes.length; i<length; i++) { if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) { found = true; } } if (expected != found) { throw new Exception(); } }
Example #7
Source File: WeakCrypto.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String conf = "[libdefaults]\n" + (args.length > 0 ? ("allow_weak_crypto = " + args[0]) : ""); Files.write(Paths.get("krb5.conf"), conf.getBytes()); System.setProperty("java.security.krb5.conf", "krb5.conf"); boolean expected = args.length != 0 && args[0].equals("true"); int[] etypes = EType.getBuiltInDefaults(); boolean found = false; for (int i=0, length = etypes.length; i<length; i++) { if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) { found = true; } } if (expected != found) { throw new Exception(); } }
Example #8
Source File: ETypeOrder.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // File does not exist, so that the system-default one won't be used System.setProperty("java.security.krb5.conf", "no_such_file"); int[] etypes = EType.getBuiltInDefaults(); // Reference order, note that 2 is not implemented in Java int correct[] = { 18, 17, 16, 23, 1, 3, 2 }; int match = 0; loopi: for (int i=0; i<etypes.length; i++) { for (; match < correct.length; match++) { if (etypes[i] == correct[match]) { System.out.println("Find " + etypes[i] + " at #" + match); continue loopi; } } throw new Exception("No match or bad order for " + etypes[i]); } }
Example #9
Source File: ETypeOrder.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // File does not exist, so that the system-default one won't be used System.setProperty("java.security.krb5.conf", "no_such_file"); int[] etypes = EType.getBuiltInDefaults(); // Reference order, note that 2 is not implemented in Java int correct[] = { 18, 17, 16, 23, 1, 3, 2 }; int match = 0; loopi: for (int i=0; i<etypes.length; i++) { for (; match < correct.length; match++) { if (etypes[i] == correct[match]) { System.out.println("Find " + etypes[i] + " at #" + match); continue loopi; } } throw new Exception("No match or bad order for " + etypes[i]); } }
Example #10
Source File: KrbAsRep.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab. * @param ktab the keytab, not null * @param asReq the original AS-REQ sent, used to validate AS-REP * @param cname the user principal name, used to locate keys in ktab */ void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname) throws KrbException, Asn1Exception, IOException { EncryptionKey dkey = null; int encPartKeyType = rep.encPart.getEType(); Integer encPartKvno = rep.encPart.kvno; try { dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } catch (KrbException ke) { if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) { // Fallback to no kvno. In some cases, keytab is generated // not by sysadmin but Java's ktab command dkey = EncryptionKey.findKey(encPartKeyType, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } } if (dkey == null) { throw new KrbException(Krb5.API_INVALID_ARG, "Cannot find key for type/kvno to decrypt AS REP - " + EType.toString(encPartKeyType) + "/" + encPartKvno); } decrypt(dkey, asReq); }
Example #11
Source File: KrbAsReqBuilder.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Build a KrbAsReq object from all info fed above. Normally this method * will be called twice: initial AS-REQ and second with pakey * @param key null (initial AS-REQ) or pakey (with preauth) * @return the KrbAsReq object * @throws KrbException * @throws IOException */ private KrbAsReq build(EncryptionKey key) throws KrbException, IOException { int[] eTypes; if (password != null) { eTypes = EType.getDefaults("default_tkt_enctypes"); } else { EncryptionKey[] ks = Krb5Util.keysFromJavaxKeyTab(ktab, cname); eTypes = EType.getDefaults("default_tkt_enctypes", ks); for (EncryptionKey k: ks) k.destroy(); } return new KrbAsReq(key, options, cname, sname, from, till, rtime, eTypes, addresses); }
Example #12
Source File: YesNo.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { System.setProperty("java.security.krb5.conf", System.getProperty("test.src", ".") +"/yesno.conf"); config = Config.getInstance(); check("a", Boolean.TRUE); check("b", Boolean.FALSE); check("c", Boolean.TRUE); check("d", Boolean.FALSE); check("e", null); check("f", null); if (!Arrays.stream(EType.getBuiltInDefaults()) .anyMatch(n -> n < 4)) { throw new Exception(); } }
Example #13
Source File: KrbAsRep.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab. * @param ktab the keytab, not null * @param asReq the original AS-REQ sent, used to validate AS-REP * @param cname the user principal name, used to locate keys in ktab */ void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname) throws KrbException, Asn1Exception, IOException { EncryptionKey dkey = null; int encPartKeyType = rep.encPart.getEType(); Integer encPartKvno = rep.encPart.kvno; try { dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } catch (KrbException ke) { if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) { // Fallback to no kvno. In some cases, keytab is generated // not by sysadmin but Java's ktab command dkey = EncryptionKey.findKey(encPartKeyType, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } } if (dkey == null) { throw new KrbException(Krb5.API_INVALID_ARG, "Cannot find key for type/kvno to decrypt AS REP - " + EType.toString(encPartKeyType) + "/" + encPartKvno); } decrypt(dkey, asReq, cname); }
Example #14
Source File: KrbAsRep.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab. * @param ktab the keytab, not null * @param asReq the original AS-REQ sent, used to validate AS-REP * @param cname the user principal name, used to locate keys in ktab */ void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname) throws KrbException, Asn1Exception, IOException { EncryptionKey dkey = null; int encPartKeyType = rep.encPart.getEType(); Integer encPartKvno = rep.encPart.kvno; try { dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } catch (KrbException ke) { if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) { // Fallback to no kvno. In some cases, keytab is generated // not by sysadmin but Java's ktab command dkey = EncryptionKey.findKey(encPartKeyType, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } } if (dkey == null) { throw new KrbException(Krb5.API_INVALID_ARG, "Cannot find key for type/kvno to decrypt AS REP - " + EType.toString(encPartKeyType) + "/" + encPartKvno); } decrypt(dkey, asReq, cname); }
Example #15
Source File: KrbAsRep.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab. * @param ktab the keytab, not null * @param asReq the original AS-REQ sent, used to validate AS-REP * @param cname the user principal name, used to locate keys in ktab */ void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname) throws KrbException, Asn1Exception, IOException { EncryptionKey dkey = null; int encPartKeyType = rep.encPart.getEType(); Integer encPartKvno = rep.encPart.kvno; try { dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } catch (KrbException ke) { if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) { // Fallback to no kvno. In some cases, keytab is generated // not by sysadmin but Java's ktab command dkey = EncryptionKey.findKey(encPartKeyType, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } } if (dkey == null) { throw new KrbException(Krb5.API_INVALID_ARG, "Cannot find key for type/kvno to decrypt AS REP - " + EType.toString(encPartKeyType) + "/" + encPartKvno); } decrypt(dkey, asReq); }
Example #16
Source File: KrbAsReqBuilder.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Build a KrbAsReq object from all info fed above. Normally this method * will be called twice: initial AS-REQ and second with pakey * @param key null (initial AS-REQ) or pakey (with preauth) * @return the KrbAsReq object * @throws KrbException * @throws IOException */ private KrbAsReq build(EncryptionKey key) throws KrbException, IOException { int[] eTypes; if (password != null) { eTypes = EType.getDefaults("default_tkt_enctypes"); } else { EncryptionKey[] ks = Krb5Util.keysFromJavaxKeyTab(ktab, cname); eTypes = EType.getDefaults("default_tkt_enctypes", ks); for (EncryptionKey k: ks) k.destroy(); } return new KrbAsReq(key, options, cname, sname, from, till, rtime, eTypes, addresses); }
Example #17
Source File: KrbAsRep.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab. * @param ktab the keytab, not null * @param asReq the original AS-REQ sent, used to validate AS-REP * @param cname the user principal name, used to locate keys in ktab */ void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname) throws KrbException, Asn1Exception, IOException { EncryptionKey dkey = null; int encPartKeyType = rep.encPart.getEType(); Integer encPartKvno = rep.encPart.kvno; try { dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } catch (KrbException ke) { if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) { // Fallback to no kvno. In some cases, keytab is generated // not by sysadmin but Java's ktab command dkey = EncryptionKey.findKey(encPartKeyType, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } } if (dkey == null) { throw new KrbException(Krb5.API_INVALID_ARG, "Cannot find key for type/kvno to decrypt AS REP - " + EType.toString(encPartKeyType) + "/" + encPartKvno); } decrypt(dkey, asReq); }
Example #18
Source File: KrbAsRep.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab. * @param ktab the keytab, not null * @param asReq the original AS-REQ sent, used to validate AS-REP * @param cname the user principal name, used to locate keys in ktab */ void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname) throws KrbException, Asn1Exception, IOException { EncryptionKey dkey = null; int encPartKeyType = rep.encPart.getEType(); Integer encPartKvno = rep.encPart.kvno; try { dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } catch (KrbException ke) { if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) { // Fallback to no kvno. In some cases, keytab is generated // not by sysadmin but Java's ktab command dkey = EncryptionKey.findKey(encPartKeyType, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } } if (dkey == null) { throw new KrbException(Krb5.API_INVALID_ARG, "Cannot find key for type/kvno to decrypt AS REP - " + EType.toString(encPartKeyType) + "/" + encPartKvno); } decrypt(dkey, asReq); }
Example #19
Source File: ETypeOrder.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // File does not exist, so that the system-default one won't be used System.setProperty("java.security.krb5.conf", "no_such_file"); int[] etypes = EType.getBuiltInDefaults(); // Reference order, note that 2 is not implemented in Java int correct[] = { 18, 17, 16, 23, 1, 3, 2 }; int match = 0; loopi: for (int i=0; i<etypes.length; i++) { for (; match < correct.length; match++) { if (etypes[i] == correct[match]) { System.out.println("Find " + etypes[i] + " at #" + match); continue loopi; } } throw new Exception("No match or bad order for " + etypes[i]); } }
Example #20
Source File: KrbAsReqBuilder.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Build a KrbAsReq object from all info fed above. Normally this method * will be called twice: initial AS-REQ and second with pakey * @param key null (initial AS-REQ) or pakey (with preauth) * @return the KrbAsReq object * @throws KrbException * @throws IOException */ private KrbAsReq build(EncryptionKey key) throws KrbException, IOException { int[] eTypes; if (password != null) { eTypes = EType.getDefaults("default_tkt_enctypes"); } else { EncryptionKey[] ks = Krb5Util.keysFromJavaxKeyTab(ktab, cname); eTypes = EType.getDefaults("default_tkt_enctypes", ks); for (EncryptionKey k: ks) k.destroy(); } return new KrbAsReq(key, options, cname, sname, from, till, rtime, eTypes, addresses); }
Example #21
Source File: ETypeOrder.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // File does not exist, so that the system-default one won't be used System.setProperty("java.security.krb5.conf", "no_such_file"); int[] etypes = EType.getBuiltInDefaults(); // Reference order, note that 2 is not implemented in Java int correct[] = { 18, 17, 16, 23, 1, 3, 2 }; int match = 0; loopi: for (int i=0; i<etypes.length; i++) { for (; match < correct.length; match++) { if (etypes[i] == correct[match]) { System.out.println("Find " + etypes[i] + " at #" + match); continue loopi; } } throw new Exception("No match or bad order for " + etypes[i]); } }
Example #22
Source File: ETypeOrder.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // File does not exist, so that the system-default one won't be used System.setProperty("java.security.krb5.conf", "no_such_file"); int[] etypes = EType.getBuiltInDefaults(); // Reference order, note that 2 is not implemented in Java int correct[] = { 18, 17, 16, 23, 1, 3, 2 }; int match = 0; loopi: for (int i=0; i<etypes.length; i++) { for (; match < correct.length; match++) { if (etypes[i] == correct[match]) { System.out.println("Find " + etypes[i] + " at #" + match); continue loopi; } } throw new Exception("No match or bad order for " + etypes[i]); } }
Example #23
Source File: ETypeOrder.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // File does not exist, so that the system-default one won't be used System.setProperty("java.security.krb5.conf", "no_such_file"); int[] etypes = EType.getBuiltInDefaults(); // Reference order, note that 2 is not implemented in Java int correct[] = { 18, 17, 16, 23, 1, 3, 2 }; int match = 0; loopi: for (int i=0; i<etypes.length; i++) { for (; match < correct.length; match++) { if (etypes[i] == correct[match]) { System.out.println("Find " + etypes[i] + " at #" + match); continue loopi; } } throw new Exception("No match or bad order for " + etypes[i]); } }
Example #24
Source File: KrbAsReqBuilder.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Build a KrbAsReq object from all info fed above. Normally this method * will be called twice: initial AS-REQ and second with pakey * @param key null (initial AS-REQ) or pakey (with preauth) * @return the KrbAsReq object * @throws KrbException * @throws IOException */ private KrbAsReq build(EncryptionKey key) throws KrbException, IOException { int[] eTypes; if (password != null) { eTypes = EType.getDefaults("default_tkt_enctypes"); } else { EncryptionKey[] ks = Krb5Util.keysFromJavaxKeyTab(ktab, cname); eTypes = EType.getDefaults("default_tkt_enctypes", ks); for (EncryptionKey k: ks) k.destroy(); } return new KrbAsReq(key, options, cname, sname, from, till, rtime, eTypes, addresses); }
Example #25
Source File: WeakCrypto.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String conf = "[libdefaults]\n" + (args.length > 0 ? ("allow_weak_crypto = " + args[0]) : ""); Files.write(Paths.get("krb5.conf"), conf.getBytes()); System.setProperty("java.security.krb5.conf", "krb5.conf"); boolean expected = args.length != 0 && args[0].equals("true"); int[] etypes = EType.getBuiltInDefaults(); boolean found = false; for (int i=0, length = etypes.length; i<length; i++) { if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) { found = true; } } if (expected != found) { throw new Exception(); } }
Example #26
Source File: KrbAsRep.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab. * @param ktab the keytab, not null * @param asReq the original AS-REQ sent, used to validate AS-REP * @param cname the user principal name, used to locate keys in ktab */ void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname) throws KrbException, Asn1Exception, IOException { EncryptionKey dkey = null; int encPartKeyType = rep.encPart.getEType(); Integer encPartKvno = rep.encPart.kvno; try { dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } catch (KrbException ke) { if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) { // Fallback to no kvno. In some cases, keytab is generated // not by sysadmin but Java's ktab command dkey = EncryptionKey.findKey(encPartKeyType, Krb5Util.keysFromJavaxKeyTab(ktab, cname)); } } if (dkey == null) { throw new KrbException(Krb5.API_INVALID_ARG, "Cannot find key for type/kvno to decrypt AS REP - " + EType.toString(encPartKeyType) + "/" + encPartKvno); } decrypt(dkey, asReq); }
Example #27
Source File: ETypeOrder.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // File does not exist, so that the system-default one won't be used System.setProperty("java.security.krb5.conf", "no_such_file"); int[] etypes = EType.getBuiltInDefaults(); // Reference order, note that 2 is not implemented in Java int correct[] = { 18, 17, 16, 23, 1, 3, 2 }; int match = 0; loopi: for (int i=0; i<etypes.length; i++) { for (; match < correct.length; match++) { if (etypes[i] == correct[match]) { System.out.println("Find " + etypes[i] + " at #" + match); continue loopi; } } throw new Exception("No match or bad order for " + etypes[i]); } }
Example #28
Source File: ETypeOrder.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // File does not exist, so that the system-default one won't be used System.setProperty("java.security.krb5.conf", "no_such_file"); int[] etypes = EType.getBuiltInDefaults(); // Reference order, note that 2 is not implemented in Java int correct[] = { 18, 17, 16, 23, 1, 3, 2 }; int match = 0; loopi: for (int i=0; i<etypes.length; i++) { for (; match < correct.length; match++) { if (etypes[i] == correct[match]) { System.out.println("Find " + etypes[i] + " at #" + match); continue loopi; } } throw new Exception("No match or bad order for " + etypes[i]); } }
Example #29
Source File: W83.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { W83 x = new W83(); // Cannot use OneKDC. kinit command cannot resolve // hostname kdc.rabbit.hole KDC kdc = new KDC(OneKDC.REALM, "127.0.0.1", 0, true); kdc.addPrincipal(OneKDC.USER, OneKDC.PASS); kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM); KDC.saveConfig(OneKDC.KRB5_CONF, kdc); System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF); Config.refresh(); kdc.writeKtab(OneKDC.KTAB); KeyTab ktab = KeyTab.getInstance(OneKDC.KTAB); for (int etype: EType.getBuiltInDefaults()) { if (etype != EncryptedData.ETYPE_ARCFOUR_HMAC) { ktab.deleteEntries(new PrincipalName(OneKDC.USER), etype, -1); } } ktab.save(); if (System.getProperty("6932525") != null) { // For 6932525 and 6951366, make sure the etypes sent in 2nd AS-REQ // is not restricted to that of preauth kdc.setOption(KDC.Option.ONLY_RC4_TGT, true); } if (System.getProperty("6959292") != null) { // For 6959292, make sure that when etype for enc-part in 2nd AS-REQ // is different from that of preauth, client can still decrypt it kdc.setOption(KDC.Option.RC4_FIRST_PREAUTH, true); } x.go(); }
Example #30
Source File: W83.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { W83 x = new W83(); // Cannot use OneKDC. kinit command cannot resolve // hostname kdc.rabbit.hole KDC kdc = new KDC(OneKDC.REALM, "127.0.0.1", 0, true); kdc.addPrincipal(OneKDC.USER, OneKDC.PASS); kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM); KDC.saveConfig(OneKDC.KRB5_CONF, kdc); System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF); Config.refresh(); kdc.writeKtab(OneKDC.KTAB); KeyTab ktab = KeyTab.getInstance(OneKDC.KTAB); for (int etype: EType.getBuiltInDefaults()) { if (etype != EncryptedData.ETYPE_ARCFOUR_HMAC) { ktab.deleteEntries(new PrincipalName(OneKDC.USER), etype, -1); } } ktab.save(); if (System.getProperty("6932525") != null) { // For 6932525 and 6951366, make sure the etypes sent in 2nd AS-REQ // is not restricted to that of preauth kdc.setOption(KDC.Option.ONLY_RC4_TGT, true); } if (System.getProperty("6959292") != null) { // For 6959292, make sure that when etype for enc-part in 2nd AS-REQ // is different from that of preauth, client can still decrypt it kdc.setOption(KDC.Option.RC4_FIRST_PREAUTH, true); } x.go(); }