From dev-return-1811-archive-asf-public=cust-asf.ponee.io@orc.apache.org Wed Feb 7 18:31:29 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 17C4118067C for ; Wed, 7 Feb 2018 18:31:29 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 0651D160C5B; Wed, 7 Feb 2018 17:31:29 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4002B160C60 for ; Wed, 7 Feb 2018 18:31:28 +0100 (CET) Received: (qmail 51468 invoked by uid 500); 7 Feb 2018 17:31:27 -0000 Mailing-List: contact dev-help@orc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@orc.apache.org Delivered-To: mailing list dev@orc.apache.org Received: (qmail 50981 invoked by uid 99); 7 Feb 2018 17:31:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Feb 2018 17:31:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 677E6DFC25; Wed, 7 Feb 2018 17:31:26 +0000 (UTC) From: omalley To: dev@orc.apache.org Reply-To: dev@orc.apache.org References: In-Reply-To: Subject: [GitHub] orc pull request #213: ORC-278 - Create in memory KeyProvider class Content-Type: text/plain Message-Id: <20180207173126.677E6DFC25@git1-us-west.apache.org> Date: Wed, 7 Feb 2018 17:31:26 +0000 (UTC) Github user omalley commented on a diff in the pull request: https://github.com/apache/orc/pull/213#discussion_r166687959 --- Diff: java/core/src/java/org/apache/orc/InMemoryKeystore.java --- @@ -0,0 +1,403 @@ +package org.apache.orc; + +import org.apache.commons.lang.StringUtils; +import org.apache.orc.impl.HadoopShims; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.io.IOException; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This is an in-memory implementation of {@link HadoopShims.KeyProvider}. + * The primary use of this class is to ease testing. + */ +public class InMemoryKeystore implements HadoopShims.KeyProvider { + + /** + * Support AES 256 ? + */ + public static final boolean SUPPORTS_AES_256; + + static { + try { + SUPPORTS_AES_256 = Cipher.getMaxAllowedKeyLength("AES") > 128; + } catch (final NoSuchAlgorithmException e) { + throw new IllegalArgumentException("Unknown algorithm", e); + } + } + + /** + * A map that stores the 'keyName@version' + * and 'metadata + material' mapping. + */ + private final Map keys; + + /** + * A map that store the keyName (without version) + * and metadata associated with it. + */ + private final Map meta = new HashMap<>(); + + private final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock(true); --- End diff -- I probably wouldn't have bothered with the read-write lock, but it is fine. ---