Search in sources :

Example 1 with DigestSaslClientCallbackHandler

use of org.apache.hadoop.hbase.security.provider.DigestSaslClientAuthenticationProvider.DigestSaslClientCallbackHandler in project hbase by apache.

the class TestHBaseSaslRpcClient method testDigestSaslClientCallbackHandlerWithException.

@Test
public void testDigestSaslClientCallbackHandlerWithException() {
    final Token<? extends TokenIdentifier> token = createTokenMock();
    when(token.getIdentifier()).thenReturn(Bytes.toBytes(DEFAULT_USER_NAME));
    when(token.getPassword()).thenReturn(Bytes.toBytes(DEFAULT_USER_PASSWORD));
    final DigestSaslClientCallbackHandler saslClCallbackHandler = new DigestSaslClientCallbackHandler(token);
    try {
        saslClCallbackHandler.handle(new Callback[] { mock(TextOutputCallback.class) });
    } catch (UnsupportedCallbackException expEx) {
    // expected
    } catch (Exception ex) {
        fail("testDigestSaslClientCallbackHandlerWithException error : " + ex.getMessage());
    }
}
Also used : DigestSaslClientCallbackHandler(org.apache.hadoop.hbase.security.provider.DigestSaslClientAuthenticationProvider.DigestSaslClientCallbackHandler) TextOutputCallback(javax.security.auth.callback.TextOutputCallback) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) ExpectedException(org.junit.rules.ExpectedException) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with DigestSaslClientCallbackHandler

use of org.apache.hadoop.hbase.security.provider.DigestSaslClientAuthenticationProvider.DigestSaslClientCallbackHandler in project hbase by apache.

the class TestHBaseSaslRpcClient method testDigestSaslClientCallbackHandler.

@Test
public void testDigestSaslClientCallbackHandler() throws UnsupportedCallbackException {
    final Token<? extends TokenIdentifier> token = createTokenMock();
    when(token.getIdentifier()).thenReturn(Bytes.toBytes(DEFAULT_USER_NAME));
    when(token.getPassword()).thenReturn(Bytes.toBytes(DEFAULT_USER_PASSWORD));
    final NameCallback nameCallback = mock(NameCallback.class);
    final PasswordCallback passwordCallback = mock(PasswordCallback.class);
    final RealmCallback realmCallback = mock(RealmCallback.class);
    // We can provide a realmCallback, but HBase presently does nothing with it.
    Callback[] callbackArray = { nameCallback, passwordCallback, realmCallback };
    final DigestSaslClientCallbackHandler saslClCallbackHandler = new DigestSaslClientCallbackHandler(token);
    saslClCallbackHandler.handle(callbackArray);
    verify(nameCallback).setName(anyString());
    verify(passwordCallback).setPassword(any());
}
Also used : NameCallback(javax.security.auth.callback.NameCallback) TextOutputCallback(javax.security.auth.callback.TextOutputCallback) RealmCallback(javax.security.sasl.RealmCallback) PasswordCallback(javax.security.auth.callback.PasswordCallback) NameCallback(javax.security.auth.callback.NameCallback) Callback(javax.security.auth.callback.Callback) DigestSaslClientCallbackHandler(org.apache.hadoop.hbase.security.provider.DigestSaslClientAuthenticationProvider.DigestSaslClientCallbackHandler) PasswordCallback(javax.security.auth.callback.PasswordCallback) RealmCallback(javax.security.sasl.RealmCallback) Test(org.junit.Test)

Aggregations

TextOutputCallback (javax.security.auth.callback.TextOutputCallback)2 DigestSaslClientCallbackHandler (org.apache.hadoop.hbase.security.provider.DigestSaslClientAuthenticationProvider.DigestSaslClientCallbackHandler)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 Callback (javax.security.auth.callback.Callback)1 NameCallback (javax.security.auth.callback.NameCallback)1 PasswordCallback (javax.security.auth.callback.PasswordCallback)1 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)1 RealmCallback (javax.security.sasl.RealmCallback)1 ExpectedException (org.junit.rules.ExpectedException)1