Convert a set of key usages to Bouncy Castle key usage.

@param usages the set of authorized usages.
@return a bit mask
327571
public static org.bouncycastle.asn1.x509.KeyUsage getKeyUsage(EnumSet<KeyUsage> usages)
    {
        int bitmask = 0;
        for (KeyUsage usage : usages) {
            bitmask |= usage.value();
        }
        return new org.bouncycastle.asn1.x509.KeyUsage(bitmask);
    }
98851
public void removeMask(long[] mask) {
    int dest = BitsUtil.nextSetBit(mask, 0);
    if(dest < 0) {
      return;
    }
    int src = BitsUtil.nextSetBit(mask, dest);
    while(src < numEntries) {
      if(!BitsUtil.get(mask, src)) {
        entries[dest] = entries[src];
        dest++;
      }
      src++;
    }
    int rm = src - dest;
    while(dest < numEntries) {
      entries[dest] = null;
      dest++;
    }
    numEntries -= rm;
  }
397724
public Set<Key> keySet(int access) {

	Set<Key> set = new LinkedHashSet<Key>();
	Map.Entry<Key, Member> entry;
	Iterator<Entry<Key, Member>> it = _data.entrySet().iterator();
	while (it.hasNext()) {
	    entry = it.next();
	    if (entry.getValue().getAccess() <= access) set.add(entry.getKey());
	}
	return set;
    }
777952
protected static boolean useFieldAccessors ()
    {
        try {
            SecurityManager security = System.getSecurityManager();
            if (security != null) {
                security.checkPermission(new ReflectPermission("suppressAccessChecks"));
            }
            return false;
        } catch (SecurityException se) {
            return true;
        }
    }
982701
public static String getVariantKey(Map<String, String> variants) {

		String variantKey = "";
		if (variants != null) {
			variantKey = getVariantKey(variants, variants.keySet());
		}

		return variantKey;
	}
1205921
public Packer useRSA(final Key rsaKeyForEncrypt, final Key rsaKeyForDecrypt)
			throws NoSuchAlgorithmException, NoSuchPaddingException {
		this.rsaCipher = Cipher.getInstance(ASYM_CIPHER_CHAIN_PADDING);
		this.rsaKeyForEncrypt = rsaKeyForEncrypt;
		this.rsaKeyForDecrypt = rsaKeyForDecrypt;
		return this;
	}
944004
@Exported(name="usage")
    public @Nonnull List<RangeItem> _getUsages() {
        List<RangeItem> r = new ArrayList<>();
        final Jenkins instance = Jenkins.getInstance();
        for (Entry<String, RangeSet> e : usages.entrySet()) {
            final String itemName = e.getKey();
            if (instance.hasPermission(Jenkins.ADMINISTER) || canDiscoverItem(itemName)) {
                r.add(new RangeItem(itemName, e.getValue()));
            }
        }
        return r;
    }
1121815
@SuppressWarnings("deprecation") // The String ctor is deprecated, but fast.
  public Set<String> keys() {
    if (isEmpty()) {
      return Collections.emptySet();
    }
    Set<String> ks = new HashSet<>(size);
    for (int i = 0; i < size; i++) {
      ks.add(new String(name(i), 0 /* hibyte */));
    }
    // immutable in case we decide to change the implementation later.
    return Collections.unmodifiableSet(ks);
  }
523015
static long getTotalUsage(Map<String, MemoryUsage> usages) {
    long sum = 0L;
    for (Map.Entry<String, MemoryUsage> e : usages.entrySet()) {
      sum += e.getValue().getUsed();
    }
    return sum;
  }
313472
public boolean[] getKeyUsageMappedBits() {
        KeyUsageExtension keyUsage = new KeyUsageExtension();
        Boolean val = Boolean.TRUE;

        try {
            if (isSet(getPosition(SSL_CLIENT)) ||
                isSet(getPosition(S_MIME)) ||
                isSet(getPosition(OBJECT_SIGNING)))
                keyUsage.set(KeyUsageExtension.DIGITAL_SIGNATURE, val);

            if (isSet(getPosition(SSL_SERVER)))
                keyUsage.set(KeyUsageExtension.KEY_ENCIPHERMENT, val);

            if (isSet(getPosition(SSL_CA)) ||
                isSet(getPosition(S_MIME_CA)) ||
                isSet(getPosition(OBJECT_SIGNING_CA)))
                keyUsage.set(KeyUsageExtension.KEY_CERTSIGN, val);
        } catch (IOException e) { }
        return keyUsage.getBits();
    }
772123
public void setMasks(String masks) {
        String[] subMasks = masks.split(separate);
        this.masks = new String[subMasks.length];
        for (int i = 0; i < subMasks.length; ++i)
            this.masks[i] = subMasks[i];
    }
1245196
@Nonnull
  public static FieldMask of(String... fieldPaths) {
    List<FieldPath> paths = new ArrayList<>();
    for (String fieldPath : fieldPaths) {
      paths.add(FieldPath.fromDotSeparatedString(fieldPath));
    }
    return new FieldMask(paths);
  }
338063
public static final long fromBitSet(final BitSet bits) {
    long value = 0L;
    for (int i = 0; i < bits.size(); i++) {
      value += bits.get(i) ? (1L << i) : 0L;
    }
    return value;
  }
1189919
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);
    }
1260075
public boolean[] getKeyUsage() {
        try {
            String extAlias = OIDMap.getName(PKIXExtensions.KeyUsage_Id);
            if (extAlias == null)
                return null;

            KeyUsageExtension certExt = (KeyUsageExtension)this.get(extAlias);
            if (certExt == null)
                return null;

            boolean[] ret = certExt.getBits();
            if (ret.length < NUM_STANDARD_KEY_USAGE) {
                boolean[] usageBits = new boolean[NUM_STANDARD_KEY_USAGE];
                System.arraycopy(ret, 0, usageBits, 0, ret.length);
                ret = usageBits;
            }
            return ret;
        } catch (Exception e) {
            return null;
        }
    }
1189503
public RequestLimitRule matchingKeys(Set<String> keys) {
        return new RequestLimitRule(this.durationSeconds, this.limit, this.precision, this.name, keys);
    }
521996
private int getVertMask(int vertsCount) {
        int vertMask = Integer.highestOneBit(vertsCount);
        if (vertMask != vertsCount) {
            vertMask *= 2;
        }
        vertMask--;
        return vertMask;
    }