code: public static EnumSet<KeyUsage> getKeyUsage(X509Extension ext)
              throws IOException {
          DERBitString bits = (DERBitString) getExtensionObject(ext);
          EnumSet<KeyUsage> keyUsage = EnumSet.noneOf(KeyUsage.class);
          for (KeyUsage bit: KeyUsage.values()) {
              if (bit.isSet(bits)) {
                  keyUsage.add(bit);
              }
          }
          return keyUsage;
      }
docs: Gets a boolean array representing bits of the KeyUsage extension.
  
  @throws IOException if failed to extract the KeyUsage extension value.
  @see java.security.cert.X509Certificate#getKeyUsage