Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HBASE-16414 Improve performance for RPC encryption with Apache Common
Crypto (Colin Ma)
- Loading branch information
Ramkrishna
committed
Oct 21, 2016
1 parent
d3decaa
commit 0ae211e
Showing
19 changed files
with
3,666 additions
and
831 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/UnsupportedCryptoException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
package org.apache.hadoop.hbase.ipc; | ||
|
||
import org.apache.hadoop.hbase.classification.InterfaceAudience; | ||
import org.apache.hadoop.hbase.classification.InterfaceStability; | ||
|
||
@InterfaceAudience.Public | ||
@InterfaceStability.Evolving | ||
public class UnsupportedCryptoException extends FatalConnectionException { | ||
public UnsupportedCryptoException() { | ||
super(); | ||
} | ||
|
||
public UnsupportedCryptoException(String msg) { | ||
super(msg); | ||
} | ||
|
||
public UnsupportedCryptoException(String msg, Throwable t) { | ||
super(msg, t); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
hbase-client/src/main/java/org/apache/hadoop/hbase/security/CryptoAESUnwrapHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
package org.apache.hadoop.hbase.security; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import io.netty.buffer.Unpooled; | ||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.channel.SimpleChannelInboundHandler; | ||
import org.apache.hadoop.hbase.classification.InterfaceAudience; | ||
import org.apache.hadoop.hbase.io.crypto.aes.CryptoAES; | ||
|
||
/** | ||
* Unwrap messages with Crypto AES. Should be placed after a | ||
* {@link io.netty.handler.codec.LengthFieldBasedFrameDecoder} | ||
*/ | ||
@InterfaceAudience.Private | ||
public class CryptoAESUnwrapHandler extends SimpleChannelInboundHandler<ByteBuf> { | ||
|
||
private final CryptoAES cryptoAES; | ||
|
||
public CryptoAESUnwrapHandler(CryptoAES cryptoAES) { | ||
this.cryptoAES = cryptoAES; | ||
} | ||
|
||
@Override | ||
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { | ||
byte[] bytes = new byte[msg.readableBytes()]; | ||
msg.readBytes(bytes); | ||
ctx.fireChannelRead(Unpooled.wrappedBuffer(cryptoAES.unwrap(bytes, 0, bytes.length))); | ||
} | ||
} |
Oops, something went wrong.