Package org.apache.hadoop.gateway.services.security

Examples of org.apache.hadoop.gateway.services.security.AliasService


    EasyMock.expect( context.getWebArchive() ).andReturn( webArchive ).anyTimes();
    EasyMock.expect( context.getTopology() ).andReturn( topology ).anyTimes();
    EasyMock.replay( context );

    AliasService as = EasyMock.createNiceMock( AliasService.class );
    CryptoService cryptoService = new DefaultCryptoService();
    ((DefaultCryptoService) cryptoService).setAliasService( as );

    GatewayServices gatewayServices = EasyMock.createNiceMock( GatewayServices.class );
    EasyMock.expect( gatewayServices.getService( GatewayServices.CRYPTO_SERVICE ) ).andReturn( cryptoService ).anyTimes();
View Full Code Here


    String clusterName = "test-cluster-name";
    String passwordAlias = "encryptQueryString";

    // Test encryption.  Result is in encryptedAdrress

    AliasService as = EasyMock.createNiceMock( AliasService.class );
    String secret = "asdf";
    EasyMock.expect( as.getPasswordFromAliasForCluster( clusterName, passwordAlias ) ).andReturn( secret.toCharArray() ).anyTimes();
    CryptoService cryptoService = new DefaultCryptoService();
    ((DefaultCryptoService)cryptoService).setAliasService( as );
    GatewayServices gatewayServices = EasyMock.createNiceMock( GatewayServices.class );
    EasyMock.expect( gatewayServices.getService( GatewayServices.CRYPTO_SERVICE ) ).andReturn( cryptoService );

    UrlRewriteEnvironment encEnvironment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
    EasyMock.expect( encEnvironment.getAttribute( GatewayServices.GATEWAY_SERVICES_ATTRIBUTE ) ).andReturn( gatewayServices ).anyTimes();
    EasyMock.expect( encEnvironment.getAttribute( GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE ) ).andReturn( clusterName ).anyTimes();
    UrlRewriteContext encContext = EasyMock.createNiceMock( UrlRewriteContext.class );

    EncryptStepContextParams hostPortParams = new EncryptStepContextParams();
    hostPortParams.addParam( "host", Arrays.asList( "host.yarn.com" ) );
    hostPortParams.addParam( "port", Arrays.asList( "8088" ) );
    EasyMock.expect( encContext.getParameters() ).andReturn( hostPortParams );


    Capture<EncryptStepContextParams> encodedValue = new Capture<EncryptStepContextParams>();
    encContext.addParameters( EasyMock.capture( encodedValue ) );

    EasyMock.replay( gatewayServices, as, encEnvironment, encContext );

    EncryptUriDescriptor descriptor = new EncryptUriDescriptor();
    descriptor.setTemplate( "{host}:{port}" );
    descriptor.setParam( encryptedValueParamName );
    EncryptUriProcessor processor = new EncryptUriProcessor();
    processor.initialize( encEnvironment, descriptor );
    UrlRewriteStepStatus encStatus = processor.process( encContext );

    assertThat( encStatus, is ( UrlRewriteStepStatus.SUCCESS ) );
    assertThat( encodedValue.getValue(), notNullValue() );
    assertThat( encodedValue.getValue().resolve( encryptedValueParamName ).size(), is( 1 ) );
    String encryptedAdrress = encodedValue.getValue().resolve( encryptedValueParamName ).get( 0 );
    assertThat( encryptedAdrress, not( isEmptyOrNullString() ) );
    assertThat( encryptedAdrress, not( "{host}:{port}" ) );
    assertThat( encryptedAdrress, not( "hdp:8088" ) );

    // Test decryption.  Result is in dectryptedAdrress.
    String decParam = "foo";
    gatewayServices = EasyMock.createNiceMock( GatewayServices.class );
    EasyMock.expect( gatewayServices.getService( GatewayServices.CRYPTO_SERVICE ) ).andReturn( cryptoService );
    as = EasyMock.createNiceMock( AliasService.class );
    EasyMock.expect( as.getPasswordFromAliasForCluster( clusterName, passwordAlias ) ).andReturn( secret.toCharArray() ).anyTimes();

    UrlRewriteEnvironment decEnvironment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
    EasyMock.expect( decEnvironment.getAttribute( GatewayServices.GATEWAY_SERVICES_ATTRIBUTE ) ).andReturn( gatewayServices ).anyTimes();
    EasyMock.expect( decEnvironment.getAttribute( GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE ) ).andReturn( clusterName ).anyTimes();
    UrlRewriteContext decContext = EasyMock.createNiceMock( UrlRewriteContext.class );
View Full Code Here

    gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
    clusterUrl = gatewayUrl + "/testdg-cluster";
   
    ///*
    GatewayServices services = GatewayServer.getGatewayServices();
    AliasService aliasService = (AliasService)services.getService(GatewayServices.ALIAS_SERVICE);
    aliasService.addAliasForCluster("testdg-cluster", "ldcSystemPassword", "guest-password");
 
    char[] password1 = aliasService.getPasswordFromAliasForCluster( "testdg-cluster", "ldcSystemPassword");
    //System.err.println("SETUP password 10: " + ((password1 == null) ? "NULL" : new String(password1)));
   
    descriptor = new File( topoDir, "testdg-cluster.xml" );
    stream = new FileOutputStream( descriptor );
    createTopology(ldapPort).toStream( stream );
View Full Code Here

    gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
    clusterUrl = gatewayUrl + "/testdg-cluster";
   
    GatewayServices services = GatewayServer.getGatewayServices();
    AliasService aliasService = (AliasService)services.getService(GatewayServices.ALIAS_SERVICE);
    aliasService.addAliasForCluster("testdg-cluster", "ldcSystemPassword", "guest-password");
 
    char[] password1 = aliasService.getPasswordFromAliasForCluster( "testdg-cluster", "ldcSystemPassword");
    //System.err.println("SETUP password 10: " + ((password1 == null) ? "NULL" : new String(password1)));
   
    descriptor = new File( topoDir, "testdg-cluster.xml" );
    stream = new FileOutputStream( descriptor );
    createTopology(ldapPort).toStream( stream );
View Full Code Here

    gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
    clusterUrl = gatewayUrl + "/test-cluster";
   
    ///*
    GatewayServices services = GatewayServer.getGatewayServices();
    AliasService aliasService = (AliasService)services.getService(GatewayServices.ALIAS_SERVICE);
    aliasService.addAliasForCluster("test-cluster", "ldcSystemPassword", "guest-password");
 
    char[] password1 = aliasService.getPasswordFromAliasForCluster( "test-cluster", "ldcSystemPassword");
    //System.err.println("SETUP password 10: " + ((password1 == null) ? "NULL" : new String(password1)));
   
    descriptor = new File( topoDir, "test-cluster.xml" );
    stream = new FileOutputStream( descriptor );
    createTopology(ldapPort).toStream( stream );
View Full Code Here

TOP

Related Classes of org.apache.hadoop.gateway.services.security.AliasService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.