Program: 160528
Project: 160528
Buggy source:
public static Authorization fromToken(SecretKeySpec key,String token) throws AuthenticationException {
  if (token == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  try {
    int hashSizeBytes=16;
    Cipher decodingCipher=Cipher.getInstance("String_Node_Str");
    decodingCipher.init(Cipher.DECRYPT_MODE,key);
    ByteBuffer buffer=ByteBuffer.wrap(decodingCipher.doFinal(Hex.decodeHex(token.toCharArray())));
    MessageDigest messageDigest=MessageDigest.getInstance("String_Node_Str");
    byte[] foundHash=new byte[hashSizeBytes];
    buffer.get(foundHash,0,hashSizeBytes);
    byte[] hashInput=new byte[buffer.capacity() - hashSizeBytes];
    buffer.get(hashInput);
    buffer.position(hashSizeBytes);
    byte[] calculatedHash=messageDigest.digest(hashInput);
    if (Arrays.equals(foundHash,calculatedHash)) {
      byte type=buffer.get();
      Authorization authorization=null;
      long expires=buffer.getLong();
      long uoid=buffer.getLong();
switch (type) {
case ExplicitRightsAuthorization.ID:
        authorization=ExplicitRightsAuthorization.fromBuffer(buffer);
      break;
case UserAuthorization.ID:
    authorization=UserAuthorization.fromBuffer(buffer);
  break;
case SystemAuthorization.ID:
authorization=SystemAuthorization.fromBuffer(buffer);
break;
case AnonymousAuthorization.ID:
authorization=AnonymousAuthorization.fromBuffer(buffer);
break;
case AdminAuthorization.ID:
authorization=AdminAuthorization.fromBuffer(buffer);
break;
default :
throw new AuthenticationException("String_Node_Str" + type);
}
authorization.setUoid(uoid);
authorization.setExpires(expires);
if (authorization.getExpires().getTimeInMillis() < new GregorianCalendar().getTimeInMillis()) {
throw new AuthenticationException("String_Node_Str");
}
return authorization;
}
 else {
throw new AuthenticationException("String_Node_Str");
}
}
 catch (GeneralSecurityException e) {
throw new AuthenticationException("String_Node_Str" + token + "String_Node_Str",e);
}
catch (DecoderException e) {
throw new AuthenticationException(e);
}
}

Fixed version (ground truth):
public static Authorization fromToken(SecretKeySpec key,String token) throws AuthenticationException {
  if (token == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  try {
    int hashSizeBytes=16;
    Cipher decodingCipher=Cipher.getInstance("String_Node_Str");
    decodingCipher.init(Cipher.DECRYPT_MODE,key);
    ByteBuffer buffer=ByteBuffer.wrap(decodingCipher.doFinal(Hex.decodeHex(token.toCharArray())));
    MessageDigest messageDigest=MessageDigest.getInstance("String_Node_Str");
    byte[] foundHash=new byte[hashSizeBytes];
    buffer.get(foundHash,0,hashSizeBytes);
    byte[] hashInput=new byte[buffer.capacity() - hashSizeBytes];
    buffer.get(hashInput);
    buffer.position(hashSizeBytes);
    byte[] calculatedHash=messageDigest.digest(hashInput);
    if (Arrays.equals(foundHash,calculatedHash)) {
      byte type=buffer.get();
      Authorization authorization=null;
      long expires=buffer.getLong();
      long uoid=buffer.getLong();
switch (type) {
case ExplicitRightsAuthorization.ID:
        authorization=ExplicitRightsAuthorization.fromBuffer(buffer);
      break;
case UserAuthorization.ID:
    authorization=UserAuthorization.fromBuffer(buffer);
  break;
case SystemAuthorization.ID:
authorization=SystemAuthorization.fromBuffer(buffer);
break;
case AnonymousAuthorization.ID:
authorization=AnonymousAuthorization.fromBuffer(buffer);
break;
case AdminAuthorization.ID:
authorization=AdminAuthorization.fromBuffer(buffer);
break;
default :
throw new AuthenticationException("String_Node_Str" + type);
}
authorization.setUoid(uoid);
authorization.setExpires(expires);
if (authorization.getExpires().getTimeInMillis() < new GregorianCalendar().getTimeInMillis()) {
throw new AuthenticationException("String_Node_Str");
}
return authorization;
}
 else {
throw new AuthenticationException("String_Node_Str");
}
}
 catch (GeneralSecurityException e) {
throw new AuthenticationException("String_Node_Str",e);
}
catch (DecoderException e) {
throw new AuthenticationException(e);
}
}