Examples of UrlRewriteContext


Examples of org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext

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

    EncryptStepContextParams encryptedParams = new EncryptStepContextParams();
    encryptedParams.addParam( decParam, Arrays.asList( encryptedAdrress ) ); //Value was encrypted by EncryptUriProcessor
    encryptedParams.addParam( "foo1", Arrays.asList( "test" ) );
    EasyMock.expect( decContext.getParameters() ).andReturn( encryptedParams );

    Capture<EncryptStepContextParams> decodedValue = new Capture<EncryptStepContextParams>();
    decContext.addParameters( EasyMock.capture( decodedValue ) );

    EasyMock.replay( gatewayServices, as, decEnvironment, decContext );

    DecryptUriDescriptor decDescriptor = new DecryptUriDescriptor();
    decDescriptor.setParam( decParam );
View Full Code Here

Examples of org.apache.tapestry5.urlrewriter.URLRewriteContext

        }
    }

    public Request processRequest(Request request)
    {
        request = process(request,incomingRules,new URLRewriteContext(){
            public boolean isIncoming()
            {
                return true;
            }
View Full Code Here

Examples of org.apache.tapestry5.urlrewriter.URLRewriteContext

    public Link createComponentEventLink(final ComponentEventRequestParameters parameters, boolean forForm)
    {
        Link standardLink = delegate.createComponentEventLink(parameters, forForm);

        URLRewriteContext rewriteContext = new URLRewriteContext()
        {
            public boolean isIncoming()
            {
                return false;
            }
View Full Code Here

Examples of org.apache.tapestry5.urlrewriter.URLRewriteContext

    public Link createPageRenderLink(final PageRenderRequestParameters parameters)
    {
        Link standardLink = delegate.createPageRenderLink(parameters);

        URLRewriteContext rewriteContext = new URLRewriteContext()
        {
            public boolean isIncoming()
            {
                return false;
            }
View Full Code Here

Examples of org.apache.tapestry5.urlrewriter.URLRewriteContext

    {
        invocation.proceed();
        String name = invocation.getMethodName();

        Link link = (Link) invocation.getResult();
        URLRewriteContext context = setupContext(invocation);
        Link newLink = rewriteIfNeeded(link,context);

        if (newLink != null)
        {
            invocation.overrideResult(newLink);
View Full Code Here

Examples of org.apache.tapestry5.urlrewriter.URLRewriteContext

    }

    private URLRewriteContext setupContext(final Invocation invocation) {

        if (forPageLink) {
            return new URLRewriteContext()
            {

                public boolean isIncoming()
                {
                    return false;
                }

                public PageRenderRequestParameters getPageParameters()
                {
                    return (PageRenderRequestParameters) invocation.getParameter(CONTEXT_PARAMETER_INDEX);
                }

                public ComponentEventRequestParameters getComponentEventParameters()
                {
                    return null;
                }
            };
        }
        return new URLRewriteContext()
        {

            public boolean isIncoming()
            {
                return false;
View Full Code Here

Examples of org.apache.tapestry5.urlrewriter.URLRewriteContext

        }
    }

    public Request processRequest(Request request)
    {
        request = process(request,incomingRules,new URLRewriteContext(){
            public boolean isIncoming()
            {
                return true;
            }
View Full Code Here

Examples of org.apache.tapestry5.urlrewriter.URLRewriteContext

  public void advise(MethodInvocation invocation) {
    invocation.proceed();

    Link link = (Link) invocation.getReturnValue();
    URLRewriteContext context = setupContext(invocation);
    Link newLink = rewriteIfNeeded(link, context);

    if (newLink != null) {
      invocation.setReturnValue(newLink);
    }
View Full Code Here

Examples of org.apache.tapestry5.urlrewriter.URLRewriteContext

  }

  private URLRewriteContext setupContext(final MethodInvocation invocation) {

    if (forPageLink) {
      return new URLRewriteContext() {

        public boolean isIncoming() {
          return false;
        }

        public PageRenderRequestParameters getPageParameters() {
          return (PageRenderRequestParameters) invocation
              .getParameter(CONTEXT_PARAMETER_INDEX);
        }

        public ComponentEventRequestParameters getComponentEventParameters() {
          return null;
        }
      };
    }
    return new URLRewriteContext() {

      public boolean isIncoming() {
        return false;
      }
View Full Code Here

Examples of org.apache.tapestry5.urlrewriter.URLRewriteContext

      }
    }
  }

  public Request processRequest(Request request) {
    request = process(request, incomingRules, new URLRewriteContext() {
      public boolean isIncoming() {
        return true;
      }

      public PageRenderRequestParameters getPageParameters() {
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.