// 
// Decompiled by Procyon v0.6.0
// 

package com.nimbusds.jose.crypto.opts;

import com.nimbusds.jose.crypto.impl.RSAKeyUtils;
import java.security.PrivateKey;
import java.util.Iterator;
import com.nimbusds.jose.Option;
import java.util.Set;

public class OptionUtils
{
    @Deprecated
    public static <T extends Option> boolean optionIsPresent(final Set<? extends Option> opts, final Class<T> tClass) {
        if (opts == null || opts.isEmpty()) {
            return false;
        }
        for (final Option o : opts) {
            if (o.getClass().isAssignableFrom(tClass)) {
                return true;
            }
        }
        return false;
    }
    
    public static void ensureMinRSAPrivateKeySize(final PrivateKey privateKey, final Set<? extends Option> opts) {
        if (!opts.contains(AllowWeakRSAKey.getInstance())) {
            final int keyBitLength = RSAKeyUtils.keyBitLength(privateKey);
            if (keyBitLength > 0 && keyBitLength < 2048) {
                throw new IllegalArgumentException("The RSA key size must be at least 2048 bits");
            }
        }
    }
}
