When QOP of auth-int or auth-conf is selected This is used to wrap the contents into the proper payload (ie encryption, signature, etc) and should be called just before sending the buffer to Netty. @param content The content to be wrapped. @return The wrapped payload. @throws IllegalStateException i
(final ChannelBuffer content)
| 226 | * the payload |
| 227 | */ |
| 228 | public ChannelBuffer wrap(final ChannelBuffer content) { |
| 229 | if (!use_wrap) { |
| 230 | return content; |
| 231 | } |
| 232 | |
| 233 | try { |
| 234 | final byte[] payload = new byte[content.readableBytes()]; |
| 235 | content.readBytes(payload); |
| 236 | final byte[] wrapped = sasl_client.wrap(payload, 0, payload.length); |
| 237 | final ChannelBuffer ret = ChannelBuffers.wrappedBuffer( |
| 238 | new byte[4 + wrapped.length]); |
| 239 | ret.clear(); |
| 240 | ret.writeInt(wrapped.length); |
| 241 | ret.writeBytes(wrapped); |
| 242 | //if (LOG.isDebugEnabled()) { |
| 243 | // LOG.debug("Wrapped payload: " + Bytes.pretty(ret)); |
| 244 | //} |
| 245 | return ret; |
| 246 | } catch (SaslException e) { |
| 247 | throw new IllegalStateException("Failed to wrap payload", e); |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * Sends the initial handshake and/or SASL challenge to the region server |