Build an authenticator.
@param key the key
@return an Authenticator
434666
public static Authenticator buildAuthenticatorWithSharedSecret(final String key) {
        if (key != null && !key.isEmpty()) {
            return new JwtAuthenticator(hmacShaKeyFor(key.getBytes(UTF_8)));
        }
        return null;
    }
907576
public ContextPair getPair(String key) {
        if (!this.contains(key)) {
            return null;
        }
        return new ContextPair(key, get(key));
    }
240344
public static EncryptionProvider getProvider(final Key key) throws UnsupportedAlgorithmException, UnsupportedKeySizeException {

		String algorithm = key.getAlgorithm();

		SupportedKeyGenAlgorithms keyAlgorithm = getAlgorithm(algorithm);

		switch (keyAlgorithm) {
		case AES:
			return new AESEncryptionProvider(key);
			
		case DES:
			return new DESEdeEncryptionProvider(key);
			
		default:
			throw new UnsupportedAlgorithmException("Algorithm [" + keyAlgorithm + "] is not supported.");
		}

	}
1074195
protected void configureSigningKey(final String signingSecretKey) {
        try {
            if (ResourceUtils.doesResourceExist(signingSecretKey)) {
                configureSigningKeyFromPrivateKeyResource(signingSecretKey);
            }
        } finally {
            if (this.signingKey == null) {
                setSigningKey(new AesKey(signingSecretKey.getBytes(StandardCharsets.UTF_8)));
                LOGGER.trace("Created signing key instance [{}] based on provided secret key", this.signingKey.getClass().getSimpleName());
            }
        }
    }
694570
public static Authenticator buildAuthenticatorWithJwk(final String location) {
        if (location != null && isUrl(location)) {
            return new JwksAuthenticator(location);
        }
        return null;
    }
956699
public byte[] init(byte[] key){
		byte[] iv = new byte[blockSize];
		new SecureRandom().nextBytes(iv);
		init(iv, key);
		return iv;
	}
146399
public static Specification<JpaDistributionSetType> byKey(final String key) {
        return (targetRoot, query, cb) -> cb.equal(targetRoot.<String> get(JpaDistributionSetType_.key), key);
    }
252128
public static void setEncryptionKey(final String key) {

		if (key == null) {

			logger.info("set_encryption_key() was called with null parameter, resetting global secret key");

			// reset hash
			secretKeyHash = null;
			return;
		}

		try {

			secretKeyHash = MessageDigest.getInstance(HASH_ALGO).digest(key.getBytes("UTF-8"));

		} catch (Throwable t) {
			logger.error("Unable to set secret key: {}", t.getMessage());
		}
	}
1079502
private static Mac initHmacSha256(byte[] key) {
        try {
            SecretKeySpec keySpec = new SecretKeySpec(key, MAC_ALGORITHM);
            Mac mac = Mac.getInstance(MAC_ALGORITHM);
            mac.init(keySpec);
            return mac;
        }
        catch (GeneralSecurityException e) {
            throw new IllegalArgumentException(e);
        }
    }
1024904
public static SslContextBuilder forServer(InputStream keyCertChain, InputStream key) {
    return configure(SslContextBuilder.forServer(keyCertChain, key));
  }
1246843
public static KeySet singleKey(Key key) {
    return new KeySet(false, ImmutableList.of(key), ImmutableList.<KeyRange>of());
  }
947656
public boolean authenticate(String appId, String apiKey) throws MnoConfigurationException {
		return appId != null && apiKey != null && appId.equals(api.getId()) && apiKey.equals(api.getKey());
	}
985872
public V get(K key) {
        return get(key.hashCode() / SIZE_ROW, key.hashCode() % SIZE_ROW);
    }
1346432
private KeyHook create(KeyBinding key)
    {
        if (key != null && key instanceof KeyHook)
        {
            return (KeyHook)key; // Don't create a KeyHook to replace this KeyBinding, since that has already been done at some point.
            // (Minecraft keeps a pointer to every KeyBinding that gets created, and they never get destroyed - so we don't want to create
            // any more than necessary.)
        }
        return new KeyHook(key.getKeyDescription(), key.getKeyCode(), key.getKeyCategory());
    }
62946
private OkHttpClient createOkHttpClient(OkHttpAuthenticator authenticator, int logLevel) {

        OkHttpClient.Builder builder = new OkHttpClient.Builder()
                .addInterceptor(loggingInterceptor(logLevel))
                .connectTimeout(CONNECT_TIMEOUT, TimeUnit.SECONDS)
                .writeTimeout(WRITE_TIMEOUT, TimeUnit.SECONDS)
                .readTimeout(READ_TIMEOUT, TimeUnit.SECONDS)
                .authenticator(authenticator);

        return builder.build();
    }
332926
public static MapNameAndKeyPair parseMemcacheKey(String key) {
        key = decodeKey(key, "UTF-8");
        String mapName = DEFAULT_MAP_NAME;
        int index = key.indexOf(':');
        if (index != -1) {
            mapName = MAP_NAME_PREFIX + key.substring(0, index);
            key = key.substring(index + 1);
        }
        return new MapNameAndKeyPair(mapName, key);
    }
387533
public JsonWriter key(CharSequence key) {
        startKey();

        if (key == null) {
            throw new IllegalArgumentException("Expected map key, but got null.");
        }

        writeQuotedAndEscaped(key);
        writer.write(':');
        return this;
    }