Search in sources :

Example 1 with QualityOfProtection

use of org.apache.accumulo.core.rpc.SaslConnectionParams.QualityOfProtection in project accumulo by apache.

the class SaslConnectionParamsTest method testDefaultParamsAsClient.

@Test
public void testDefaultParamsAsClient() 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);
            assertEquals("true", clientConf.get(ClientProperty.INSTANCE_RPC_SASL_ENABLED));
            final SaslConnectionParams saslParams = new SaslConnectionParams(clientConf, 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) Test(org.junit.Test)

Example 2 with QualityOfProtection

use of org.apache.accumulo.core.rpc.SaslConnectionParams.QualityOfProtection in project accumulo by apache.

the class SaslConnectionParamsTest method testDelegationTokenImpl.

@Test
public void testDelegationTokenImpl() throws Exception {
    final DelegationTokenImpl token = new DelegationTokenImpl(new byte[0], new AuthenticationTokenIdentifier("user", 1, 10l, 20l, "instanceid"));
    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());
            assertEquals(SaslMechanism.DIGEST_MD5, saslParams.getMechanism());
            assertNotNull(saslParams.getCallbackHandler());
            assertEquals(SaslClientDigestCallbackHandler.class, saslParams.getCallbackHandler().getClass());
            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) DelegationTokenImpl(org.apache.accumulo.core.client.impl.DelegationTokenImpl) AuthenticationTokenIdentifier(org.apache.accumulo.core.client.impl.AuthenticationTokenIdentifier) Map(java.util.Map) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.Test)

Example 3 with QualityOfProtection

use of org.apache.accumulo.core.rpc.SaslConnectionParams.QualityOfProtection 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

Map (java.util.Map)3 ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)3 QualityOfProtection (org.apache.accumulo.core.rpc.SaslConnectionParams.QualityOfProtection)3 Test (org.junit.Test)3 KerberosToken (org.apache.accumulo.core.client.security.tokens.KerberosToken)2 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)2 AuthenticationTokenIdentifier (org.apache.accumulo.core.client.impl.AuthenticationTokenIdentifier)1 DelegationTokenImpl (org.apache.accumulo.core.client.impl.DelegationTokenImpl)1