casbin / jcasbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Java
https://casbin.org
Apache License 2.0
2.4k stars 464 forks source link

Remove guava #279

Closed i1619khz closed 2 years ago

i1619khz commented 2 years ago

I searched for the use of guava in the jcasbin code and found only in used in Util.java. Only used for md5 encryption

https://github.com/casbin/jcasbin/blob/a21b2199bcd1199a66aebf7e86930b2218dfacd1/src/main/java/org/casbin/jcasbin/util/Util.java#L45

https://github.com/casbin/jcasbin/blob/a21b2199bcd1199a66aebf7e86930b2218dfacd1/src/main/java/org/casbin/jcasbin/util/Util.java#L292-L295

Referring to the practice of common codec, only need to jdk

  public static MessageDigest getDigest(String algorithm) {
      try {
          return MessageDigest.getInstance(algorithm);
      } catch (NoSuchAlgorithmException e) {
          throw new IllegalArgumentException(e);
      }
  }

  public static String md5(String data) {
      return new String(getDigest("MD5").digest(data.getBytes(StandardCharsets.UTF_8)));
  }

Reduce unnecessary dependencies

casbin-bot commented 2 years ago

@tangyang9464 @seriouszyx @elfisworking @fangzhengjin

tangyang9464 commented 2 years ago

@i1619khz Could you make a PR?

i1619khz commented 2 years ago

@i1619khz Could you make a PR? with pleasure

i1619khz commented 2 years ago

@tangyang9464 #280