jdk/test/sun/security/krb5/auto/KDC.java
changeset 4168 1a8d21bb898c
parent 3046 dd50d75d88e6
child 4336 4c792c19266e
equal deleted inserted replaced
4167:76f44f2d5d4d 4168:1a8d21bb898c
   464         try {
   464         try {
   465             // Do not call EncryptionKey.acquireSecretKeys(), otherwise
   465             // Do not call EncryptionKey.acquireSecretKeys(), otherwise
   466             // the krb5.conf config file would be loaded.
   466             // the krb5.conf config file would be loaded.
   467             Method stringToKey = EncryptionKey.class.getDeclaredMethod("stringToKey", char[].class, String.class, byte[].class, Integer.TYPE);
   467             Method stringToKey = EncryptionKey.class.getDeclaredMethod("stringToKey", char[].class, String.class, byte[].class, Integer.TYPE);
   468             stringToKey.setAccessible(true);
   468             stringToKey.setAccessible(true);
   469             return new EncryptionKey((byte[]) stringToKey.invoke(null, getPassword(p), getSalt(p), null, etype), etype, null);
   469             Integer kvno = null;
       
   470             // For service whose password ending with a number, use it as kvno
       
   471             if (p.toString().indexOf('/') >= 0) {
       
   472                 char[] pass = getPassword(p);
       
   473                 if (Character.isDigit(pass[pass.length-1])) {
       
   474                     kvno = pass[pass.length-1] - '0';
       
   475                 }
       
   476             }
       
   477             return new EncryptionKey((byte[]) stringToKey.invoke(
       
   478                     null, getPassword(p), getSalt(p), null, etype),
       
   479                     etype, kvno);
   470         } catch (InvocationTargetException ex) {
   480         } catch (InvocationTargetException ex) {
   471             KrbException ke = (KrbException)ex.getCause();
   481             KrbException ke = (KrbException)ex.getCause();
   472             throw ke;
   482             throw ke;
   473         } catch (Exception e) {
   483         } catch (Exception e) {
   474             throw new RuntimeException(e);  // should not happen
   484             throw new RuntimeException(e);  // should not happen