Examples of GatewayServices


Examples of org.apache.hadoop.gateway.services.GatewayServices

  /**
   * @param alias
   * @return
   */
  private CredentialValue getCredentialValueForAlias(String alias) {
    GatewayServices services = (GatewayServices)request.getServletContext().
        getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
    String clusterName = (String) request.getServletContext().getAttribute(GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE);
    AliasService as = services.getService(GatewayServices.ALIAS_SERVICE);
    char[] credential = as.getPasswordFromAliasForCluster(clusterName, alias);
    if (credential != null) {
      return new CredentialValue(alias, new String(credential));
    }
    return null;
View Full Code Here

Examples of org.apache.hadoop.gateway.services.GatewayServices

  }

  @Override
  public void initialize( UrlRewriteEnvironment environment, DecryptUriDescriptor descriptor ) throws Exception {
    clusterName = environment.getAttribute( GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE );
    GatewayServices services = environment.getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
    cryptoService = (CryptoService) services.getService(GatewayServices.CRYPTO_SERVICE);
    param = descriptor.getParam();
  }
View Full Code Here

Examples of org.apache.hadoop.gateway.services.GatewayServices

  }

  @Override
  public void initialize( UrlRewriteEnvironment environment, EncryptUriDescriptor descriptor ) throws Exception {
    clusterName = environment.getAttribute( GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE );
    GatewayServices services = environment.getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
    cryptoService = (CryptoService) services.getService(GatewayServices.CRYPTO_SERVICE);
    template = descriptor.getTemplate();
    param = descriptor.getParam();
  }
View Full Code Here

Examples of org.apache.hadoop.gateway.services.GatewayServices

    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();

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

    EncryptUriDeploymentContributor contributor = new EncryptUriDeploymentContributor();
View Full Code Here

Examples of org.apache.hadoop.gateway.services.GatewayServices

    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();
View Full Code Here

Examples of org.apache.hadoop.gateway.services.GatewayServices

   public static HaProvider getHaProvider(ServletContext context) {
      return (HaProvider) context.getAttribute(PROVIDER_ATTRIBUTE_NAME);
   }

   private void setupHaProvider(HaDescriptor descriptor, ServletContext servletContext) {
      GatewayServices services = (GatewayServices) servletContext.getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
      String clusterName = (String) servletContext.getAttribute(GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE);
      ServiceRegistry serviceRegistry = services.getService(GatewayServices.SERVICE_REGISTRY_SERVICE);
      HaProvider provider = new DefaultHaProvider(descriptor);
      List<String> serviceNames = descriptor.getEnabledServiceNames();
      for (String serviceName : serviceNames) {
         provider.addHaService(serviceName, serviceRegistry.lookupServiceURLs(clusterName, serviceName));
      }
View Full Code Here

Examples of org.apache.hadoop.gateway.services.GatewayServices

  @GET
  @Produces({APPLICATION_JSON, APPLICATION_XML})
  @Path("topologies/{id}")
  public Topology getTopology(@PathParam("id") String id) {
    GatewayServices services = (GatewayServices) request.getServletContext()
        .getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);

    TopologyService ts = services.getService(GatewayServices.TOPOLOGY_SERVICE);

    for (Topology t : ts.getTopologies()) {
      if(t.getName().equals(id)) {
        try {
          t.setUri(new URI(request.getRequestURL().substring(0, request.getRequestURL().indexOf("gateway")) + "gateway/" + t.getName()));
View Full Code Here

Examples of org.apache.hadoop.gateway.services.GatewayServices

  @GET
  @Produces({APPLICATION_JSON, APPLICATION_XML})
  @Path("topologies")
  public SimpleTopologyWrapper getTopologies() {
    GatewayServices services = (GatewayServices) request.getServletContext()
        .getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);


    TopologyService ts = services.getService(GatewayServices.TOPOLOGY_SERVICE);

    ArrayList<SimpleTopology> st = new ArrayList<SimpleTopology>();

    for (Topology t : ts.getTopologies()) {
      st.add(getSimpleTopology(t, request.getRequestURL().toString()));
View Full Code Here

Examples of org.apache.hadoop.gateway.services.GatewayServices

  @PUT
  @Consumes({APPLICATION_JSON, APPLICATION_XML})
  @Path("topologies/{id}")
  public Topology uploadTopology(@PathParam("id") String id, Topology t) {

    GatewayServices gs = (GatewayServices) request.getServletContext()
        .getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);

    t.setName(id);
    TopologyService ts = gs.getService(GatewayServices.TOPOLOGY_SERVICE);

    ts.deployTopology(t);

    return getTopology(id);
  }
View Full Code Here

Examples of org.apache.hadoop.gateway.services.GatewayServices

  @Produces(APPLICATION_JSON)
  @Path("topologies/{id}")
  public Response deleteTopology(@PathParam("id") String id) {
    boolean deleted = false;
    if(!id.equals("admin")) {
      GatewayServices services = (GatewayServices) request.getServletContext()
          .getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);

      TopologyService ts = services.getService(GatewayServices.TOPOLOGY_SERVICE);

      for (Topology t : ts.getTopologies()) {
        if(t.getName().equals(id)) {
          ts.deleteTopology(t);
          deleted = true;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.