Search in sources :

Example 46 with KerberosToken

use of org.apache.accumulo.core.client.security.tokens.KerberosToken in project accumulo by apache.

the class SaslConnectionParamsTest method testDefaultParams.

@Test
public void testDefaultParams() throws Exception {
    final KerberosToken token = EasyMock.createMock(KerberosToken.class);
    testUser.doAs(new PrivilegedExceptionAction<Void>() {

        @Override
        public Void run() throws Exception {
            final ClientConfiguration clientConf = ClientConfiguration.loadDefault();
            // The primary is the first component of the principal
            final String primary = "accumulo";
            clientConf.withSasl(true, primary);
            final AccumuloConfiguration rpcConf = ClientContext.convertClientConfig(clientConf);
            assertEquals("true", clientConf.get(ClientProperty.INSTANCE_RPC_SASL_ENABLED));
            final SaslConnectionParams saslParams = new SaslConnectionParams(rpcConf, token);
            assertEquals(primary, saslParams.getKerberosServerPrimary());
            final QualityOfProtection defaultQop = QualityOfProtection.get(Property.RPC_SASL_QOP.getDefaultValue());
            assertEquals(defaultQop, saslParams.getQualityOfProtection());
            Map<String, String> properties = saslParams.getSaslProperties();
            assertEquals(1, properties.size());
            assertEquals(defaultQop.getQuality(), properties.get(Sasl.QOP));
            assertEquals(username, saslParams.getPrincipal());
            return null;
        }
    });
}
Also used : QualityOfProtection(org.apache.accumulo.core.rpc.SaslConnectionParams.QualityOfProtection) KerberosToken(org.apache.accumulo.core.client.security.tokens.KerberosToken) Map(java.util.Map) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.Test)

Aggregations

KerberosToken (org.apache.accumulo.core.client.security.tokens.KerberosToken)46 Connector (org.apache.accumulo.core.client.Connector)28 Test (org.junit.Test)28 AuthenticationToken (org.apache.accumulo.core.client.security.tokens.AuthenticationToken)22 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)19 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)19 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)18 IOException (java.io.IOException)15 AccumuloException (org.apache.accumulo.core.client.AccumuloException)15 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)14 ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)12 TableExistsException (org.apache.accumulo.core.client.TableExistsException)12 DelegationTokenConfig (org.apache.accumulo.core.client.admin.DelegationTokenConfig)12 File (java.io.File)10 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)10 ClusterUser (org.apache.accumulo.cluster.ClusterUser)8 DelegationTokenImpl (org.apache.accumulo.core.client.impl.DelegationTokenImpl)8 Instance (org.apache.accumulo.core.client.Instance)6 AuthenticationTokenIdentifier (org.apache.accumulo.core.client.impl.AuthenticationTokenIdentifier)6 ClusterControl (org.apache.accumulo.cluster.ClusterControl)4