code: public static EnumSet<KeyUsage> getSetOfKeyUsage(org.bouncycastle.asn1.x509.KeyUsage keyUsage)
      {
          if (keyUsage == null) {
              return null;
          }
  
          Collection<KeyUsage> usages = new ArrayList<KeyUsage>();
  
          for (KeyUsage usage : KeyUsage.values()) {
              if ((((DERBitString) keyUsage.toASN1Primitive()).intValue() & usage.value()) > 0) {
                  usages.add(usage);
              }
          }
          return EnumSet.copyOf(usages);
      }
docs: Convert usages from Bouncy Castle.
  
  @param keyUsage the bouncy castle key usage to convert.
  @return the set of authorized usages.