You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Inge Solvoll <in...@gmail.com> on 2008/11/14 14:18:49 UTC

[T5] Pick up https/http from request

Hi!

My web application is large and consists of Struts, T4 and T5 pages. In
Struts and T4, I use the current http request to figure out whether to use
https or not. Users can choose if they want to log in using https or not.
The chosen protocol is used on all pages after login.

In T5, this is either a global static setting, or a static setting per page.
Is there a service or something I can override to implement my own "protocol
builder"? Something like this:

public class HttpProtocolBuilder {
  public HttpProtocolBuilder (final HttpServletRequest request) {
    this.request = request
  }

  public String getProtocol() {
    if (request.isSecure()) {
      return "https";
    }
    else {
     return "http";
     }
}

Regards

Inge

Re: [T5] Pick up https/http from request

Posted by Inge Solvoll <in...@gmail.com>.
Got rid of the recursion error on startup by doing

@InjectService("Request") Request request

instead of

final Request request

Now I'm back to the redirect loop problem. I have confirmed that my
getBaseURL method is called in a loop, and the default getBaseURL method is
never called.

Why the loop???

Inge

On Wed, Nov 26, 2008 at 11:37 AM, Inge Solvoll <in...@gmail.com>wrote:

> Thanks!
>
> But this still gives me the same loop error, because I have to inject
> Request (where you inject SiteServices) into the builder method to access
> the secure state of the request:
>
> Caused by: org.apache.tapestry5.ioc.internal.OperationException:
> Construction of service 'Alias' has failed due to recursion: the service
> depends on itself in some way. Please check
> org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, String,
> AliasManager, Collection) (at TapestryModule.java:214) for references to
> another service that is itself dependent on service 'Alias'.
>
> Inge
>
>
> On Wed, Nov 26, 2008 at 11:28 AM, Michael Gerzabek <
> michael.gerzabek@gmx.net> wrote:
>
>> Inge,
>>
>> I did it successfully for a similar purpose:
>>
>>   @SuppressWarnings("unchecked")
>>   public static void contributeAlias(
>>       @InjectService( "SiteBaseURLSource" )
>>       BaseURLSource baseUrlSource,
>>       Configuration<AliasContribution> configuration ) {
>>
>>       configuration.add( AliasContribution.create(
>>           BaseURLSource.class,
>>           baseUrlSource ) );
>>
>>   }
>>
>> Don't use the binder but create your own build method:
>>
>>   @Marker( SiteServices.class )
>>   public static BaseURLSource buildSiteBaseURLSource(
>>       @SiteServices
>>       SiteService site ) {
>>
>>       return new SiteBaseURLSource( site );
>>   }
>>
>> You can ommit the Marker annotation.
>>
>> /Michael
>>
>> Solvoll schrieb:
>>
>>  Hi!
>>>
>>> I'm really struggling here as I think I'm approaching a solution. What
>>> I'm
>>> trying to do is to override/decorate/alias/replace the BaseURLSource with
>>> my
>>> own implementation, like this:
>>>
>>> public class MyBaseURLSource implements BaseURLSource {
>>>
>>>  private final Request request;
>>>
>>>  public MyBaseURLSource(Request request) {
>>>    this.request = request;
>>>  }
>>>
>>>  public String getBaseURL(boolean secure) {
>>>    boolean secureRequest = request.isSecure();
>>>    String baseURL = String.format("%s://%s", secureRequest ? "https" :
>>> "http", request.getServerName());
>>>    return baseURL;
>>>  }
>>>
>>> }
>>>
>>>
>>> Essentially, I've copied the default implementation and replaced the
>>> usage
>>> of the secure parameter with the secure value of the request. My problem
>>> is
>>> that I'm not capable of putting this code to actual work in the
>>> framework.
>>>
>>> I've tried:
>>> - aliasing, but that didn't work because of circular dependency (I have
>>> to
>>> inject the Request)
>>> - binder.bind(BaseURLSource.class, MyBaseURLSource.class), combinded with
>>> a
>>> builder for MyBaseURLSource. Causes redirect loop.
>>> - Decorating. Not managed to find out how I do this yet, have tried a few
>>> things.
>>>
>>> I'm guessing this is rather simple, it's just a bit complicated when
>>> you're
>>> not experienced in IoC... Anyone who wants to point me in the right
>>> direction?
>>>
>>> Regards
>>> Inge
>>>
>>>
>>>
>>> On Wed, Nov 19, 2008 at 10:22 AM, Inge Solvoll <inge.tapestry@gmail.com
>>> >wrote:
>>>
>>>
>>>
>>>> I voted for this issue now.
>>>>
>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>
>>>> This is really a big issue for our usage of T5, T5 is now forcing us to
>>>> redirect users away from http access, because we no longer can support
>>>> both
>>>> modes as long as T5 is fixed on either http or https.
>>>>
>>>> Anyone who's got a working version of a BaseURLSource contribution, that
>>>> actually can output a URL using the protocol from the initial request?
>>>>
>>>> Regards
>>>> Inge
>>>>
>>>>
>>>> On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <inge.tapestry@gmail.com
>>>> >wrote:
>>>>
>>>>
>>>>
>>>>> I know, this isn't really a problem for regular pages, they load using
>>>>> the
>>>>> requested protocol, when not marked as secure. But when I create
>>>>> eventlinks
>>>>> that updates zones, these don't work when they are generated with http
>>>>> and
>>>>> the rest of the page is generated in https...
>>>>>
>>>>> What I would like to do is to try some more on the BaseURLSource
>>>>> approach.
>>>>> Anyone who's got any idea why this has no effect here? I copied and
>>>>> pasted
>>>>> the code from the T5 docs and put in my Appmodule, and the contribute
>>>>> method
>>>>> is called on server startup. I replaced the "localhost" url with an
>>>>> obviously bad url, for testing, but nothing happens, all pages just
>>>>> load as
>>>>> always, including eventlinks and actionlinks.
>>>>>
>>>>> Inge
>>>>>
>>>>>
>>>>> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <carl.crowder@taptu.com
>>>>> >wrote:
>>>>>
>>>>>
>>>>>
>>>>>> I don't know if you're aware, but if you create a href something like
>>>>>>
>>>>>> href="//something.com/page"
>>>>>>
>>>>>> then the current protocol is maintained. So if you were viewing the
>>>>>> page
>>>>>> at https://something.com the HREF would resolve to
>>>>>> https://something.com/page and similarly with http. Unfortunately it
>>>>>> requires using absolute URLs all the time.
>>>>>>
>>>>>> I'm not sure if that helps, but perhaps it could be used in fixing
>>>>>> that
>>>>>> issue.
>>>>>>
>>>>>> Carl
>>>>>>
>>>>>> Inge Solvoll wrote:
>>>>>>
>>>>>>
>>>>>>> Yes, I might. This is a major blow for us, our customers choose
>>>>>>> freely
>>>>>>> whether they want to use http or https, so the T5 way of doing things
>>>>>>>
>>>>>>>
>>>>>> just
>>>>>>
>>>>>>
>>>>>>> doesn't work for us...
>>>>>>>
>>>>>>> On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
>>>>>>> jonathan.theitguy@gmail.com> wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> You might want to vote for this:
>>>>>>>>
>>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> -----Original Message-----
>>>>>>>>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
>>>>>>>>> Sent: Friday, November 14, 2008 15:10
>>>>>>>>> To: Tapestry users
>>>>>>>>> Subject: Re: [T5] Pick up https/http from request
>>>>>>>>>
>>>>>>>>> Thanks!
>>>>>>>>>
>>>>>>>>> I tried copying your code into my AppModule with some small
>>>>>>>>>
>>>>>>>>>
>>>>>>>> modifications.
>>>>>>>>
>>>>>>>>
>>>>>>>>> But the code only runs on server startup, not when I access a
>>>>>>>>>
>>>>>>>>>
>>>>>>>> tapestry 5
>>>>>>
>>>>>>
>>>>>>>  page. I tried to add deliberate errors in the code, like naming the
>>>>>>>>>
>>>>>>>>>
>>>>>>>> server
>>>>>>>>
>>>>>>>>
>>>>>>>>> loooocalhost, but I never saw the results when accessing pages.
>>>>>>>>>
>>>>>>>>> Also, when I try to add "final HttpServletRequest request" as a
>>>>>>>>>
>>>>>>>>>
>>>>>>>> parameter
>>>>>>
>>>>>>
>>>>>>>  to
>>>>>>>>> the contributeAlias method, my T5.0.13 crashes complaining about
>>>>>>>>>
>>>>>>>>>
>>>>>>>> service
>>>>>>
>>>>>>
>>>>>>>  recursion.
>>>>>>>>>
>>>>>>>>> What I need is for T5 to figure out that a user accesses a page
>>>>>>>>> with
>>>>>>>>> either
>>>>>>>>> http or https, and respond on the same protocol...
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Regards
>>>>>>>>> Inge
>>>>>>>>>
>>>>>>>>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner <kbottner@gmail.com
>>>>>>>>> >
>>>>>>>>>
>>>>>>>>>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> I believe you might be able to use an alternation of a solution I
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> used
>>>>>>
>>>>>>
>>>>>>>  for
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> getting https to work properly between my development and
>>>>>>>>>> production
>>>>>>>>>> servers.
>>>>>>>>>>
>>>>>>>>>> public static void
>>>>>>>>>> contributeAlias(Configuration<AliasContribution>
>>>>>>>>>> configuration,
>>>>>>>>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> String
>>>>>>
>>>>>>
>>>>>>>  production
>>>>>>>>>>  {
>>>>>>>>>>               if (0 != production.compareToIgnoreCase("true"))
>>>>>>>>>>               {
>>>>>>>>>>             BaseURLSource source = new BaseURLSource()
>>>>>>>>>>             {
>>>>>>>>>>                 public String getBaseURL(boolean secure)
>>>>>>>>>>                 {
>>>>>>>>>>                     String protocol = secure ? "https" : "http";
>>>>>>>>>>
>>>>>>>>>>                     int port = secure ? 8443 : 8080;
>>>>>>>>>>
>>>>>>>>>>                     return String.format("%s://localhost:%d",
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> protocol,
>>>>>>>>
>>>>>>>>
>>>>>>>>> port);
>>>>>>>>>>                 }
>>>>>>>>>>             };
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> source));
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>               }
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>> Somehow make this dependent on the user selection and return it
>>>>>>>>>> accordingly.
>>>>>>>>>>
>>>>>>>>>> Not a quick solution but possible a direction to try!
>>>>>>>>>>
>>>>>>>>>> Keith
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>>>>>>>>>>
>>>>>>>>>>  Hi!
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> My web application is large and consists of Struts, T4 and T5
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> pages.
>>>>>>
>>>>>>
>>>>>>> In
>>>>>>>>
>>>>>>>>
>>>>>>>>>  Struts and T4, I use the current http request to figure out
>>>>>>>>>>> whether
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> to
>>>>>>
>>>>>>
>>>>>>>  use
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> https or not. Users can choose if they want to log in using https
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> or
>>>>>>
>>>>>>
>>>>>>>  not.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> The chosen protocol is used on all pages after login.
>>>>>>>>>>>
>>>>>>>>>>> In T5, this is either a global static setting, or a static
>>>>>>>>>>> setting
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> per
>>>>>>
>>>>>>
>>>>>>>  page.
>>>>>>>>>>> Is there a service or something I can override to implement my
>>>>>>>>>>> own
>>>>>>>>>>> "protocol
>>>>>>>>>>> builder"? Something like this:
>>>>>>>>>>>
>>>>>>>>>>> public class HttpProtocolBuilder {
>>>>>>>>>>>  public HttpProtocolBuilder (final HttpServletRequest request) {
>>>>>>>>>>>  this.request = request
>>>>>>>>>>>  }
>>>>>>>>>>>
>>>>>>>>>>>  public String getProtocol() {
>>>>>>>>>>>  if (request.isSecure()) {
>>>>>>>>>>>    return "https";
>>>>>>>>>>>  }
>>>>>>>>>>>  else {
>>>>>>>>>>>   return "http";
>>>>>>>>>>>   }
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> Regards
>>>>>>>>>>>
>>>>>>>>>>> Inge
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>>>  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

Re: [T5] Pick up https/http from request

Posted by Inge Solvoll <in...@gmail.com>.
Important note on this one:

My implementation breaks non-standard ports, and makes pages on port 8080
post forms to port 80. The correct way to address this is to just return
null and false in the 2 methods, and do a service override instead of alias.

On Thu, Nov 27, 2008 at 4:18 PM, Ryan Mitchell <rj...@tcl.net> wrote:

> Hi, glad to see the solution, I came up with something almost
> identical, contributing my own RequestSecurityManager.  I posted about
> this issue a few weeks ago and was surprised no one responded, but I
> figured I was explaining the problem weirdly, as I'm wont to do.  In
> my case the problem led to sessions being lost between the transitions
> from https to http requests if the cookie the container created was
> flagged as 'secure'.
>
> My implementation of RequestSecurityManager is identical to the
> original T5 impl except one line:
>
> public String getBaseURL(Page page) {
>         boolean securePage = isSecure(page);
>        if (securePage == request.isSecure()) return null;
>        if (request.isSecure()) return null; // <<< rjm added 2008-10-30
>        return baseURLSource.getBaseURL(securePage);
>    }
>
> I *think* this would resolve TAP5-167, though I haven't tested
> explicitly.  It does work well for my own application, were there is
> an explicit mix of http and https pages (using @Secure annotation,
> etc).
>
>
> On Thu, Nov 27, 2008 at 3:56 AM, Michael Gerzabek
> <mi...@gmx.net> wrote:
> > straight forward! Thanks for posting your solution.
> >
> > Inge Solvoll schrieb:
> >>
> >> Excellent! Thanks for thep help, everyone!! This has made my life so
> much
> >> easier...
> >>
> >> Got it working like this:
> >>
> >> In my implementation of RequestSecurityManager:
> >>
> >>  public boolean checkForInsecureRequest(String pageName) throws
> >> IOException
> >> {
> >>    return false;
> >>  }
> >>
> >>  public String getBaseURL(Page page) {
> >>    return baseURLSource.getBaseURL(request.isSecure());
> >>  }
> >>
> >>
> >> In my Appmodule:
> >>
> >>  public static void contributeAlias(Configuration<AliasContribution>
> >> configuration, @InjectService("Request") Request request,
> >> @InjectService("BaseURLSource") BaseURLSource baseURLSource) {
> >>    RequestSecurityManager manager = new
> MyRequestSecurityManager(request,
> >> baseURLSource);
> >>
> >>
>  configuration.add(AliasContribution.create(RequestSecurityManager.class,
> >> manager));
> >>  }
> >>
> >>
> >> On Wed, Nov 26, 2008 at 12:42 PM, Michael Gerzabek
> >> <michael.gerzabek@gmx.net
> >>
> >>>
> >>> wrote:
> >>>
> >>
> >>
> >>>
> >>> Inge Solvoll schrieb:
> >>>
> >>>
> >>>>
> >>>> Thanks, I'll look into that then.
> >>>>
> >>>> What I want to do:
> >>>>
> >>>> 1. The user accesses http://myserver.com/mypage. Should get the same
> >>>> url/protocol in return.
> >>>> 2. The user accesses https://myserver.com/mypage. Should get the same
> >>>> url/protocol in return.
> >>>>
> >>>>
> >>>>
> >>>
> >>> Ok,
> >>>
> >>> so then forget BaseURLSource and implement RequestSecurityManager. The
> >>> code
> >>> could be something like
> >>>
> >>>  public boolean checkForInsecureRequest( String pageName )
> >>>      throws IOException {
> >>>
> >>>      ... copy-n-paste from T5 implementation ...
> >>>  }
> >>>
> >>>  public String getBaseURL( Page page ) {
> >>>
> >>>      return baseURLSource.getBaseURL( request.isSecure() );
> >>>  }
> >>>
> >>> and get Request injected in your constructor.
> >>>
> >>> /Michael
> >>>
> >>>  As of now, the user gets a fixed protocol in return, not the protocol
> he
> >>>
> >>>>
> >>>> requested.
> >>>>
> >>>>
> >>>>
> >>>> On Wed, Nov 26, 2008 at 12:29 PM, Michael Gerzabek <
> >>>> michael.gerzabek@gmx.net
> >>>>
> >>>>
> >>>>
> >>>>>
> >>>>> wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>>>
> >>>>> Inge,
> >>>>>
> >>>>> not sure that I undestand fully what you are about. It sounds like
> you
> >>>>> also
> >>>>> want to implement RequestSecurityManager (
> >>>>>
> >>>>>
> >>>>>
> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/internal/services/package-tree.html
> >>>>> ).
> >>>>> This is at least what I did and it works for me.
> >>>>>
> >>>>> /Michael
> >>>>>
> >>>>> Inge Solvoll schrieb:
> >>>>>
> >>>>>  I think I know the reason for the loop...
> >>>>>
> >>>>>
> >>>>>
> >>>>>>
> >>>>>> my getBaseURL method is only called when the requested url has a
> >>>>>> different
> >>>>>> protocol than specified in MetaDataConstants.SECURE_PAGE. It seems
> >>>>>> that
> >>>>>> when
> >>>>>> I try to write a base URL in my custom method that has a different
> >>>>>> protocol
> >>>>>> than SECURE_PAGE value, they start knocking each other's heades with
> >>>>>> redirects.
> >>>>>>
> >>>>>> Right now, it looks like this system works differently than I
> thought.
> >>>>>> Is
> >>>>>> it
> >>>>>> not possible to override the behaviour of one page or entire
> >>>>>> application
> >>>>>> fixed on a protocol?
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> On Wed, Nov 26, 2008 at 11:44 AM, Kristian Marinkovic <
> >>>>>> kristian.marinkovic@porsche.co.at> wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>>
> >>>>>>> try creating the proxy manually... almost worked every time for me
> >>>>>>>
> >>>>>>> constructor injection will be performed as expected
> >>>>>>>
> >>>>>>> public static void contributeAlias(
> >>>>>>>  ObjectLocator locator,
> >>>>>>>  Configuration<AliasContribution> configuration ) {
> >>>>>>>
> >>>>>>>  configuration.add( AliasContribution.create(
> >>>>>>>        BaseURLSource.class,
> >>>>>>>         locator.proxy(BaseURLSource.class,SomeImplementation.class)
> >>>>>>> );
> >>>>>>>
> >>>>>>>  }
> >>>>>>>
> >>>>>>> g,
> >>>>>>> kris
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> "Inge Solvoll" <in...@gmail.com>
> >>>>>>> 26.11.2008 11:37
> >>>>>>> Bitte antworten an
> >>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> >>>>>>>
> >>>>>>>
> >>>>>>> An
> >>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> >>>>>>> Kopie
> >>>>>>>
> >>>>>>> Thema
> >>>>>>> Re: [T5] Pick up https/http from request
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> Thanks!
> >>>>>>>
> >>>>>>> But this still gives me the same loop error, because I have to
> inject
> >>>>>>> Request (where you inject SiteServices) into the builder method to
> >>>>>>> access
> >>>>>>> the secure state of the request:
> >>>>>>>
> >>>>>>> Caused by: org.apache.tapestry5.ioc.internal.OperationException:
> >>>>>>> Construction of service 'Alias' has failed due to recursion: the
> >>>>>>> service
> >>>>>>> depends on itself in some way. Please check
> >>>>>>> org.apache.tapestry5.services.TapestryModule.buildAlias(Logger,
> >>>>>>> String,
> >>>>>>> AliasManager, Collection) (at TapestryModule.java:214) for
> references
> >>>>>>> to
> >>>>>>> another service that is itself dependent on service 'Alias'.
> >>>>>>>
> >>>>>>> Inge
> >>>>>>>
> >>>>>>> On Wed, Nov 26, 2008 at 11:28 AM, Michael Gerzabek
> >>>>>>> <michael.gerzabek@gmx.net
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>> wrote:
> >>>>>>>>    Inge,
> >>>>>>>>
> >>>>>>>> I did it successfully for a similar purpose:
> >>>>>>>>
> >>>>>>>>  @SuppressWarnings("unchecked")
> >>>>>>>>  public static void contributeAlias(
> >>>>>>>>    @InjectService( "SiteBaseURLSource" )
> >>>>>>>>    BaseURLSource baseUrlSource,
> >>>>>>>>    Configuration<AliasContribution> configuration ) {
> >>>>>>>>
> >>>>>>>>    configuration.add( AliasContribution.create(
> >>>>>>>>        BaseURLSource.class,
> >>>>>>>>        baseUrlSource ) );
> >>>>>>>>
> >>>>>>>>  }
> >>>>>>>>
> >>>>>>>> Don't use the binder but create your own build method:
> >>>>>>>>
> >>>>>>>>  @Marker( SiteServices.class )
> >>>>>>>>  public static BaseURLSource buildSiteBaseURLSource(
> >>>>>>>>    @SiteServices
> >>>>>>>>    SiteService site ) {
> >>>>>>>>
> >>>>>>>>    return new SiteBaseURLSource( site );
> >>>>>>>>  }
> >>>>>>>>
> >>>>>>>> You can ommit the Marker annotation.
> >>>>>>>>
> >>>>>>>> /Michael
> >>>>>>>>
> >>>>>>>> Solvoll schrieb:
> >>>>>>>>
> >>>>>>>>  Hi!
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> I'm really struggling here as I think I'm approaching a solution.
> >>>>>>>>> What
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>> I'm
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>> trying to do is to override/decorate/alias/replace the
> BaseURLSource
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>> with
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>> my
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> own implementation, like this:
> >>>>>>>>>
> >>>>>>>>> public class MyBaseURLSource implements BaseURLSource {
> >>>>>>>>>
> >>>>>>>>>  private final Request request;
> >>>>>>>>>
> >>>>>>>>>  public MyBaseURLSource(Request request) {
> >>>>>>>>>  this.request = request;
> >>>>>>>>>  }
> >>>>>>>>>
> >>>>>>>>>  public String getBaseURL(boolean secure) {
> >>>>>>>>>  boolean secureRequest = request.isSecure();
> >>>>>>>>>  String baseURL = String.format("%s://%s", secureRequest ?
> "https"
> >>>>>>>>> :
> >>>>>>>>> "http", request.getServerName());
> >>>>>>>>>  return baseURL;
> >>>>>>>>>  }
> >>>>>>>>>
> >>>>>>>>> }
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> Essentially, I've copied the default implementation and replaced
> >>>>>>>>> the
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>> usage
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>> of the secure parameter with the secure value of the request. My
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>> problem
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>> is
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> that I'm not capable of putting this code to actual work in the
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>> framework.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>> I've tried:
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> - aliasing, but that didn't work because of circular dependency
> (I
> >>>>>>>>> have
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>> to
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>> inject the Request)
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> - binder.bind(BaseURLSource.class, MyBaseURLSource.class),
> >>>>>>>>> combinded
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>> with
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>> a
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> builder for MyBaseURLSource. Causes redirect loop.
> >>>>>>>>> - Decorating. Not managed to find out how I do this yet, have
> tried
> >>>>>>>>> a
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>> few
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>> things.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> I'm guessing this is rather simple, it's just a bit complicated
> >>>>>>>>> when
> >>>>>>>>> you're
> >>>>>>>>> not experienced in IoC... Anyone who wants to point me in the
> right
> >>>>>>>>> direction?
> >>>>>>>>>
> >>>>>>>>> Regards
> >>>>>>>>> Inge
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> On Wed, Nov 19, 2008 at 10:22 AM, Inge Solvoll <
> >>>>>>>>> inge.tapestry@gmail.com
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> wrote:
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> I voted for this issue now.
> >>>>>>>>>>
> >>>>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
> >>>>>>>>>>
> >>>>>>>>>> This is really a big issue for our usage of T5, T5 is now
> forcing
> >>>>>>>>>> us
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> to
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>> redirect users away from http access, because we no longer can
> >>>>>>>> support
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> both
> >>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> modes as long as T5 is fixed on either http or https.
> >>>>>>>>>>
> >>>>>>>>>> Anyone who's got a working version of a BaseURLSource
> >>>>>>>>>> contribution,
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> that
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>> actually can output a URL using the protocol from the initial
> >>>>>>>> request?
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> Regards
> >>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> Inge
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <
> >>>>>>>>>> inge.tapestry@gmail.com
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> wrote:
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> I know, this isn't really a problem for regular pages, they
> load
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> using
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>
> >>>>>>>> the
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> requested protocol, when not marked as secure. But when I create
> >>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> eventlinks
> >>>>>>>>>>> that updates zones, these don't work when they are generated
> with
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> http
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>
> >>>>>>>> and
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> the rest of the page is generated in https...
> >>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> What I would like to do is to try some more on the
> BaseURLSource
> >>>>>>>>>>> approach.
> >>>>>>>>>>> Anyone who's got any idea why this has no effect here? I copied
> >>>>>>>>>>> and
> >>>>>>>>>>> pasted
> >>>>>>>>>>> the code from the T5 docs and put in my Appmodule, and the
> >>>>>>>>>>> contribute
> >>>>>>>>>>> method
> >>>>>>>>>>> is called on server startup. I replaced the "localhost" url
> with
> >>>>>>>>>>> an
> >>>>>>>>>>> obviously bad url, for testing, but nothing happens, all pages
> >>>>>>>>>>> just
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> load
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>
> >>>>>>>> as
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> always, including eventlinks and actionlinks.
> >>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> Inge
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <
> >>>>>>>>>>> carl.crowder@taptu.com
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> wrote:
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> I don't know if you're aware, but if you create a href
> something
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> like
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>
> >>>>>>>> href="//something.com/page"
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> then the current protocol is maintained. So if you were viewing
> the
> >>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> page
> >>>>>>>>>>>> at https://something.com the HREF would resolve to
> >>>>>>>>>>>> https://something.com/page and similarly with http.
> >>>>>>>>>>>> Unfortunately
> >>>>>>>>>>>> it
> >>>>>>>>>>>> requires using absolute URLs all the time.
> >>>>>>>>>>>>
> >>>>>>>>>>>> I'm not sure if that helps, but perhaps it could be used in
> >>>>>>>>>>>> fixing
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> that
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>
> >>>>>>>> issue.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> Carl
> >>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> Inge Solvoll wrote:
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Yes, I might. This is a major blow for us, our customers
> choose
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> freely
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>
> >>>>>>>> whether they want to use http or https, so the T5 way of doing
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> things
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>
> >>>>>>>> just
> >>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> doesn't work for us...
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
> >>>>>>>>>>>>> jonathan.theitguy@gmail.com> wrote:
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> You might want to vote for this:
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> -----Original Message-----
> >>>>>>>>>>>>>>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
> >>>>>>>>>>>>>>> Sent: Friday, November 14, 2008 15:10
> >>>>>>>>>>>>>>> To: Tapestry users
> >>>>>>>>>>>>>>> Subject: Re: [T5] Pick up https/http from request
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Thanks!
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> I tried copying your code into my AppModule with some small
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> modifications.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> But the code only runs on server startup, not when I access
> a
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> tapestry 5
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> page. I tried to add deliberate errors in the code, like
> naming
> >>>>>>>>>>>>> the
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> server
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> loooocalhost, but I never saw the results when accessing
> >>>>>>>>>>>>>>> pages.
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Also, when I try to add "final HttpServletRequest request"
> as
> >>>>>>>>>>>>>>> a
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> parameter
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> to
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> the contributeAlias method, my T5.0.13 crashes complaining
> >>>>>>>>>>>>>> about
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> service
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> recursion.
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> What I need is for T5 to figure out that a user accesses a
> >>>>>>>>>>>>>> page
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> with
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>
> >>>>>>>> either
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> http or https, and respond on the same protocol...
> >>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>> Inge
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> <kb...@gmail.com>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>
> >>>>>>>> wrote:
> >>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> I believe you might be able to use an alternation of a
> >>>>>>>>>>>>>>> solution
> >>>>>>>>>>>>>>> I
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> used
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> for
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> getting https to work properly between my development and
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> production
> >>>>>>>>>>>>>>>> servers.
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> public static void
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> contributeAlias(Configuration<AliasContribution>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>
> >>>>>>>> configuration,
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
> >>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> String
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> production
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>  {
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>            if (0 != production.compareToIgnoreCase("true"))
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>            {
> >>>>>>>>>>>>>>>>          BaseURLSource source = new BaseURLSource()
> >>>>>>>>>>>>>>>>          {
> >>>>>>>>>>>>>>>>              public String getBaseURL(boolean secure)
> >>>>>>>>>>>>>>>>              {
> >>>>>>>>>>>>>>>>                  String protocol = secure ? "https" :
> >>>>>>>>>>>>>>>> "http";
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>                  int port = secure ? 8443 : 8080;
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>                  return String.format("%s://localhost:%d",
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> protocol,
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> port);
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>              }
> >>>>>>>>>>>>>>>>          };
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
>  configuration.add(AliasContribution.create(BaseURLSource.class,
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> source));
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>            }
> >>>>>>>>>>>>>>>>  }
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> Somehow make this dependent on the user selection and
> return
> >>>>>>>>>>>>>>>> it
> >>>>>>>>>>>>>>>> accordingly.
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> Not a quick solution but possible a direction to try!
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> Keith
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>  Hi!
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> My web application is large and consists of Struts, T4
> and
> >>>>>>>>>>>>>>>>> T5
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> pages.
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> In
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Struts and T4, I use the current http request to figure out
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> whether
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>
> >>>>>>>> to
> >>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> use
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> https or not. Users can choose if they want to log in using
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> https
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>
> >>>>>>>> or
> >>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> not.
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> The chosen protocol is used on all pages after login.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> In T5, this is either a global static setting, or a
> static
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> setting
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>
> >>>>>>>> per
> >>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> page.
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Is there a service or something I can override to implement
> my
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> own
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>
> >>>>>>>> "protocol
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> builder"? Something like this:
> >>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> public class HttpProtocolBuilder {
> >>>>>>>>>>>>>>>>>  public HttpProtocolBuilder (final HttpServletRequest
> >>>>>>>>>>>>>>>>> request)
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> {
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>
> >>>>>>>>  this.request = request
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>>  }
> >>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>  public String getProtocol() {
> >>>>>>>>>>>>>>>>>  if (request.isSecure()) {
> >>>>>>>>>>>>>>>>>  return "https";
> >>>>>>>>>>>>>>>>>  }
> >>>>>>>>>>>>>>>>>  else {
> >>>>>>>>>>>>>>>>>  return "http";
> >>>>>>>>>>>>>>>>>  }
> >>>>>>>>>>>>>>>>> }
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> Inge
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>
> >>>>>>>
> ---------------------------------------------------------------------
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>>>>>> users-help@tapestry.apache.org
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>
> >>>>>>>
> ---------------------------------------------------------------------
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>
> >>>>>>>
> ---------------------------------------------------------------------
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> ---------------------------------------------------------------------
> >>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
>
> --
> Ryan Mitchell <rj...@tcl.net>
> Telecom Logic, LLC
> +15039432980
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: [T5] Pick up https/http from request

Posted by Ryan Mitchell <rj...@tcl.net>.
Hi, glad to see the solution, I came up with something almost
identical, contributing my own RequestSecurityManager.  I posted about
this issue a few weeks ago and was surprised no one responded, but I
figured I was explaining the problem weirdly, as I'm wont to do.  In
my case the problem led to sessions being lost between the transitions
from https to http requests if the cookie the container created was
flagged as 'secure'.

My implementation of RequestSecurityManager is identical to the
original T5 impl except one line:

public String getBaseURL(Page page) {
        boolean securePage = isSecure(page);
        if (securePage == request.isSecure()) return null;
        if (request.isSecure()) return null; // <<< rjm added 2008-10-30
        return baseURLSource.getBaseURL(securePage);
    }

I *think* this would resolve TAP5-167, though I haven't tested
explicitly.  It does work well for my own application, were there is
an explicit mix of http and https pages (using @Secure annotation,
etc).


On Thu, Nov 27, 2008 at 3:56 AM, Michael Gerzabek
<mi...@gmx.net> wrote:
> straight forward! Thanks for posting your solution.
>
> Inge Solvoll schrieb:
>>
>> Excellent! Thanks for thep help, everyone!! This has made my life so much
>> easier...
>>
>> Got it working like this:
>>
>> In my implementation of RequestSecurityManager:
>>
>>  public boolean checkForInsecureRequest(String pageName) throws
>> IOException
>> {
>>    return false;
>>  }
>>
>>  public String getBaseURL(Page page) {
>>    return baseURLSource.getBaseURL(request.isSecure());
>>  }
>>
>>
>> In my Appmodule:
>>
>>  public static void contributeAlias(Configuration<AliasContribution>
>> configuration, @InjectService("Request") Request request,
>> @InjectService("BaseURLSource") BaseURLSource baseURLSource) {
>>    RequestSecurityManager manager = new MyRequestSecurityManager(request,
>> baseURLSource);
>>
>>  configuration.add(AliasContribution.create(RequestSecurityManager.class,
>> manager));
>>  }
>>
>>
>> On Wed, Nov 26, 2008 at 12:42 PM, Michael Gerzabek
>> <michael.gerzabek@gmx.net
>>
>>>
>>> wrote:
>>>
>>
>>
>>>
>>> Inge Solvoll schrieb:
>>>
>>>
>>>>
>>>> Thanks, I'll look into that then.
>>>>
>>>> What I want to do:
>>>>
>>>> 1. The user accesses http://myserver.com/mypage. Should get the same
>>>> url/protocol in return.
>>>> 2. The user accesses https://myserver.com/mypage. Should get the same
>>>> url/protocol in return.
>>>>
>>>>
>>>>
>>>
>>> Ok,
>>>
>>> so then forget BaseURLSource and implement RequestSecurityManager. The
>>> code
>>> could be something like
>>>
>>>  public boolean checkForInsecureRequest( String pageName )
>>>      throws IOException {
>>>
>>>      ... copy-n-paste from T5 implementation ...
>>>  }
>>>
>>>  public String getBaseURL( Page page ) {
>>>
>>>      return baseURLSource.getBaseURL( request.isSecure() );
>>>  }
>>>
>>> and get Request injected in your constructor.
>>>
>>> /Michael
>>>
>>>  As of now, the user gets a fixed protocol in return, not the protocol he
>>>
>>>>
>>>> requested.
>>>>
>>>>
>>>>
>>>> On Wed, Nov 26, 2008 at 12:29 PM, Michael Gerzabek <
>>>> michael.gerzabek@gmx.net
>>>>
>>>>
>>>>
>>>>>
>>>>> wrote:
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>>
>>>>> Inge,
>>>>>
>>>>> not sure that I undestand fully what you are about. It sounds like you
>>>>> also
>>>>> want to implement RequestSecurityManager (
>>>>>
>>>>>
>>>>> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/internal/services/package-tree.html
>>>>> ).
>>>>> This is at least what I did and it works for me.
>>>>>
>>>>> /Michael
>>>>>
>>>>> Inge Solvoll schrieb:
>>>>>
>>>>>  I think I know the reason for the loop...
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> my getBaseURL method is only called when the requested url has a
>>>>>> different
>>>>>> protocol than specified in MetaDataConstants.SECURE_PAGE. It seems
>>>>>> that
>>>>>> when
>>>>>> I try to write a base URL in my custom method that has a different
>>>>>> protocol
>>>>>> than SECURE_PAGE value, they start knocking each other's heades with
>>>>>> redirects.
>>>>>>
>>>>>> Right now, it looks like this system works differently than I thought.
>>>>>> Is
>>>>>> it
>>>>>> not possible to override the behaviour of one page or entire
>>>>>> application
>>>>>> fixed on a protocol?
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Nov 26, 2008 at 11:44 AM, Kristian Marinkovic <
>>>>>> kristian.marinkovic@porsche.co.at> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> try creating the proxy manually... almost worked every time for me
>>>>>>>
>>>>>>> constructor injection will be performed as expected
>>>>>>>
>>>>>>> public static void contributeAlias(
>>>>>>>  ObjectLocator locator,
>>>>>>>  Configuration<AliasContribution> configuration ) {
>>>>>>>
>>>>>>>  configuration.add( AliasContribution.create(
>>>>>>>        BaseURLSource.class,
>>>>>>>         locator.proxy(BaseURLSource.class,SomeImplementation.class)
>>>>>>> );
>>>>>>>
>>>>>>>  }
>>>>>>>
>>>>>>> g,
>>>>>>> kris
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> "Inge Solvoll" <in...@gmail.com>
>>>>>>> 26.11.2008 11:37
>>>>>>> Bitte antworten an
>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>
>>>>>>>
>>>>>>> An
>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>> Kopie
>>>>>>>
>>>>>>> Thema
>>>>>>> Re: [T5] Pick up https/http from request
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Thanks!
>>>>>>>
>>>>>>> But this still gives me the same loop error, because I have to inject
>>>>>>> Request (where you inject SiteServices) into the builder method to
>>>>>>> access
>>>>>>> the secure state of the request:
>>>>>>>
>>>>>>> Caused by: org.apache.tapestry5.ioc.internal.OperationException:
>>>>>>> Construction of service 'Alias' has failed due to recursion: the
>>>>>>> service
>>>>>>> depends on itself in some way. Please check
>>>>>>> org.apache.tapestry5.services.TapestryModule.buildAlias(Logger,
>>>>>>> String,
>>>>>>> AliasManager, Collection) (at TapestryModule.java:214) for references
>>>>>>> to
>>>>>>> another service that is itself dependent on service 'Alias'.
>>>>>>>
>>>>>>> Inge
>>>>>>>
>>>>>>> On Wed, Nov 26, 2008 at 11:28 AM, Michael Gerzabek
>>>>>>> <michael.gerzabek@gmx.net
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> wrote:
>>>>>>>>    Inge,
>>>>>>>>
>>>>>>>> I did it successfully for a similar purpose:
>>>>>>>>
>>>>>>>>  @SuppressWarnings("unchecked")
>>>>>>>>  public static void contributeAlias(
>>>>>>>>    @InjectService( "SiteBaseURLSource" )
>>>>>>>>    BaseURLSource baseUrlSource,
>>>>>>>>    Configuration<AliasContribution> configuration ) {
>>>>>>>>
>>>>>>>>    configuration.add( AliasContribution.create(
>>>>>>>>        BaseURLSource.class,
>>>>>>>>        baseUrlSource ) );
>>>>>>>>
>>>>>>>>  }
>>>>>>>>
>>>>>>>> Don't use the binder but create your own build method:
>>>>>>>>
>>>>>>>>  @Marker( SiteServices.class )
>>>>>>>>  public static BaseURLSource buildSiteBaseURLSource(
>>>>>>>>    @SiteServices
>>>>>>>>    SiteService site ) {
>>>>>>>>
>>>>>>>>    return new SiteBaseURLSource( site );
>>>>>>>>  }
>>>>>>>>
>>>>>>>> You can ommit the Marker annotation.
>>>>>>>>
>>>>>>>> /Michael
>>>>>>>>
>>>>>>>> Solvoll schrieb:
>>>>>>>>
>>>>>>>>  Hi!
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> I'm really struggling here as I think I'm approaching a solution.
>>>>>>>>> What
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> I'm
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> trying to do is to override/decorate/alias/replace the BaseURLSource
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> with
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> my
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> own implementation, like this:
>>>>>>>>>
>>>>>>>>> public class MyBaseURLSource implements BaseURLSource {
>>>>>>>>>
>>>>>>>>>  private final Request request;
>>>>>>>>>
>>>>>>>>>  public MyBaseURLSource(Request request) {
>>>>>>>>>  this.request = request;
>>>>>>>>>  }
>>>>>>>>>
>>>>>>>>>  public String getBaseURL(boolean secure) {
>>>>>>>>>  boolean secureRequest = request.isSecure();
>>>>>>>>>  String baseURL = String.format("%s://%s", secureRequest ? "https"
>>>>>>>>> :
>>>>>>>>> "http", request.getServerName());
>>>>>>>>>  return baseURL;
>>>>>>>>>  }
>>>>>>>>>
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Essentially, I've copied the default implementation and replaced
>>>>>>>>> the
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> usage
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> of the secure parameter with the secure value of the request. My
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> problem
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> is
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> that I'm not capable of putting this code to actual work in the
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> framework.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> I've tried:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> - aliasing, but that didn't work because of circular dependency (I
>>>>>>>>> have
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> to
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> inject the Request)
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> - binder.bind(BaseURLSource.class, MyBaseURLSource.class),
>>>>>>>>> combinded
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> with
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> a
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> builder for MyBaseURLSource. Causes redirect loop.
>>>>>>>>> - Decorating. Not managed to find out how I do this yet, have tried
>>>>>>>>> a
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> few
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> things.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> I'm guessing this is rather simple, it's just a bit complicated
>>>>>>>>> when
>>>>>>>>> you're
>>>>>>>>> not experienced in IoC... Anyone who wants to point me in the right
>>>>>>>>> direction?
>>>>>>>>>
>>>>>>>>> Regards
>>>>>>>>> Inge
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Wed, Nov 19, 2008 at 10:22 AM, Inge Solvoll <
>>>>>>>>> inge.tapestry@gmail.com
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> I voted for this issue now.
>>>>>>>>>>
>>>>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>>>>>
>>>>>>>>>> This is really a big issue for our usage of T5, T5 is now forcing
>>>>>>>>>> us
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> to
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> redirect users away from http access, because we no longer can
>>>>>>>> support
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> both
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> modes as long as T5 is fixed on either http or https.
>>>>>>>>>>
>>>>>>>>>> Anyone who's got a working version of a BaseURLSource
>>>>>>>>>> contribution,
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> that
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> actually can output a URL using the protocol from the initial
>>>>>>>> request?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Regards
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Inge
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <
>>>>>>>>>> inge.tapestry@gmail.com
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> I know, this isn't really a problem for regular pages, they load
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> using
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>>> the
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> requested protocol, when not marked as secure. But when I create
>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> eventlinks
>>>>>>>>>>> that updates zones, these don't work when they are generated with
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> http
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>>> and
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> the rest of the page is generated in https...
>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> What I would like to do is to try some more on the BaseURLSource
>>>>>>>>>>> approach.
>>>>>>>>>>> Anyone who's got any idea why this has no effect here? I copied
>>>>>>>>>>> and
>>>>>>>>>>> pasted
>>>>>>>>>>> the code from the T5 docs and put in my Appmodule, and the
>>>>>>>>>>> contribute
>>>>>>>>>>> method
>>>>>>>>>>> is called on server startup. I replaced the "localhost" url with
>>>>>>>>>>> an
>>>>>>>>>>> obviously bad url, for testing, but nothing happens, all pages
>>>>>>>>>>> just
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> load
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>>> as
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> always, including eventlinks and actionlinks.
>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Inge
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <
>>>>>>>>>>> carl.crowder@taptu.com
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> I don't know if you're aware, but if you create a href something
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> like
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>
>>>>>>>> href="//something.com/page"
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> then the current protocol is maintained. So if you were viewing the
>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> page
>>>>>>>>>>>> at https://something.com the HREF would resolve to
>>>>>>>>>>>> https://something.com/page and similarly with http.
>>>>>>>>>>>> Unfortunately
>>>>>>>>>>>> it
>>>>>>>>>>>> requires using absolute URLs all the time.
>>>>>>>>>>>>
>>>>>>>>>>>> I'm not sure if that helps, but perhaps it could be used in
>>>>>>>>>>>> fixing
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> that
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>
>>>>>>>> issue.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Carl
>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Inge Solvoll wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Yes, I might. This is a major blow for us, our customers choose
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> freely
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>
>>>>>>>> whether they want to use http or https, so the T5 way of doing
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> things
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>
>>>>>>>> just
>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> doesn't work for us...
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
>>>>>>>>>>>>> jonathan.theitguy@gmail.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> You might want to vote for this:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>>>>>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
>>>>>>>>>>>>>>> Sent: Friday, November 14, 2008 15:10
>>>>>>>>>>>>>>> To: Tapestry users
>>>>>>>>>>>>>>> Subject: Re: [T5] Pick up https/http from request
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thanks!
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I tried copying your code into my AppModule with some small
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> modifications.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> But the code only runs on server startup, not when I access a
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> tapestry 5
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> page. I tried to add deliberate errors in the code, like naming
>>>>>>>>>>>>> the
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> server
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> loooocalhost, but I never saw the results when accessing
>>>>>>>>>>>>>>> pages.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Also, when I try to add "final HttpServletRequest request" as
>>>>>>>>>>>>>>> a
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> parameter
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> to
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> the contributeAlias method, my T5.0.13 crashes complaining
>>>>>>>>>>>>>> about
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> service
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> recursion.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> What I need is for T5 to figure out that a user accesses a
>>>>>>>>>>>>>> page
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> with
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>
>>>>>>>> either
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> http or https, and respond on the same protocol...
>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>> Inge
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> <kb...@gmail.com>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I believe you might be able to use an alternation of a
>>>>>>>>>>>>>>> solution
>>>>>>>>>>>>>>> I
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> used
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> for
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> getting https to work properly between my development and
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> production
>>>>>>>>>>>>>>>> servers.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> public static void
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> contributeAlias(Configuration<AliasContribution>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>
>>>>>>>> configuration,
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> String
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> production
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>            if (0 != production.compareToIgnoreCase("true"))
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>            {
>>>>>>>>>>>>>>>>          BaseURLSource source = new BaseURLSource()
>>>>>>>>>>>>>>>>          {
>>>>>>>>>>>>>>>>              public String getBaseURL(boolean secure)
>>>>>>>>>>>>>>>>              {
>>>>>>>>>>>>>>>>                  String protocol = secure ? "https" :
>>>>>>>>>>>>>>>> "http";
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                  int port = secure ? 8443 : 8080;
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                  return String.format("%s://localhost:%d",
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> protocol,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> port);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>              }
>>>>>>>>>>>>>>>>          };
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> source));
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>            }
>>>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Somehow make this dependent on the user selection and return
>>>>>>>>>>>>>>>> it
>>>>>>>>>>>>>>>> accordingly.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Not a quick solution but possible a direction to try!
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Keith
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>  Hi!
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> My web application is large and consists of Struts, T4 and
>>>>>>>>>>>>>>>>> T5
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> pages.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> In
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Struts and T4, I use the current http request to figure out
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> whether
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>
>>>>>>>> to
>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> use
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> https or not. Users can choose if they want to log in using
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> https
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>
>>>>>>>> or
>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> not.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> The chosen protocol is used on all pages after login.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> In T5, this is either a global static setting, or a static
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> setting
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>
>>>>>>>> per
>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> page.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Is there a service or something I can override to implement my
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> own
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>
>>>>>>>> "protocol
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> builder"? Something like this:
>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> public class HttpProtocolBuilder {
>>>>>>>>>>>>>>>>>  public HttpProtocolBuilder (final HttpServletRequest
>>>>>>>>>>>>>>>>> request)
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>
>>>>>>>>  this.request = request
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>  }
>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>  public String getProtocol() {
>>>>>>>>>>>>>>>>>  if (request.isSecure()) {
>>>>>>>>>>>>>>>>>  return "https";
>>>>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>>>>  else {
>>>>>>>>>>>>>>>>>  return "http";
>>>>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Inge
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>>>> users-help@tapestry.apache.org
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Ryan Mitchell <rj...@tcl.net>
Telecom Logic, LLC
+15039432980

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Pick up https/http from request

Posted by Michael Gerzabek <mi...@gmx.net>.
straight forward! Thanks for posting your solution.

Inge Solvoll schrieb:
> Excellent! Thanks for thep help, everyone!! This has made my life so much
> easier...
>
> Got it working like this:
>
> In my implementation of RequestSecurityManager:
>
>   public boolean checkForInsecureRequest(String pageName) throws IOException
> {
>     return false;
>   }
>
>   public String getBaseURL(Page page) {
>     return baseURLSource.getBaseURL(request.isSecure());
>   }
>
>
> In my Appmodule:
>
>   public static void contributeAlias(Configuration<AliasContribution>
> configuration, @InjectService("Request") Request request,
> @InjectService("BaseURLSource") BaseURLSource baseURLSource) {
>     RequestSecurityManager manager = new MyRequestSecurityManager(request,
> baseURLSource);
>     configuration.add(AliasContribution.create(RequestSecurityManager.class,
> manager));
>   }
>
>
> On Wed, Nov 26, 2008 at 12:42 PM, Michael Gerzabek <michael.gerzabek@gmx.net
>   
>> wrote:
>>     
>
>   
>> Inge Solvoll schrieb:
>>
>>     
>>> Thanks, I'll look into that then.
>>>
>>> What I want to do:
>>>
>>> 1. The user accesses http://myserver.com/mypage. Should get the same
>>> url/protocol in return.
>>> 2. The user accesses https://myserver.com/mypage. Should get the same
>>> url/protocol in return.
>>>
>>>
>>>       
>> Ok,
>>
>> so then forget BaseURLSource and implement RequestSecurityManager. The code
>> could be something like
>>
>>   public boolean checkForInsecureRequest( String pageName )
>>       throws IOException {
>>
>>       ... copy-n-paste from T5 implementation ...
>>   }
>>
>>   public String getBaseURL( Page page ) {
>>
>>       return baseURLSource.getBaseURL( request.isSecure() );
>>   }
>>
>> and get Request injected in your constructor.
>>
>> /Michael
>>
>>  As of now, the user gets a fixed protocol in return, not the protocol he
>>     
>>> requested.
>>>
>>>
>>>
>>> On Wed, Nov 26, 2008 at 12:29 PM, Michael Gerzabek <
>>> michael.gerzabek@gmx.net
>>>
>>>
>>>       
>>>> wrote:
>>>>
>>>>
>>>>         
>>>
>>>       
>>>> Inge,
>>>>
>>>> not sure that I undestand fully what you are about. It sounds like you
>>>> also
>>>> want to implement RequestSecurityManager (
>>>>
>>>> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/internal/services/package-tree.html
>>>> ).
>>>> This is at least what I did and it works for me.
>>>>
>>>> /Michael
>>>>
>>>> Inge Solvoll schrieb:
>>>>
>>>>  I think I know the reason for the loop...
>>>>
>>>>
>>>>         
>>>>> my getBaseURL method is only called when the requested url has a
>>>>> different
>>>>> protocol than specified in MetaDataConstants.SECURE_PAGE. It seems that
>>>>> when
>>>>> I try to write a base URL in my custom method that has a different
>>>>> protocol
>>>>> than SECURE_PAGE value, they start knocking each other's heades with
>>>>> redirects.
>>>>>
>>>>> Right now, it looks like this system works differently than I thought.
>>>>> Is
>>>>> it
>>>>> not possible to override the behaviour of one page or entire application
>>>>> fixed on a protocol?
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Nov 26, 2008 at 11:44 AM, Kristian Marinkovic <
>>>>> kristian.marinkovic@porsche.co.at> wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>           
>>>>>> try creating the proxy manually... almost worked every time for me
>>>>>>
>>>>>> constructor injection will be performed as expected
>>>>>>
>>>>>> public static void contributeAlias(
>>>>>>  ObjectLocator locator,
>>>>>>   Configuration<AliasContribution> configuration ) {
>>>>>>
>>>>>>  configuration.add( AliasContribution.create(
>>>>>>         BaseURLSource.class,
>>>>>>          locator.proxy(BaseURLSource.class,SomeImplementation.class) );
>>>>>>
>>>>>>  }
>>>>>>
>>>>>> g,
>>>>>> kris
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> "Inge Solvoll" <in...@gmail.com>
>>>>>> 26.11.2008 11:37
>>>>>> Bitte antworten an
>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>
>>>>>>
>>>>>> An
>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>> Kopie
>>>>>>
>>>>>> Thema
>>>>>> Re: [T5] Pick up https/http from request
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>>> But this still gives me the same loop error, because I have to inject
>>>>>> Request (where you inject SiteServices) into the builder method to
>>>>>> access
>>>>>> the secure state of the request:
>>>>>>
>>>>>> Caused by: org.apache.tapestry5.ioc.internal.OperationException:
>>>>>> Construction of service 'Alias' has failed due to recursion: the
>>>>>> service
>>>>>> depends on itself in some way. Please check
>>>>>> org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, String,
>>>>>> AliasManager, Collection) (at TapestryModule.java:214) for references
>>>>>> to
>>>>>> another service that is itself dependent on service 'Alias'.
>>>>>>
>>>>>> Inge
>>>>>>
>>>>>> On Wed, Nov 26, 2008 at 11:28 AM, Michael Gerzabek
>>>>>> <michael.gerzabek@gmx.net
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> wrote:
>>>>>>>     Inge,
>>>>>>>
>>>>>>> I did it successfully for a similar purpose:
>>>>>>>
>>>>>>>  @SuppressWarnings("unchecked")
>>>>>>>  public static void contributeAlias(
>>>>>>>     @InjectService( "SiteBaseURLSource" )
>>>>>>>     BaseURLSource baseUrlSource,
>>>>>>>     Configuration<AliasContribution> configuration ) {
>>>>>>>
>>>>>>>     configuration.add( AliasContribution.create(
>>>>>>>         BaseURLSource.class,
>>>>>>>         baseUrlSource ) );
>>>>>>>
>>>>>>>  }
>>>>>>>
>>>>>>> Don't use the binder but create your own build method:
>>>>>>>
>>>>>>>  @Marker( SiteServices.class )
>>>>>>>  public static BaseURLSource buildSiteBaseURLSource(
>>>>>>>     @SiteServices
>>>>>>>     SiteService site ) {
>>>>>>>
>>>>>>>     return new SiteBaseURLSource( site );
>>>>>>>  }
>>>>>>>
>>>>>>> You can ommit the Marker annotation.
>>>>>>>
>>>>>>> /Michael
>>>>>>>
>>>>>>> Solvoll schrieb:
>>>>>>>
>>>>>>>  Hi!
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> I'm really struggling here as I think I'm approaching a solution.
>>>>>>>> What
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> I'm
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>             
>>>>>>> trying to do is to override/decorate/alias/replace the BaseURLSource
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>>                 
>>>>>>> with
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>             
>>>>>>> my
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> own implementation, like this:
>>>>>>>>
>>>>>>>> public class MyBaseURLSource implements BaseURLSource {
>>>>>>>>
>>>>>>>>  private final Request request;
>>>>>>>>
>>>>>>>>  public MyBaseURLSource(Request request) {
>>>>>>>>  this.request = request;
>>>>>>>>  }
>>>>>>>>
>>>>>>>>  public String getBaseURL(boolean secure) {
>>>>>>>>  boolean secureRequest = request.isSecure();
>>>>>>>>  String baseURL = String.format("%s://%s", secureRequest ? "https" :
>>>>>>>> "http", request.getServerName());
>>>>>>>>  return baseURL;
>>>>>>>>  }
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> Essentially, I've copied the default implementation and replaced the
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> usage
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>             
>>>>>>> of the secure parameter with the secure value of the request. My
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>>                 
>>>>>>> problem
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>             
>>>>>>> is
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> that I'm not capable of putting this code to actual work in the
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> framework.
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>             
>>>>>>> I've tried:
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> - aliasing, but that didn't work because of circular dependency (I
>>>>>>>> have
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> to
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>             
>>>>>>> inject the Request)
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> - binder.bind(BaseURLSource.class, MyBaseURLSource.class), combinded
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> with
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>             
>>>>>>> a
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> builder for MyBaseURLSource. Causes redirect loop.
>>>>>>>> - Decorating. Not managed to find out how I do this yet, have tried a
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> few
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>             
>>>>>>> things.
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> I'm guessing this is rather simple, it's just a bit complicated when
>>>>>>>> you're
>>>>>>>> not experienced in IoC... Anyone who wants to point me in the right
>>>>>>>> direction?
>>>>>>>>
>>>>>>>> Regards
>>>>>>>> Inge
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wed, Nov 19, 2008 at 10:22 AM, Inge Solvoll <
>>>>>>>> inge.tapestry@gmail.com
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> I voted for this issue now.
>>>>>>>>>
>>>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>>>>
>>>>>>>>> This is really a big issue for our usage of T5, T5 is now forcing us
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> to
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> redirect users away from http access, because we no longer can support
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> both
>>>>>>>>                 
>>>>>>>>> modes as long as T5 is fixed on either http or https.
>>>>>>>>>
>>>>>>>>> Anyone who's got a working version of a BaseURLSource contribution,
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> that
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> actually can output a URL using the protocol from the initial request?
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> Regards
>>>>>>>>                 
>>>>>>>>> Inge
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <
>>>>>>>>> inge.tapestry@gmail.com
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> I know, this isn't really a problem for regular pages, they load
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> using
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>> the
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> requested protocol, when not marked as secure. But when I create
>>>>>>>>                 
>>>>>>>>>> eventlinks
>>>>>>>>>> that updates zones, these don't work when they are generated with
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> http
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>> and
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> the rest of the page is generated in https...
>>>>>>>>                 
>>>>>>>>>> What I would like to do is to try some more on the BaseURLSource
>>>>>>>>>> approach.
>>>>>>>>>> Anyone who's got any idea why this has no effect here? I copied and
>>>>>>>>>> pasted
>>>>>>>>>> the code from the T5 docs and put in my Appmodule, and the
>>>>>>>>>> contribute
>>>>>>>>>> method
>>>>>>>>>> is called on server startup. I replaced the "localhost" url with an
>>>>>>>>>> obviously bad url, for testing, but nothing happens, all pages just
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> load
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>> as
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> always, including eventlinks and actionlinks.
>>>>>>>>                 
>>>>>>>>>> Inge
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <
>>>>>>>>>> carl.crowder@taptu.com
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> I don't know if you're aware, but if you create a href something
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> like
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>> href="//something.com/page"
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> then the current protocol is maintained. So if you were viewing the
>>>>>>>>                 
>>>>>>>>>>> page
>>>>>>>>>>> at https://something.com the HREF would resolve to
>>>>>>>>>>> https://something.com/page and similarly with http. Unfortunately
>>>>>>>>>>> it
>>>>>>>>>>> requires using absolute URLs all the time.
>>>>>>>>>>>
>>>>>>>>>>> I'm not sure if that helps, but perhaps it could be used in fixing
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> that
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>> issue.
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> Carl
>>>>>>>>                 
>>>>>>>>>>> Inge Solvoll wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> Yes, I might. This is a major blow for us, our customers choose
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> freely
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>> whether they want to use http or https, so the T5 way of doing
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>>>>> things
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>> just
>>>>>>>               
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> doesn't work for us...
>>>>>>>>>>>>
>>>>>>>>>>>> On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
>>>>>>>>>>>> jonathan.theitguy@gmail.com> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> You might want to vote for this:
>>>>>>>>>>>>>
>>>>>>>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>>>>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
>>>>>>>>>>>>>> Sent: Friday, November 14, 2008 15:10
>>>>>>>>>>>>>> To: Tapestry users
>>>>>>>>>>>>>> Subject: Re: [T5] Pick up https/http from request
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thanks!
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I tried copying your code into my AppModule with some small
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> modifications.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> But the code only runs on server startup, not when I access a
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> tapestry 5
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> page. I tried to add deliberate errors in the code, like naming
>>>>>>>>>>>> the
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> server
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> loooocalhost, but I never saw the results when accessing pages.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Also, when I try to add "final HttpServletRequest request" as a
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> parameter
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> to
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> the contributeAlias method, my T5.0.13 crashes complaining about
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> service
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> recursion.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> What I need is for T5 to figure out that a user accesses a page
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> with
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>> either
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> http or https, and respond on the same protocol...
>>>>>>>>                 
>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>> Inge
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> <kb...@gmail.com>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>> wrote:
>>>>>>>               
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> I believe you might be able to use an alternation of a solution
>>>>>>>>>>>>>> I
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> used
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> for
>>>>>>>>>>>>>                           
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> getting https to work properly between my development and
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>> production
>>>>>>>>>>>>>>> servers.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public static void
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> contributeAlias(Configuration<AliasContribution>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>> configuration,
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
>>>>>>>>                 
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> String
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> production
>>>>>>>>>>>>>                           
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>  {
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>             if (0 != production.compareToIgnoreCase("true"))
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>>             {
>>>>>>>>>>>>>>>           BaseURLSource source = new BaseURLSource()
>>>>>>>>>>>>>>>           {
>>>>>>>>>>>>>>>               public String getBaseURL(boolean secure)
>>>>>>>>>>>>>>>               {
>>>>>>>>>>>>>>>                   String protocol = secure ? "https" : "http";
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                   int port = secure ? 8443 : 8080;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                   return String.format("%s://localhost:%d",
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> protocol,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> port);
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>>               }
>>>>>>>>>>>>>>>           };
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> source));
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>>             }
>>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Somehow make this dependent on the user selection and return
>>>>>>>>>>>>>>> it
>>>>>>>>>>>>>>> accordingly.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Not a quick solution but possible a direction to try!
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Keith
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  Hi!
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>>> My web application is large and consists of Struts, T4 and T5
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> pages.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> In
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> Struts and T4, I use the current http request to figure out
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> whether
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>> to
>>>>>>>               
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> use
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> https or not. Users can choose if they want to log in using
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> https
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>> or
>>>>>>>               
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> not.
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> The chosen protocol is used on all pages after login.
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>>> In T5, this is either a global static setting, or a static
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> setting
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>> per
>>>>>>>               
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> page.
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> Is there a service or something I can override to implement my
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>> own
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>> "protocol
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> builder"? Something like this:
>>>>>>>>                 
>>>>>>>>>>>>>>>> public class HttpProtocolBuilder {
>>>>>>>>>>>>>>>>  public HttpProtocolBuilder (final HttpServletRequest
>>>>>>>>>>>>>>>> request)
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>  this.request = request
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>>  }
>>>>>>>>                 
>>>>>>>>>>>>>>>>  public String getProtocol() {
>>>>>>>>>>>>>>>>  if (request.isSecure()) {
>>>>>>>>>>>>>>>>  return "https";
>>>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>>>  else {
>>>>>>>>>>>>>>>>  return "http";
>>>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Inge
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>>                               
>>>>>> ---------------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>               
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>> ---------------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>                 
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>> ---------------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>                 
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>             
>>>>>
>>>>>           
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>         
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Pick up https/http from request

Posted by Inge Solvoll <in...@gmail.com>.
Excellent! Thanks for thep help, everyone!! This has made my life so much
easier...

Got it working like this:

In my implementation of RequestSecurityManager:

  public boolean checkForInsecureRequest(String pageName) throws IOException
{
    return false;
  }

  public String getBaseURL(Page page) {
    return baseURLSource.getBaseURL(request.isSecure());
  }


In my Appmodule:

  public static void contributeAlias(Configuration<AliasContribution>
configuration, @InjectService("Request") Request request,
@InjectService("BaseURLSource") BaseURLSource baseURLSource) {
    RequestSecurityManager manager = new MyRequestSecurityManager(request,
baseURLSource);
    configuration.add(AliasContribution.create(RequestSecurityManager.class,
manager));
  }


On Wed, Nov 26, 2008 at 12:42 PM, Michael Gerzabek <michael.gerzabek@gmx.net
> wrote:

> Inge Solvoll schrieb:
>
>> Thanks, I'll look into that then.
>>
>> What I want to do:
>>
>> 1. The user accesses http://myserver.com/mypage. Should get the same
>> url/protocol in return.
>> 2. The user accesses https://myserver.com/mypage. Should get the same
>> url/protocol in return.
>>
>>
> Ok,
>
> so then forget BaseURLSource and implement RequestSecurityManager. The code
> could be something like
>
>   public boolean checkForInsecureRequest( String pageName )
>       throws IOException {
>
>       ... copy-n-paste from T5 implementation ...
>   }
>
>   public String getBaseURL( Page page ) {
>
>       return baseURLSource.getBaseURL( request.isSecure() );
>   }
>
> and get Request injected in your constructor.
>
> /Michael
>
>  As of now, the user gets a fixed protocol in return, not the protocol he
>> requested.
>>
>>
>>
>> On Wed, Nov 26, 2008 at 12:29 PM, Michael Gerzabek <
>> michael.gerzabek@gmx.net
>>
>>
>>> wrote:
>>>
>>>
>>
>>
>>
>>> Inge,
>>>
>>> not sure that I undestand fully what you are about. It sounds like you
>>> also
>>> want to implement RequestSecurityManager (
>>>
>>> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/internal/services/package-tree.html
>>> ).
>>> This is at least what I did and it works for me.
>>>
>>> /Michael
>>>
>>> Inge Solvoll schrieb:
>>>
>>>  I think I know the reason for the loop...
>>>
>>>
>>>> my getBaseURL method is only called when the requested url has a
>>>> different
>>>> protocol than specified in MetaDataConstants.SECURE_PAGE. It seems that
>>>> when
>>>> I try to write a base URL in my custom method that has a different
>>>> protocol
>>>> than SECURE_PAGE value, they start knocking each other's heades with
>>>> redirects.
>>>>
>>>> Right now, it looks like this system works differently than I thought.
>>>> Is
>>>> it
>>>> not possible to override the behaviour of one page or entire application
>>>> fixed on a protocol?
>>>>
>>>>
>>>>
>>>> On Wed, Nov 26, 2008 at 11:44 AM, Kristian Marinkovic <
>>>> kristian.marinkovic@porsche.co.at> wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> try creating the proxy manually... almost worked every time for me
>>>>>
>>>>> constructor injection will be performed as expected
>>>>>
>>>>> public static void contributeAlias(
>>>>>  ObjectLocator locator,
>>>>>   Configuration<AliasContribution> configuration ) {
>>>>>
>>>>>  configuration.add( AliasContribution.create(
>>>>>         BaseURLSource.class,
>>>>>          locator.proxy(BaseURLSource.class,SomeImplementation.class) );
>>>>>
>>>>>  }
>>>>>
>>>>> g,
>>>>> kris
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> "Inge Solvoll" <in...@gmail.com>
>>>>> 26.11.2008 11:37
>>>>> Bitte antworten an
>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>
>>>>>
>>>>> An
>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>> Kopie
>>>>>
>>>>> Thema
>>>>> Re: [T5] Pick up https/http from request
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Thanks!
>>>>>
>>>>> But this still gives me the same loop error, because I have to inject
>>>>> Request (where you inject SiteServices) into the builder method to
>>>>> access
>>>>> the secure state of the request:
>>>>>
>>>>> Caused by: org.apache.tapestry5.ioc.internal.OperationException:
>>>>> Construction of service 'Alias' has failed due to recursion: the
>>>>> service
>>>>> depends on itself in some way. Please check
>>>>> org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, String,
>>>>> AliasManager, Collection) (at TapestryModule.java:214) for references
>>>>> to
>>>>> another service that is itself dependent on service 'Alias'.
>>>>>
>>>>> Inge
>>>>>
>>>>> On Wed, Nov 26, 2008 at 11:28 AM, Michael Gerzabek
>>>>> <michael.gerzabek@gmx.net
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> wrote:
>>>>>>     Inge,
>>>>>>
>>>>>> I did it successfully for a similar purpose:
>>>>>>
>>>>>>  @SuppressWarnings("unchecked")
>>>>>>  public static void contributeAlias(
>>>>>>     @InjectService( "SiteBaseURLSource" )
>>>>>>     BaseURLSource baseUrlSource,
>>>>>>     Configuration<AliasContribution> configuration ) {
>>>>>>
>>>>>>     configuration.add( AliasContribution.create(
>>>>>>         BaseURLSource.class,
>>>>>>         baseUrlSource ) );
>>>>>>
>>>>>>  }
>>>>>>
>>>>>> Don't use the binder but create your own build method:
>>>>>>
>>>>>>  @Marker( SiteServices.class )
>>>>>>  public static BaseURLSource buildSiteBaseURLSource(
>>>>>>     @SiteServices
>>>>>>     SiteService site ) {
>>>>>>
>>>>>>     return new SiteBaseURLSource( site );
>>>>>>  }
>>>>>>
>>>>>> You can ommit the Marker annotation.
>>>>>>
>>>>>> /Michael
>>>>>>
>>>>>> Solvoll schrieb:
>>>>>>
>>>>>>  Hi!
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> I'm really struggling here as I think I'm approaching a solution.
>>>>>>> What
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> I'm
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>> trying to do is to override/decorate/alias/replace the BaseURLSource
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>> with
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>> my
>>>>>>
>>>>>>
>>>>>>> own implementation, like this:
>>>>>>>
>>>>>>> public class MyBaseURLSource implements BaseURLSource {
>>>>>>>
>>>>>>>  private final Request request;
>>>>>>>
>>>>>>>  public MyBaseURLSource(Request request) {
>>>>>>>  this.request = request;
>>>>>>>  }
>>>>>>>
>>>>>>>  public String getBaseURL(boolean secure) {
>>>>>>>  boolean secureRequest = request.isSecure();
>>>>>>>  String baseURL = String.format("%s://%s", secureRequest ? "https" :
>>>>>>> "http", request.getServerName());
>>>>>>>  return baseURL;
>>>>>>>  }
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> Essentially, I've copied the default implementation and replaced the
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> usage
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>> of the secure parameter with the secure value of the request. My
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>> problem
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>> is
>>>>>>
>>>>>>
>>>>>>> that I'm not capable of putting this code to actual work in the
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> framework.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>> I've tried:
>>>>>>
>>>>>>
>>>>>>> - aliasing, but that didn't work because of circular dependency (I
>>>>>>> have
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> to
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>> inject the Request)
>>>>>>
>>>>>>
>>>>>>> - binder.bind(BaseURLSource.class, MyBaseURLSource.class), combinded
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> with
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>> a
>>>>>>
>>>>>>
>>>>>>> builder for MyBaseURLSource. Causes redirect loop.
>>>>>>> - Decorating. Not managed to find out how I do this yet, have tried a
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> few
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>> things.
>>>>>>
>>>>>>
>>>>>>> I'm guessing this is rather simple, it's just a bit complicated when
>>>>>>> you're
>>>>>>> not experienced in IoC... Anyone who wants to point me in the right
>>>>>>> direction?
>>>>>>>
>>>>>>> Regards
>>>>>>> Inge
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Nov 19, 2008 at 10:22 AM, Inge Solvoll <
>>>>>>> inge.tapestry@gmail.com
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> I voted for this issue now.
>>>>>>>>
>>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>>>
>>>>>>>> This is really a big issue for our usage of T5, T5 is now forcing us
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> to
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>> redirect users away from http access, because we no longer can support
>>>>>>
>>>>>>
>>>>>>> both
>>>>>>>> modes as long as T5 is fixed on either http or https.
>>>>>>>>
>>>>>>>> Anyone who's got a working version of a BaseURLSource contribution,
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> that
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>> actually can output a URL using the protocol from the initial request?
>>>>>>
>>>>>>
>>>>>>> Regards
>>>>>>>> Inge
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <
>>>>>>>> inge.tapestry@gmail.com
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> I know, this isn't really a problem for regular pages, they load
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> using
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>>>>> the
>>>>>>
>>>>>>
>>>>>>> requested protocol, when not marked as secure. But when I create
>>>>>>>>> eventlinks
>>>>>>>>> that updates zones, these don't work when they are generated with
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> http
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>>>>> and
>>>>>>
>>>>>>
>>>>>>> the rest of the page is generated in https...
>>>>>>>>>
>>>>>>>>> What I would like to do is to try some more on the BaseURLSource
>>>>>>>>> approach.
>>>>>>>>> Anyone who's got any idea why this has no effect here? I copied and
>>>>>>>>> pasted
>>>>>>>>> the code from the T5 docs and put in my Appmodule, and the
>>>>>>>>> contribute
>>>>>>>>> method
>>>>>>>>> is called on server startup. I replaced the "localhost" url with an
>>>>>>>>> obviously bad url, for testing, but nothing happens, all pages just
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> load
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>>>>> as
>>>>>>
>>>>>>
>>>>>>> always, including eventlinks and actionlinks.
>>>>>>>>>
>>>>>>>>> Inge
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <
>>>>>>>>> carl.crowder@taptu.com
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> I don't know if you're aware, but if you create a href something
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> like
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>
>>>>>> href="//something.com/page"
>>>>>>
>>>>>>
>>>>>>> then the current protocol is maintained. So if you were viewing the
>>>>>>>>>> page
>>>>>>>>>> at https://something.com the HREF would resolve to
>>>>>>>>>> https://something.com/page and similarly with http. Unfortunately
>>>>>>>>>> it
>>>>>>>>>> requires using absolute URLs all the time.
>>>>>>>>>>
>>>>>>>>>> I'm not sure if that helps, but perhaps it could be used in fixing
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> that
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>
>>>>>> issue.
>>>>>>
>>>>>>
>>>>>>> Carl
>>>>>>>>>>
>>>>>>>>>> Inge Solvoll wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> Yes, I might. This is a major blow for us, our customers choose
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> freely
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>
>>>>>> whether they want to use http or https, so the T5 way of doing
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> things
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>
>>>>>> just
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> doesn't work for us...
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
>>>>>>>>>>> jonathan.theitguy@gmail.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> You might want to vote for this:
>>>>>>>>>>>>
>>>>>>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>>>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
>>>>>>>>>>>>> Sent: Friday, November 14, 2008 15:10
>>>>>>>>>>>>> To: Tapestry users
>>>>>>>>>>>>> Subject: Re: [T5] Pick up https/http from request
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks!
>>>>>>>>>>>>>
>>>>>>>>>>>>> I tried copying your code into my AppModule with some small
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> modifications.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> But the code only runs on server startup, not when I access a
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> tapestry 5
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> page. I tried to add deliberate errors in the code, like naming
>>>>>>>>>>> the
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> server
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> loooocalhost, but I never saw the results when accessing pages.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Also, when I try to add "final HttpServletRequest request" as a
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> parameter
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> to
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> the contributeAlias method, my T5.0.13 crashes complaining about
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> service
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> recursion.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> What I need is for T5 to figure out that a user accesses a page
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> with
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>
>>>>>> either
>>>>>>
>>>>>>
>>>>>>> http or https, and respond on the same protocol...
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Regards
>>>>>>>>>>>>> Inge
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> <kb...@gmail.com>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>
>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> I believe you might be able to use an alternation of a solution
>>>>>>>>>>>>> I
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> used
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> for
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> getting https to work properly between my development and
>>>>>>>>>>>>>> production
>>>>>>>>>>>>>> servers.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> public static void
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> contributeAlias(Configuration<AliasContribution>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>
>>>>>> configuration,
>>>>>>
>>>>>>
>>>>>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> String
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> production
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>  {
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>>             if (0 != production.compareToIgnoreCase("true"))
>>>>>>>>>>>>>>             {
>>>>>>>>>>>>>>           BaseURLSource source = new BaseURLSource()
>>>>>>>>>>>>>>           {
>>>>>>>>>>>>>>               public String getBaseURL(boolean secure)
>>>>>>>>>>>>>>               {
>>>>>>>>>>>>>>                   String protocol = secure ? "https" : "http";
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                   int port = secure ? 8443 : 8080;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                   return String.format("%s://localhost:%d",
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> protocol,
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> port);
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>               }
>>>>>>>>>>>>>>           };
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> source));
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>             }
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Somehow make this dependent on the user selection and return
>>>>>>>>>>>>>> it
>>>>>>>>>>>>>> accordingly.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Not a quick solution but possible a direction to try!
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Keith
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  Hi!
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> My web application is large and consists of Struts, T4 and T5
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>> pages.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> In
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> Struts and T4, I use the current http request to figure out
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> whether
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>
>>>>>> to
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> use
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> https or not. Users can choose if they want to log in using
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> https
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>
>>>>>> or
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> not.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> The chosen protocol is used on all pages after login.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> In T5, this is either a global static setting, or a static
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>> setting
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>
>>>>>> per
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> page.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> Is there a service or something I can override to implement my
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>> own
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>
>>>>>> "protocol
>>>>>>
>>>>>>
>>>>>>> builder"? Something like this:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public class HttpProtocolBuilder {
>>>>>>>>>>>>>>>  public HttpProtocolBuilder (final HttpServletRequest
>>>>>>>>>>>>>>> request)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>
>>>>>>  this.request = request
>>>>>>
>>>>>>
>>>>>>>  }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  public String getProtocol() {
>>>>>>>>>>>>>>>  if (request.isSecure()) {
>>>>>>>>>>>>>>>  return "https";
>>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>>  else {
>>>>>>>>>>>>>>>  return "http";
>>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Inge
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: [T5] Pick up https/http from request

Posted by Michael Gerzabek <mi...@gmx.net>.
Inge Solvoll schrieb:
> Thanks, I'll look into that then.
>
> What I want to do:
>
> 1. The user accesses http://myserver.com/mypage. Should get the same
> url/protocol in return.
> 2. The user accesses https://myserver.com/mypage. Should get the same
> url/protocol in return.
>   
Ok,

so then forget BaseURLSource and implement RequestSecurityManager. The 
code could be something like

    public boolean checkForInsecureRequest( String pageName )
        throws IOException {

        ... copy-n-paste from T5 implementation ...
    }

    public String getBaseURL( Page page ) {

        return baseURLSource.getBaseURL( request.isSecure() );
    }

and get Request injected in your constructor.

/Michael
> As of now, the user gets a fixed protocol in return, not the protocol he
> requested.
>
>
>
> On Wed, Nov 26, 2008 at 12:29 PM, Michael Gerzabek <michael.gerzabek@gmx.net
>   
>> wrote:
>>     
>
>   
>> Inge,
>>
>> not sure that I undestand fully what you are about. It sounds like you also
>> want to implement RequestSecurityManager (
>> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/internal/services/package-tree.html).
>> This is at least what I did and it works for me.
>>
>> /Michael
>>
>> Inge Solvoll schrieb:
>>
>>  I think I know the reason for the loop...
>>     
>>> my getBaseURL method is only called when the requested url has a different
>>> protocol than specified in MetaDataConstants.SECURE_PAGE. It seems that
>>> when
>>> I try to write a base URL in my custom method that has a different
>>> protocol
>>> than SECURE_PAGE value, they start knocking each other's heades with
>>> redirects.
>>>
>>> Right now, it looks like this system works differently than I thought. Is
>>> it
>>> not possible to override the behaviour of one page or entire application
>>> fixed on a protocol?
>>>
>>>
>>>
>>> On Wed, Nov 26, 2008 at 11:44 AM, Kristian Marinkovic <
>>> kristian.marinkovic@porsche.co.at> wrote:
>>>
>>>
>>>
>>>       
>>>> try creating the proxy manually... almost worked every time for me
>>>>
>>>> constructor injection will be performed as expected
>>>>
>>>> public static void contributeAlias(
>>>>   ObjectLocator locator,
>>>>    Configuration<AliasContribution> configuration ) {
>>>>
>>>>   configuration.add( AliasContribution.create(
>>>>          BaseURLSource.class,
>>>>           locator.proxy(BaseURLSource.class,SomeImplementation.class) );
>>>>
>>>>  }
>>>>
>>>> g,
>>>> kris
>>>>
>>>>
>>>>
>>>>
>>>> "Inge Solvoll" <in...@gmail.com>
>>>> 26.11.2008 11:37
>>>> Bitte antworten an
>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>
>>>>
>>>> An
>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>> Kopie
>>>>
>>>> Thema
>>>> Re: [T5] Pick up https/http from request
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Thanks!
>>>>
>>>> But this still gives me the same loop error, because I have to inject
>>>> Request (where you inject SiteServices) into the builder method to access
>>>> the secure state of the request:
>>>>
>>>> Caused by: org.apache.tapestry5.ioc.internal.OperationException:
>>>> Construction of service 'Alias' has failed due to recursion: the service
>>>> depends on itself in some way. Please check
>>>> org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, String,
>>>> AliasManager, Collection) (at TapestryModule.java:214) for references to
>>>> another service that is itself dependent on service 'Alias'.
>>>>
>>>> Inge
>>>>
>>>> On Wed, Nov 26, 2008 at 11:28 AM, Michael Gerzabek
>>>> <michael.gerzabek@gmx.net
>>>>
>>>>
>>>>         
>>>>> wrote:
>>>>>      Inge,
>>>>>
>>>>> I did it successfully for a similar purpose:
>>>>>
>>>>>  @SuppressWarnings("unchecked")
>>>>>  public static void contributeAlias(
>>>>>      @InjectService( "SiteBaseURLSource" )
>>>>>      BaseURLSource baseUrlSource,
>>>>>      Configuration<AliasContribution> configuration ) {
>>>>>
>>>>>      configuration.add( AliasContribution.create(
>>>>>          BaseURLSource.class,
>>>>>          baseUrlSource ) );
>>>>>
>>>>>  }
>>>>>
>>>>> Don't use the binder but create your own build method:
>>>>>
>>>>>  @Marker( SiteServices.class )
>>>>>  public static BaseURLSource buildSiteBaseURLSource(
>>>>>      @SiteServices
>>>>>      SiteService site ) {
>>>>>
>>>>>      return new SiteBaseURLSource( site );
>>>>>  }
>>>>>
>>>>> You can ommit the Marker annotation.
>>>>>
>>>>> /Michael
>>>>>
>>>>> Solvoll schrieb:
>>>>>
>>>>>  Hi!
>>>>>
>>>>>
>>>>>           
>>>>>> I'm really struggling here as I think I'm approaching a solution. What
>>>>>>
>>>>>>
>>>>>>             
>>>>> I'm
>>>>>           
>>>>         
>>>>> trying to do is to override/decorate/alias/replace the BaseURLSource
>>>>>           
>>>>>>             
>>>>> with
>>>>>           
>>>>         
>>>>> my
>>>>>           
>>>>>> own implementation, like this:
>>>>>>
>>>>>> public class MyBaseURLSource implements BaseURLSource {
>>>>>>
>>>>>>  private final Request request;
>>>>>>
>>>>>>  public MyBaseURLSource(Request request) {
>>>>>>   this.request = request;
>>>>>>  }
>>>>>>
>>>>>>  public String getBaseURL(boolean secure) {
>>>>>>   boolean secureRequest = request.isSecure();
>>>>>>   String baseURL = String.format("%s://%s", secureRequest ? "https" :
>>>>>> "http", request.getServerName());
>>>>>>   return baseURL;
>>>>>>  }
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>> Essentially, I've copied the default implementation and replaced the
>>>>>>
>>>>>>
>>>>>>             
>>>>> usage
>>>>>           
>>>>         
>>>>> of the secure parameter with the secure value of the request. My
>>>>>           
>>>>>>             
>>>>> problem
>>>>>           
>>>>         
>>>>> is
>>>>>           
>>>>>> that I'm not capable of putting this code to actual work in the
>>>>>>
>>>>>>
>>>>>>             
>>>>> framework.
>>>>>           
>>>>         
>>>>> I've tried:
>>>>>           
>>>>>> - aliasing, but that didn't work because of circular dependency (I have
>>>>>>
>>>>>>
>>>>>>             
>>>>> to
>>>>>           
>>>>         
>>>>> inject the Request)
>>>>>           
>>>>>> - binder.bind(BaseURLSource.class, MyBaseURLSource.class), combinded
>>>>>>
>>>>>>
>>>>>>             
>>>>> with
>>>>>           
>>>>         
>>>>> a
>>>>>           
>>>>>> builder for MyBaseURLSource. Causes redirect loop.
>>>>>> - Decorating. Not managed to find out how I do this yet, have tried a
>>>>>>
>>>>>>
>>>>>>             
>>>>> few
>>>>>           
>>>>         
>>>>> things.
>>>>>           
>>>>>> I'm guessing this is rather simple, it's just a bit complicated when
>>>>>> you're
>>>>>> not experienced in IoC... Anyone who wants to point me in the right
>>>>>> direction?
>>>>>>
>>>>>> Regards
>>>>>> Inge
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Nov 19, 2008 at 10:22 AM, Inge Solvoll <
>>>>>> inge.tapestry@gmail.com
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> wrote:
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>
>>>>>>             
>>>>>>> I voted for this issue now.
>>>>>>>
>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>>
>>>>>>> This is really a big issue for our usage of T5, T5 is now forcing us
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>> to
>>>>>>             
>>>>         
>>>>> redirect users away from http access, because we no longer can support
>>>>>           
>>>>>>> both
>>>>>>> modes as long as T5 is fixed on either http or https.
>>>>>>>
>>>>>>> Anyone who's got a working version of a BaseURLSource contribution,
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>> that
>>>>>>             
>>>>         
>>>>> actually can output a URL using the protocol from the initial request?
>>>>>           
>>>>>>> Regards
>>>>>>> Inge
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <
>>>>>>> inge.tapestry@gmail.com
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>
>>>>>>>               
>>>>>>>> I know, this isn't really a problem for regular pages, they load
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> using
>>>>>>>               
>>>>         
>>>>> the
>>>>>           
>>>>>>>> requested protocol, when not marked as secure. But when I create
>>>>>>>> eventlinks
>>>>>>>> that updates zones, these don't work when they are generated with
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> http
>>>>>>>               
>>>>         
>>>>> and
>>>>>           
>>>>>>>> the rest of the page is generated in https...
>>>>>>>>
>>>>>>>> What I would like to do is to try some more on the BaseURLSource
>>>>>>>> approach.
>>>>>>>> Anyone who's got any idea why this has no effect here? I copied and
>>>>>>>> pasted
>>>>>>>> the code from the T5 docs and put in my Appmodule, and the contribute
>>>>>>>> method
>>>>>>>> is called on server startup. I replaced the "localhost" url with an
>>>>>>>> obviously bad url, for testing, but nothing happens, all pages just
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> load
>>>>>>>               
>>>>         
>>>>> as
>>>>>           
>>>>>>>> always, including eventlinks and actionlinks.
>>>>>>>>
>>>>>>>> Inge
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <
>>>>>>>> carl.crowder@taptu.com
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> I don't know if you're aware, but if you create a href something
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> like
>>>>>>>>                 
>>>>         
>>>>> href="//something.com/page"
>>>>>           
>>>>>>>>> then the current protocol is maintained. So if you were viewing the
>>>>>>>>> page
>>>>>>>>> at https://something.com the HREF would resolve to
>>>>>>>>> https://something.com/page and similarly with http. Unfortunately
>>>>>>>>> it
>>>>>>>>> requires using absolute URLs all the time.
>>>>>>>>>
>>>>>>>>> I'm not sure if that helps, but perhaps it could be used in fixing
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> that
>>>>>>>>                 
>>>>         
>>>>> issue.
>>>>>           
>>>>>>>>> Carl
>>>>>>>>>
>>>>>>>>> Inge Solvoll wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> Yes, I might. This is a major blow for us, our customers choose
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> freely
>>>>>>>>>                   
>>>>         
>>>>> whether they want to use http or https, so the T5 way of doing
>>>>>           
>>>>>>>>>>                     
>>>>>>>>> things
>>>>>>>>>                   
>>>>         
>>>>>>>>> just
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> doesn't work for us...
>>>>>>>>>>
>>>>>>>>>> On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
>>>>>>>>>> jonathan.theitguy@gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> You might want to vote for this:
>>>>>>>>>>>
>>>>>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
>>>>>>>>>>>> Sent: Friday, November 14, 2008 15:10
>>>>>>>>>>>> To: Tapestry users
>>>>>>>>>>>> Subject: Re: [T5] Pick up https/http from request
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks!
>>>>>>>>>>>>
>>>>>>>>>>>> I tried copying your code into my AppModule with some small
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> modifications.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> But the code only runs on server startup, not when I access a
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> tapestry 5
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> page. I tried to add deliberate errors in the code, like naming the
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> server
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> loooocalhost, but I never saw the results when accessing pages.
>>>>>>>>>>>>
>>>>>>>>>>>> Also, when I try to add "final HttpServletRequest request" as a
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> parameter
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> to
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> the contributeAlias method, my T5.0.13 crashes complaining about
>>>>>>>>>>>                       
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> service
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> recursion.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> What I need is for T5 to figure out that a user accesses a page
>>>>>>>>>>>                       
>>>>>>>>>>>>                         
>>>>>>>>>>> with
>>>>>>>>>>>                       
>>>>         
>>>>> either
>>>>>           
>>>>>>>>>>>> http or https, and respond on the same protocol...
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Regards
>>>>>>>>>>>> Inge
>>>>>>>>>>>>
>>>>>>>>>>>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> <kb...@gmail.com>
>>>>>>>>>>>                       
>>>>         
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> I believe you might be able to use an alternation of a solution I
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>                           
>>>>>>>>>>>> used
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>> for
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>>> getting https to work properly between my development and
>>>>>>>>>>>>> production
>>>>>>>>>>>>> servers.
>>>>>>>>>>>>>
>>>>>>>>>>>>> public static void
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> contributeAlias(Configuration<AliasContribution>
>>>>>>>>>>>>                         
>>>>         
>>>>> configuration,
>>>>>           
>>>>>>>>>>>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> String
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>> production
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>  {
>>>>>>>>>>>                       
>>>>>>>>>>>>>              if (0 != production.compareToIgnoreCase("true"))
>>>>>>>>>>>>>              {
>>>>>>>>>>>>>            BaseURLSource source = new BaseURLSource()
>>>>>>>>>>>>>            {
>>>>>>>>>>>>>                public String getBaseURL(boolean secure)
>>>>>>>>>>>>>                {
>>>>>>>>>>>>>                    String protocol = secure ? "https" : "http";
>>>>>>>>>>>>>
>>>>>>>>>>>>>                    int port = secure ? 8443 : 8080;
>>>>>>>>>>>>>
>>>>>>>>>>>>>                    return String.format("%s://localhost:%d",
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> protocol,
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>                       
>>>>>>>>>>>> port);
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>                }
>>>>>>>>>>>>>            };
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> source));
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>              }
>>>>>>>>>>>>>  }
>>>>>>>>>>>>>
>>>>>>>>>>>>> Somehow make this dependent on the user selection and return it
>>>>>>>>>>>>> accordingly.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Not a quick solution but possible a direction to try!
>>>>>>>>>>>>>
>>>>>>>>>>>>> Keith
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>  Hi!
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> My web application is large and consists of Struts, T4 and T5
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> pages.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>> In
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>                       
>>>>>>>>>>>> Struts and T4, I use the current http request to figure out
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> whether
>>>>>>>>>>>                       
>>>>         
>>>>>>>>>>>>> to
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>> use
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>>> https or not. Users can choose if they want to log in using
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> https
>>>>>>>>>>>>                         
>>>>         
>>>>>>>>>>>>> or
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>> not.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>>> The chosen protocol is used on all pages after login.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> In T5, this is either a global static setting, or a static
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> setting
>>>>>>>>>>>>>                           
>>>>         
>>>>>>>>>>>>> per
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>> page.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> Is there a service or something I can override to implement my
>>>>>>>>>>>                       
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> own
>>>>>>>>>>>>>                           
>>>>         
>>>>> "protocol
>>>>>           
>>>>>>>>>>>>>> builder"? Something like this:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> public class HttpProtocolBuilder {
>>>>>>>>>>>>>>  public HttpProtocolBuilder (final HttpServletRequest request)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> {
>>>>>>>>>>>>>                           
>>>>         
>>>>>  this.request = request
>>>>>           
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  public String getProtocol() {
>>>>>>>>>>>>>>  if (request.isSecure()) {
>>>>>>>>>>>>>>   return "https";
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>  else {
>>>>>>>>>>>>>>  return "http";
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Inge
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>                           
>>>> ---------------------------------------------------------------------
>>>>
>>>>
>>>>         
>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>>>                       
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>> ---------------------------------------------------------------------
>>>>
>>>>
>>>>         
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>           
>>>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>> ---------------------------------------------------------------------
>>>>
>>>>
>>>>         
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>           
>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>           
>>>>         
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Pick up https/http from request

Posted by Inge Solvoll <in...@gmail.com>.
Thanks, I'll look into that then.

What I want to do:

1. The user accesses http://myserver.com/mypage. Should get the same
url/protocol in return.
2. The user accesses https://myserver.com/mypage. Should get the same
url/protocol in return.

As of now, the user gets a fixed protocol in return, not the protocol he
requested.



On Wed, Nov 26, 2008 at 12:29 PM, Michael Gerzabek <michael.gerzabek@gmx.net
> wrote:

> Inge,
>
> not sure that I undestand fully what you are about. It sounds like you also
> want to implement RequestSecurityManager (
> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/internal/services/package-tree.html).
> This is at least what I did and it works for me.
>
> /Michael
>
> Inge Solvoll schrieb:
>
>  I think I know the reason for the loop...
>>
>> my getBaseURL method is only called when the requested url has a different
>> protocol than specified in MetaDataConstants.SECURE_PAGE. It seems that
>> when
>> I try to write a base URL in my custom method that has a different
>> protocol
>> than SECURE_PAGE value, they start knocking each other's heades with
>> redirects.
>>
>> Right now, it looks like this system works differently than I thought. Is
>> it
>> not possible to override the behaviour of one page or entire application
>> fixed on a protocol?
>>
>>
>>
>> On Wed, Nov 26, 2008 at 11:44 AM, Kristian Marinkovic <
>> kristian.marinkovic@porsche.co.at> wrote:
>>
>>
>>
>>> try creating the proxy manually... almost worked every time for me
>>>
>>> constructor injection will be performed as expected
>>>
>>> public static void contributeAlias(
>>>   ObjectLocator locator,
>>>    Configuration<AliasContribution> configuration ) {
>>>
>>>   configuration.add( AliasContribution.create(
>>>          BaseURLSource.class,
>>>           locator.proxy(BaseURLSource.class,SomeImplementation.class) );
>>>
>>>  }
>>>
>>> g,
>>> kris
>>>
>>>
>>>
>>>
>>> "Inge Solvoll" <in...@gmail.com>
>>> 26.11.2008 11:37
>>> Bitte antworten an
>>> "Tapestry users" <us...@tapestry.apache.org>
>>>
>>>
>>> An
>>> "Tapestry users" <us...@tapestry.apache.org>
>>> Kopie
>>>
>>> Thema
>>> Re: [T5] Pick up https/http from request
>>>
>>>
>>>
>>>
>>>
>>>
>>> Thanks!
>>>
>>> But this still gives me the same loop error, because I have to inject
>>> Request (where you inject SiteServices) into the builder method to access
>>> the secure state of the request:
>>>
>>> Caused by: org.apache.tapestry5.ioc.internal.OperationException:
>>> Construction of service 'Alias' has failed due to recursion: the service
>>> depends on itself in some way. Please check
>>> org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, String,
>>> AliasManager, Collection) (at TapestryModule.java:214) for references to
>>> another service that is itself dependent on service 'Alias'.
>>>
>>> Inge
>>>
>>> On Wed, Nov 26, 2008 at 11:28 AM, Michael Gerzabek
>>> <michael.gerzabek@gmx.net
>>>
>>>
>>>> wrote:
>>>>      Inge,
>>>>
>>>> I did it successfully for a similar purpose:
>>>>
>>>>  @SuppressWarnings("unchecked")
>>>>  public static void contributeAlias(
>>>>      @InjectService( "SiteBaseURLSource" )
>>>>      BaseURLSource baseUrlSource,
>>>>      Configuration<AliasContribution> configuration ) {
>>>>
>>>>      configuration.add( AliasContribution.create(
>>>>          BaseURLSource.class,
>>>>          baseUrlSource ) );
>>>>
>>>>  }
>>>>
>>>> Don't use the binder but create your own build method:
>>>>
>>>>  @Marker( SiteServices.class )
>>>>  public static BaseURLSource buildSiteBaseURLSource(
>>>>      @SiteServices
>>>>      SiteService site ) {
>>>>
>>>>      return new SiteBaseURLSource( site );
>>>>  }
>>>>
>>>> You can ommit the Marker annotation.
>>>>
>>>> /Michael
>>>>
>>>> Solvoll schrieb:
>>>>
>>>>  Hi!
>>>>
>>>>
>>>>> I'm really struggling here as I think I'm approaching a solution. What
>>>>>
>>>>>
>>>> I'm
>>>
>>>
>>>> trying to do is to override/decorate/alias/replace the BaseURLSource
>>>>>
>>>>>
>>>> with
>>>
>>>
>>>> my
>>>>> own implementation, like this:
>>>>>
>>>>> public class MyBaseURLSource implements BaseURLSource {
>>>>>
>>>>>  private final Request request;
>>>>>
>>>>>  public MyBaseURLSource(Request request) {
>>>>>   this.request = request;
>>>>>  }
>>>>>
>>>>>  public String getBaseURL(boolean secure) {
>>>>>   boolean secureRequest = request.isSecure();
>>>>>   String baseURL = String.format("%s://%s", secureRequest ? "https" :
>>>>> "http", request.getServerName());
>>>>>   return baseURL;
>>>>>  }
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>> Essentially, I've copied the default implementation and replaced the
>>>>>
>>>>>
>>>> usage
>>>
>>>
>>>> of the secure parameter with the secure value of the request. My
>>>>>
>>>>>
>>>> problem
>>>
>>>
>>>> is
>>>>> that I'm not capable of putting this code to actual work in the
>>>>>
>>>>>
>>>> framework.
>>>
>>>
>>>> I've tried:
>>>>> - aliasing, but that didn't work because of circular dependency (I have
>>>>>
>>>>>
>>>> to
>>>
>>>
>>>> inject the Request)
>>>>> - binder.bind(BaseURLSource.class, MyBaseURLSource.class), combinded
>>>>>
>>>>>
>>>> with
>>>
>>>
>>>> a
>>>>> builder for MyBaseURLSource. Causes redirect loop.
>>>>> - Decorating. Not managed to find out how I do this yet, have tried a
>>>>>
>>>>>
>>>> few
>>>
>>>
>>>> things.
>>>>>
>>>>> I'm guessing this is rather simple, it's just a bit complicated when
>>>>> you're
>>>>> not experienced in IoC... Anyone who wants to point me in the right
>>>>> direction?
>>>>>
>>>>> Regards
>>>>> Inge
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Nov 19, 2008 at 10:22 AM, Inge Solvoll <
>>>>> inge.tapestry@gmail.com
>>>>>
>>>>>
>>>>>> wrote:
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> I voted for this issue now.
>>>>>>
>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>
>>>>>> This is really a big issue for our usage of T5, T5 is now forcing us
>>>>>>
>>>>>>
>>>>> to
>>>
>>>
>>>> redirect users away from http access, because we no longer can support
>>>>>> both
>>>>>> modes as long as T5 is fixed on either http or https.
>>>>>>
>>>>>> Anyone who's got a working version of a BaseURLSource contribution,
>>>>>>
>>>>>>
>>>>> that
>>>
>>>
>>>> actually can output a URL using the protocol from the initial request?
>>>>>>
>>>>>> Regards
>>>>>> Inge
>>>>>>
>>>>>>
>>>>>> On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <
>>>>>> inge.tapestry@gmail.com
>>>>>>
>>>>>>
>>>>>>> wrote:
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> I know, this isn't really a problem for regular pages, they load
>>>>>>>
>>>>>>>
>>>>>> using
>>>
>>>
>>>> the
>>>>>>> requested protocol, when not marked as secure. But when I create
>>>>>>> eventlinks
>>>>>>> that updates zones, these don't work when they are generated with
>>>>>>>
>>>>>>>
>>>>>> http
>>>
>>>
>>>> and
>>>>>>> the rest of the page is generated in https...
>>>>>>>
>>>>>>> What I would like to do is to try some more on the BaseURLSource
>>>>>>> approach.
>>>>>>> Anyone who's got any idea why this has no effect here? I copied and
>>>>>>> pasted
>>>>>>> the code from the T5 docs and put in my Appmodule, and the contribute
>>>>>>> method
>>>>>>> is called on server startup. I replaced the "localhost" url with an
>>>>>>> obviously bad url, for testing, but nothing happens, all pages just
>>>>>>>
>>>>>>>
>>>>>> load
>>>
>>>
>>>> as
>>>>>>> always, including eventlinks and actionlinks.
>>>>>>>
>>>>>>> Inge
>>>>>>>
>>>>>>>
>>>>>>> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <
>>>>>>> carl.crowder@taptu.com
>>>>>>>
>>>>>>>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> I don't know if you're aware, but if you create a href something
>>>>>>>>
>>>>>>>>
>>>>>>> like
>>>
>>>
>>>> href="//something.com/page"
>>>>>>>>
>>>>>>>> then the current protocol is maintained. So if you were viewing the
>>>>>>>> page
>>>>>>>> at https://something.com the HREF would resolve to
>>>>>>>> https://something.com/page and similarly with http. Unfortunately
>>>>>>>> it
>>>>>>>> requires using absolute URLs all the time.
>>>>>>>>
>>>>>>>> I'm not sure if that helps, but perhaps it could be used in fixing
>>>>>>>>
>>>>>>>>
>>>>>>> that
>>>
>>>
>>>> issue.
>>>>>>>>
>>>>>>>> Carl
>>>>>>>>
>>>>>>>> Inge Solvoll wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Yes, I might. This is a major blow for us, our customers choose
>>>>>>>>>
>>>>>>>>>
>>>>>>>> freely
>>>
>>>
>>>> whether they want to use http or https, so the T5 way of doing
>>>>>>>>>
>>>>>>>>>
>>>>>>>> things
>>>
>>>
>>>>
>>>>>>>>>
>>>>>>>> just
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> doesn't work for us...
>>>>>>>>>
>>>>>>>>> On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
>>>>>>>>> jonathan.theitguy@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> You might want to vote for this:
>>>>>>>>>>
>>>>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> -----Original Message-----
>>>>>>>>>>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
>>>>>>>>>>> Sent: Friday, November 14, 2008 15:10
>>>>>>>>>>> To: Tapestry users
>>>>>>>>>>> Subject: Re: [T5] Pick up https/http from request
>>>>>>>>>>>
>>>>>>>>>>> Thanks!
>>>>>>>>>>>
>>>>>>>>>>> I tried copying your code into my AppModule with some small
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> modifications.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> But the code only runs on server startup, not when I access a
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> tapestry 5
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>> page. I tried to add deliberate errors in the code, like naming the
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> server
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> loooocalhost, but I never saw the results when accessing pages.
>>>>>>>>>>>
>>>>>>>>>>> Also, when I try to add "final HttpServletRequest request" as a
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> parameter
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>> to
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> the contributeAlias method, my T5.0.13 crashes complaining about
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> service
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>> recursion.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> What I need is for T5 to figure out that a user accesses a page
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> with
>>>
>>>
>>>> either
>>>>>>>>>>> http or https, and respond on the same protocol...
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Regards
>>>>>>>>>>> Inge
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> <kb...@gmail.com>
>>>
>>>
>>>>
>>>>>>>>>>>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> I believe you might be able to use an alternation of a solution I
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> used
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>>>> for
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> getting https to work properly between my development and
>>>>>>>>>>>> production
>>>>>>>>>>>> servers.
>>>>>>>>>>>>
>>>>>>>>>>>> public static void
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> contributeAlias(Configuration<AliasContribution>
>>>
>>>
>>>> configuration,
>>>>>>>>>>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> String
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>>>> production
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>  {
>>>>>>>>>>>>              if (0 != production.compareToIgnoreCase("true"))
>>>>>>>>>>>>              {
>>>>>>>>>>>>            BaseURLSource source = new BaseURLSource()
>>>>>>>>>>>>            {
>>>>>>>>>>>>                public String getBaseURL(boolean secure)
>>>>>>>>>>>>                {
>>>>>>>>>>>>                    String protocol = secure ? "https" : "http";
>>>>>>>>>>>>
>>>>>>>>>>>>                    int port = secure ? 8443 : 8080;
>>>>>>>>>>>>
>>>>>>>>>>>>                    return String.format("%s://localhost:%d",
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> protocol,
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> port);
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>                }
>>>>>>>>>>>>            };
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> source));
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>              }
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>> Somehow make this dependent on the user selection and return it
>>>>>>>>>>>> accordingly.
>>>>>>>>>>>>
>>>>>>>>>>>> Not a quick solution but possible a direction to try!
>>>>>>>>>>>>
>>>>>>>>>>>> Keith
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>  Hi!
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> My web application is large and consists of Struts, T4 and T5
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> pages.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>
>>>>>>>>> In
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> Struts and T4, I use the current http request to figure out
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> whether
>>>
>>>
>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> to
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>
>>>>>>>>> use
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> https or not. Users can choose if they want to log in using
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> https
>>>
>>>
>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> or
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>
>>>>>>>>> not.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> The chosen protocol is used on all pages after login.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> In T5, this is either a global static setting, or a static
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> setting
>>>
>>>
>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> per
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>
>>>>>>>>> page.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Is there a service or something I can override to implement my
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> own
>>>
>>>
>>>> "protocol
>>>>>>>>>>>>> builder"? Something like this:
>>>>>>>>>>>>>
>>>>>>>>>>>>> public class HttpProtocolBuilder {
>>>>>>>>>>>>>  public HttpProtocolBuilder (final HttpServletRequest request)
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> {
>>>
>>>
>>>>  this.request = request
>>>>>>>>>>>>>  }
>>>>>>>>>>>>>
>>>>>>>>>>>>>  public String getProtocol() {
>>>>>>>>>>>>>  if (request.isSecure()) {
>>>>>>>>>>>>>   return "https";
>>>>>>>>>>>>>  }
>>>>>>>>>>>>>  else {
>>>>>>>>>>>>>  return "http";
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> }
>>>>>>>>>>>>>
>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>
>>>>>>>>>>>>> Inge
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>> ---------------------------------------------------------------------
>>>
>>>
>>>>
>>>>>>>>
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>> ---------------------------------------------------------------------
>>>
>>>
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>> ---------------------------------------------------------------------
>>>
>>>
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: [T5] Pick up https/http from request

Posted by Michael Gerzabek <mi...@gmx.net>.
Inge,

not sure that I undestand fully what you are about. It sounds like you 
also want to implement RequestSecurityManager 
(http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/internal/services/package-tree.html). 
This is at least what I did and it works for me.

/Michael

Inge Solvoll schrieb:
> I think I know the reason for the loop...
>
> my getBaseURL method is only called when the requested url has a different
> protocol than specified in MetaDataConstants.SECURE_PAGE. It seems that when
> I try to write a base URL in my custom method that has a different protocol
> than SECURE_PAGE value, they start knocking each other's heades with
> redirects.
>
> Right now, it looks like this system works differently than I thought. Is it
> not possible to override the behaviour of one page or entire application
> fixed on a protocol?
>
>
>
> On Wed, Nov 26, 2008 at 11:44 AM, Kristian Marinkovic <
> kristian.marinkovic@porsche.co.at> wrote:
>
>   
>> try creating the proxy manually... almost worked every time for me
>>
>> constructor injection will be performed as expected
>>
>> public static void contributeAlias(
>>    ObjectLocator locator,
>>     Configuration<AliasContribution> configuration ) {
>>
>>    configuration.add( AliasContribution.create(
>>           BaseURLSource.class,
>>            locator.proxy(BaseURLSource.class,SomeImplementation.class) );
>>
>>   }
>>
>> g,
>> kris
>>
>>
>>
>>
>> "Inge Solvoll" <in...@gmail.com>
>> 26.11.2008 11:37
>> Bitte antworten an
>> "Tapestry users" <us...@tapestry.apache.org>
>>
>>
>> An
>> "Tapestry users" <us...@tapestry.apache.org>
>> Kopie
>>
>> Thema
>> Re: [T5] Pick up https/http from request
>>
>>
>>
>>
>>
>>
>> Thanks!
>>
>> But this still gives me the same loop error, because I have to inject
>> Request (where you inject SiteServices) into the builder method to access
>> the secure state of the request:
>>
>> Caused by: org.apache.tapestry5.ioc.internal.OperationException:
>> Construction of service 'Alias' has failed due to recursion: the service
>> depends on itself in some way. Please check
>> org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, String,
>> AliasManager, Collection) (at TapestryModule.java:214) for references to
>> another service that is itself dependent on service 'Alias'.
>>
>> Inge
>>
>> On Wed, Nov 26, 2008 at 11:28 AM, Michael Gerzabek
>> <michael.gerzabek@gmx.net
>>     
>>> wrote:
>>>       
>>> Inge,
>>>
>>> I did it successfully for a similar purpose:
>>>
>>>   @SuppressWarnings("unchecked")
>>>   public static void contributeAlias(
>>>       @InjectService( "SiteBaseURLSource" )
>>>       BaseURLSource baseUrlSource,
>>>       Configuration<AliasContribution> configuration ) {
>>>
>>>       configuration.add( AliasContribution.create(
>>>           BaseURLSource.class,
>>>           baseUrlSource ) );
>>>
>>>   }
>>>
>>> Don't use the binder but create your own build method:
>>>
>>>   @Marker( SiteServices.class )
>>>   public static BaseURLSource buildSiteBaseURLSource(
>>>       @SiteServices
>>>       SiteService site ) {
>>>
>>>       return new SiteBaseURLSource( site );
>>>   }
>>>
>>> You can ommit the Marker annotation.
>>>
>>> /Michael
>>>
>>> Solvoll schrieb:
>>>
>>>  Hi!
>>>       
>>>> I'm really struggling here as I think I'm approaching a solution. What
>>>>         
>> I'm
>>     
>>>> trying to do is to override/decorate/alias/replace the BaseURLSource
>>>>         
>> with
>>     
>>>> my
>>>> own implementation, like this:
>>>>
>>>> public class MyBaseURLSource implements BaseURLSource {
>>>>
>>>>  private final Request request;
>>>>
>>>>  public MyBaseURLSource(Request request) {
>>>>    this.request = request;
>>>>  }
>>>>
>>>>  public String getBaseURL(boolean secure) {
>>>>    boolean secureRequest = request.isSecure();
>>>>    String baseURL = String.format("%s://%s", secureRequest ? "https" :
>>>> "http", request.getServerName());
>>>>    return baseURL;
>>>>  }
>>>>
>>>> }
>>>>
>>>>
>>>> Essentially, I've copied the default implementation and replaced the
>>>>         
>> usage
>>     
>>>> of the secure parameter with the secure value of the request. My
>>>>         
>> problem
>>     
>>>> is
>>>> that I'm not capable of putting this code to actual work in the
>>>>         
>> framework.
>>     
>>>> I've tried:
>>>> - aliasing, but that didn't work because of circular dependency (I have
>>>>         
>> to
>>     
>>>> inject the Request)
>>>> - binder.bind(BaseURLSource.class, MyBaseURLSource.class), combinded
>>>>         
>> with
>>     
>>>> a
>>>> builder for MyBaseURLSource. Causes redirect loop.
>>>> - Decorating. Not managed to find out how I do this yet, have tried a
>>>>         
>> few
>>     
>>>> things.
>>>>
>>>> I'm guessing this is rather simple, it's just a bit complicated when
>>>> you're
>>>> not experienced in IoC... Anyone who wants to point me in the right
>>>> direction?
>>>>
>>>> Regards
>>>> Inge
>>>>
>>>>
>>>>
>>>> On Wed, Nov 19, 2008 at 10:22 AM, Inge Solvoll <inge.tapestry@gmail.com
>>>>         
>>>>> wrote:
>>>>>           
>>>>
>>>>         
>>>>> I voted for this issue now.
>>>>>
>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>
>>>>> This is really a big issue for our usage of T5, T5 is now forcing us
>>>>>           
>> to
>>     
>>>>> redirect users away from http access, because we no longer can support
>>>>> both
>>>>> modes as long as T5 is fixed on either http or https.
>>>>>
>>>>> Anyone who's got a working version of a BaseURLSource contribution,
>>>>>           
>> that
>>     
>>>>> actually can output a URL using the protocol from the initial request?
>>>>>
>>>>> Regards
>>>>> Inge
>>>>>
>>>>>
>>>>> On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <inge.tapestry@gmail.com
>>>>>           
>>>>>> wrote:
>>>>>>             
>>>>>
>>>>>           
>>>>>> I know, this isn't really a problem for regular pages, they load
>>>>>>             
>> using
>>     
>>>>>> the
>>>>>> requested protocol, when not marked as secure. But when I create
>>>>>> eventlinks
>>>>>> that updates zones, these don't work when they are generated with
>>>>>>             
>> http
>>     
>>>>>> and
>>>>>> the rest of the page is generated in https...
>>>>>>
>>>>>> What I would like to do is to try some more on the BaseURLSource
>>>>>> approach.
>>>>>> Anyone who's got any idea why this has no effect here? I copied and
>>>>>> pasted
>>>>>> the code from the T5 docs and put in my Appmodule, and the contribute
>>>>>> method
>>>>>> is called on server startup. I replaced the "localhost" url with an
>>>>>> obviously bad url, for testing, but nothing happens, all pages just
>>>>>>             
>> load
>>     
>>>>>> as
>>>>>> always, including eventlinks and actionlinks.
>>>>>>
>>>>>> Inge
>>>>>>
>>>>>>
>>>>>> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <carl.crowder@taptu.com
>>>>>>             
>>>>>>> wrote:
>>>>>>>               
>>>>>>
>>>>>>             
>>>>>>> I don't know if you're aware, but if you create a href something
>>>>>>>               
>> like
>>     
>>>>>>> href="//something.com/page"
>>>>>>>
>>>>>>> then the current protocol is maintained. So if you were viewing the
>>>>>>> page
>>>>>>> at https://something.com the HREF would resolve to
>>>>>>> https://something.com/page and similarly with http. Unfortunately it
>>>>>>> requires using absolute URLs all the time.
>>>>>>>
>>>>>>> I'm not sure if that helps, but perhaps it could be used in fixing
>>>>>>>               
>> that
>>     
>>>>>>> issue.
>>>>>>>
>>>>>>> Carl
>>>>>>>
>>>>>>> Inge Solvoll wrote:
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> Yes, I might. This is a major blow for us, our customers choose
>>>>>>>>                 
>> freely
>>     
>>>>>>>> whether they want to use http or https, so the T5 way of doing
>>>>>>>>                 
>> things
>>     
>>>>>>>>                 
>>>>>>> just
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> doesn't work for us...
>>>>>>>>
>>>>>>>> On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
>>>>>>>> jonathan.theitguy@gmail.com> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> You might want to vote for this:
>>>>>>>>>
>>>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> -----Original Message-----
>>>>>>>>>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
>>>>>>>>>> Sent: Friday, November 14, 2008 15:10
>>>>>>>>>> To: Tapestry users
>>>>>>>>>> Subject: Re: [T5] Pick up https/http from request
>>>>>>>>>>
>>>>>>>>>> Thanks!
>>>>>>>>>>
>>>>>>>>>> I tried copying your code into my AppModule with some small
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> modifications.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> But the code only runs on server startup, not when I access a
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> tapestry 5
>>>>>>>>>                   
>>>>>>>               
>>>>>>>> page. I tried to add deliberate errors in the code, like naming the
>>>>>>>>                 
>>>>>>>>>>                     
>>>>>>>>> server
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> loooocalhost, but I never saw the results when accessing pages.
>>>>>>>>>>
>>>>>>>>>> Also, when I try to add "final HttpServletRequest request" as a
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> parameter
>>>>>>>>>                   
>>>>>>>               
>>>>>>>> to
>>>>>>>>                 
>>>>>>>>>> the contributeAlias method, my T5.0.13 crashes complaining about
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> service
>>>>>>>>>                   
>>>>>>>               
>>>>>>>> recursion.
>>>>>>>>                 
>>>>>>>>>> What I need is for T5 to figure out that a user accesses a page
>>>>>>>>>>                     
>> with
>>     
>>>>>>>>>> either
>>>>>>>>>> http or https, and respond on the same protocol...
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Regards
>>>>>>>>>> Inge
>>>>>>>>>>
>>>>>>>>>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner
>>>>>>>>>>                     
>> <kb...@gmail.com>
>>     
>>>>>>>>>>                     
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> I believe you might be able to use an alternation of a solution I
>>>>>>>>>>                     
>>>>>>>>>>>                       
>>>>>>>>>> used
>>>>>>>>>>                     
>>>>>>>               
>>>>>>>> for
>>>>>>>>                 
>>>>>>>>>>                     
>>>>>>>>>>> getting https to work properly between my development and
>>>>>>>>>>> production
>>>>>>>>>>> servers.
>>>>>>>>>>>
>>>>>>>>>>> public static void
>>>>>>>>>>>                       
>> contributeAlias(Configuration<AliasContribution>
>>     
>>>>>>>>>>> configuration,
>>>>>>>>>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> String
>>>>>>>>>>                     
>>>>>>>               
>>>>>>>> production
>>>>>>>>                 
>>>>>>>>>>>  {
>>>>>>>>>>>               if (0 != production.compareToIgnoreCase("true"))
>>>>>>>>>>>               {
>>>>>>>>>>>             BaseURLSource source = new BaseURLSource()
>>>>>>>>>>>             {
>>>>>>>>>>>                 public String getBaseURL(boolean secure)
>>>>>>>>>>>                 {
>>>>>>>>>>>                     String protocol = secure ? "https" : "http";
>>>>>>>>>>>
>>>>>>>>>>>                     int port = secure ? 8443 : 8080;
>>>>>>>>>>>
>>>>>>>>>>>                     return String.format("%s://localhost:%d",
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> protocol,
>>>>>>>>>>                     
>>>>>>>>>                   
>>>>>>>>>> port);
>>>>>>>>>>                     
>>>>>>>>>>>                 }
>>>>>>>>>>>             };
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> source));
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>               }
>>>>>>>>>>>  }
>>>>>>>>>>>
>>>>>>>>>>> Somehow make this dependent on the user selection and return it
>>>>>>>>>>> accordingly.
>>>>>>>>>>>
>>>>>>>>>>> Not a quick solution but possible a direction to try!
>>>>>>>>>>>
>>>>>>>>>>> Keith
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>>>>>>>>>>>
>>>>>>>>>>>  Hi!
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> My web application is large and consists of Struts, T4 and T5
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> pages.
>>>>>>>>>>>                       
>>>>>>>               
>>>>>>>> In
>>>>>>>>                 
>>>>>>>>>                   
>>>>>>>>>> Struts and T4, I use the current http request to figure out
>>>>>>>>>>                     
>> whether
>>     
>>>>>>>>>>>>                         
>>>>>>>>>>> to
>>>>>>>>>>>                       
>>>>>>>               
>>>>>>>> use
>>>>>>>>                 
>>>>>>>>>>                     
>>>>>>>>>>> https or not. Users can choose if they want to log in using
>>>>>>>>>>>                       
>> https
>>     
>>>>>>>>>>>>                         
>>>>>>>>>>> or
>>>>>>>>>>>                       
>>>>>>>               
>>>>>>>> not.
>>>>>>>>                 
>>>>>>>>>>                     
>>>>>>>>>>> The chosen protocol is used on all pages after login.
>>>>>>>>>>>                       
>>>>>>>>>>>> In T5, this is either a global static setting, or a static
>>>>>>>>>>>>                         
>> setting
>>     
>>>>>>>>>>>>                         
>>>>>>>>>>> per
>>>>>>>>>>>                       
>>>>>>>               
>>>>>>>> page.
>>>>>>>>                 
>>>>>>>>>>>> Is there a service or something I can override to implement my
>>>>>>>>>>>>                         
>> own
>>     
>>>>>>>>>>>> "protocol
>>>>>>>>>>>> builder"? Something like this:
>>>>>>>>>>>>
>>>>>>>>>>>> public class HttpProtocolBuilder {
>>>>>>>>>>>>  public HttpProtocolBuilder (final HttpServletRequest request)
>>>>>>>>>>>>                         
>> {
>>     
>>>>>>>>>>>>  this.request = request
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  public String getProtocol() {
>>>>>>>>>>>>  if (request.isSecure()) {
>>>>>>>>>>>>    return "https";
>>>>>>>>>>>>  }
>>>>>>>>>>>>  else {
>>>>>>>>>>>>   return "http";
>>>>>>>>>>>>   }
>>>>>>>>>>>> }
>>>>>>>>>>>>
>>>>>>>>>>>> Regards
>>>>>>>>>>>>
>>>>>>>>>>>> Inge
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>                       
>> ---------------------------------------------------------------------
>>     
>>>>>>>               
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>                 
>>>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>> ---------------------------------------------------------------------
>>     
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>> ---------------------------------------------------------------------
>>     
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>         
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>       
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Re: [T5] Pick up https/http from request

Posted by Inge Solvoll <in...@gmail.com>.
I think I know the reason for the loop...

my getBaseURL method is only called when the requested url has a different
protocol than specified in MetaDataConstants.SECURE_PAGE. It seems that when
I try to write a base URL in my custom method that has a different protocol
than SECURE_PAGE value, they start knocking each other's heades with
redirects.

Right now, it looks like this system works differently than I thought. Is it
not possible to override the behaviour of one page or entire application
fixed on a protocol?



On Wed, Nov 26, 2008 at 11:44 AM, Kristian Marinkovic <
kristian.marinkovic@porsche.co.at> wrote:

> try creating the proxy manually... almost worked every time for me
>
> constructor injection will be performed as expected
>
> public static void contributeAlias(
>    ObjectLocator locator,
>     Configuration<AliasContribution> configuration ) {
>
>    configuration.add( AliasContribution.create(
>           BaseURLSource.class,
>            locator.proxy(BaseURLSource.class,SomeImplementation.class) );
>
>   }
>
> g,
> kris
>
>
>
>
> "Inge Solvoll" <in...@gmail.com>
> 26.11.2008 11:37
> Bitte antworten an
> "Tapestry users" <us...@tapestry.apache.org>
>
>
> An
> "Tapestry users" <us...@tapestry.apache.org>
> Kopie
>
> Thema
> Re: [T5] Pick up https/http from request
>
>
>
>
>
>
> Thanks!
>
> But this still gives me the same loop error, because I have to inject
> Request (where you inject SiteServices) into the builder method to access
> the secure state of the request:
>
> Caused by: org.apache.tapestry5.ioc.internal.OperationException:
> Construction of service 'Alias' has failed due to recursion: the service
> depends on itself in some way. Please check
> org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, String,
> AliasManager, Collection) (at TapestryModule.java:214) for references to
> another service that is itself dependent on service 'Alias'.
>
> Inge
>
> On Wed, Nov 26, 2008 at 11:28 AM, Michael Gerzabek
> <michael.gerzabek@gmx.net
> > wrote:
>
> > Inge,
> >
> > I did it successfully for a similar purpose:
> >
> >   @SuppressWarnings("unchecked")
> >   public static void contributeAlias(
> >       @InjectService( "SiteBaseURLSource" )
> >       BaseURLSource baseUrlSource,
> >       Configuration<AliasContribution> configuration ) {
> >
> >       configuration.add( AliasContribution.create(
> >           BaseURLSource.class,
> >           baseUrlSource ) );
> >
> >   }
> >
> > Don't use the binder but create your own build method:
> >
> >   @Marker( SiteServices.class )
> >   public static BaseURLSource buildSiteBaseURLSource(
> >       @SiteServices
> >       SiteService site ) {
> >
> >       return new SiteBaseURLSource( site );
> >   }
> >
> > You can ommit the Marker annotation.
> >
> > /Michael
> >
> > Solvoll schrieb:
> >
> >  Hi!
> >>
> >> I'm really struggling here as I think I'm approaching a solution. What
> I'm
> >> trying to do is to override/decorate/alias/replace the BaseURLSource
> with
> >> my
> >> own implementation, like this:
> >>
> >> public class MyBaseURLSource implements BaseURLSource {
> >>
> >>  private final Request request;
> >>
> >>  public MyBaseURLSource(Request request) {
> >>    this.request = request;
> >>  }
> >>
> >>  public String getBaseURL(boolean secure) {
> >>    boolean secureRequest = request.isSecure();
> >>    String baseURL = String.format("%s://%s", secureRequest ? "https" :
> >> "http", request.getServerName());
> >>    return baseURL;
> >>  }
> >>
> >> }
> >>
> >>
> >> Essentially, I've copied the default implementation and replaced the
> usage
> >> of the secure parameter with the secure value of the request. My
> problem
> >> is
> >> that I'm not capable of putting this code to actual work in the
> framework.
> >>
> >> I've tried:
> >> - aliasing, but that didn't work because of circular dependency (I have
> to
> >> inject the Request)
> >> - binder.bind(BaseURLSource.class, MyBaseURLSource.class), combinded
> with
> >> a
> >> builder for MyBaseURLSource. Causes redirect loop.
> >> - Decorating. Not managed to find out how I do this yet, have tried a
> few
> >> things.
> >>
> >> I'm guessing this is rather simple, it's just a bit complicated when
> >> you're
> >> not experienced in IoC... Anyone who wants to point me in the right
> >> direction?
> >>
> >> Regards
> >> Inge
> >>
> >>
> >>
> >> On Wed, Nov 19, 2008 at 10:22 AM, Inge Solvoll <inge.tapestry@gmail.com
> >> >wrote:
> >>
> >>
> >>
> >>> I voted for this issue now.
> >>>
> >>> https://issues.apache.org/jira/browse/TAP5-167
> >>>
> >>> This is really a big issue for our usage of T5, T5 is now forcing us
> to
> >>> redirect users away from http access, because we no longer can support
> >>> both
> >>> modes as long as T5 is fixed on either http or https.
> >>>
> >>> Anyone who's got a working version of a BaseURLSource contribution,
> that
> >>> actually can output a URL using the protocol from the initial request?
> >>>
> >>> Regards
> >>> Inge
> >>>
> >>>
> >>> On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <inge.tapestry@gmail.com
> >>> >wrote:
> >>>
> >>>
> >>>
> >>>> I know, this isn't really a problem for regular pages, they load
> using
> >>>> the
> >>>> requested protocol, when not marked as secure. But when I create
> >>>> eventlinks
> >>>> that updates zones, these don't work when they are generated with
> http
> >>>> and
> >>>> the rest of the page is generated in https...
> >>>>
> >>>> What I would like to do is to try some more on the BaseURLSource
> >>>> approach.
> >>>> Anyone who's got any idea why this has no effect here? I copied and
> >>>> pasted
> >>>> the code from the T5 docs and put in my Appmodule, and the contribute
> >>>> method
> >>>> is called on server startup. I replaced the "localhost" url with an
> >>>> obviously bad url, for testing, but nothing happens, all pages just
> load
> >>>> as
> >>>> always, including eventlinks and actionlinks.
> >>>>
> >>>> Inge
> >>>>
> >>>>
> >>>> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <carl.crowder@taptu.com
> >>>> >wrote:
> >>>>
> >>>>
> >>>>
> >>>>> I don't know if you're aware, but if you create a href something
> like
> >>>>>
> >>>>> href="//something.com/page"
> >>>>>
> >>>>> then the current protocol is maintained. So if you were viewing the
> >>>>> page
> >>>>> at https://something.com the HREF would resolve to
> >>>>> https://something.com/page and similarly with http. Unfortunately it
> >>>>> requires using absolute URLs all the time.
> >>>>>
> >>>>> I'm not sure if that helps, but perhaps it could be used in fixing
> that
> >>>>> issue.
> >>>>>
> >>>>> Carl
> >>>>>
> >>>>> Inge Solvoll wrote:
> >>>>>
> >>>>>
> >>>>>> Yes, I might. This is a major blow for us, our customers choose
> freely
> >>>>>> whether they want to use http or https, so the T5 way of doing
> things
> >>>>>>
> >>>>>>
> >>>>> just
> >>>>>
> >>>>>
> >>>>>> doesn't work for us...
> >>>>>>
> >>>>>> On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
> >>>>>> jonathan.theitguy@gmail.com> wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> You might want to vote for this:
> >>>>>>>
> >>>>>>> https://issues.apache.org/jira/browse/TAP5-167
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> -----Original Message-----
> >>>>>>>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
> >>>>>>>> Sent: Friday, November 14, 2008 15:10
> >>>>>>>> To: Tapestry users
> >>>>>>>> Subject: Re: [T5] Pick up https/http from request
> >>>>>>>>
> >>>>>>>> Thanks!
> >>>>>>>>
> >>>>>>>> I tried copying your code into my AppModule with some small
> >>>>>>>>
> >>>>>>>>
> >>>>>>> modifications.
> >>>>>>>
> >>>>>>>
> >>>>>>>> But the code only runs on server startup, not when I access a
> >>>>>>>>
> >>>>>>>>
> >>>>>>> tapestry 5
> >>>>>
> >>>>>
> >>>>>> page. I tried to add deliberate errors in the code, like naming the
> >>>>>>>>
> >>>>>>>>
> >>>>>>> server
> >>>>>>>
> >>>>>>>
> >>>>>>>> loooocalhost, but I never saw the results when accessing pages.
> >>>>>>>>
> >>>>>>>> Also, when I try to add "final HttpServletRequest request" as a
> >>>>>>>>
> >>>>>>>>
> >>>>>>> parameter
> >>>>>
> >>>>>
> >>>>>> to
> >>>>>>>> the contributeAlias method, my T5.0.13 crashes complaining about
> >>>>>>>>
> >>>>>>>>
> >>>>>>> service
> >>>>>
> >>>>>
> >>>>>> recursion.
> >>>>>>>>
> >>>>>>>> What I need is for T5 to figure out that a user accesses a page
> with
> >>>>>>>> either
> >>>>>>>> http or https, and respond on the same protocol...
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> Regards
> >>>>>>>> Inge
> >>>>>>>>
> >>>>>>>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner
> <kb...@gmail.com>
> >>>>>>>>
> >>>>>>>>
> >>>>>>> wrote:
> >>>>>>>
> >>>>>>>
> >>>>>>>> I believe you might be able to use an alternation of a solution I
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> used
> >>>>>
> >>>>>
> >>>>>> for
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> getting https to work properly between my development and
> >>>>>>>>> production
> >>>>>>>>> servers.
> >>>>>>>>>
> >>>>>>>>> public static void
> contributeAlias(Configuration<AliasContribution>
> >>>>>>>>> configuration,
> >>>>>>>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> String
> >>>>>
> >>>>>
> >>>>>> production
> >>>>>>>>>  {
> >>>>>>>>>               if (0 != production.compareToIgnoreCase("true"))
> >>>>>>>>>               {
> >>>>>>>>>             BaseURLSource source = new BaseURLSource()
> >>>>>>>>>             {
> >>>>>>>>>                 public String getBaseURL(boolean secure)
> >>>>>>>>>                 {
> >>>>>>>>>                     String protocol = secure ? "https" : "http";
> >>>>>>>>>
> >>>>>>>>>                     int port = secure ? 8443 : 8080;
> >>>>>>>>>
> >>>>>>>>>                     return String.format("%s://localhost:%d",
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> protocol,
> >>>>>>>
> >>>>>>>
> >>>>>>>> port);
> >>>>>>>>>                 }
> >>>>>>>>>             };
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> source));
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>               }
> >>>>>>>>>  }
> >>>>>>>>>
> >>>>>>>>> Somehow make this dependent on the user selection and return it
> >>>>>>>>> accordingly.
> >>>>>>>>>
> >>>>>>>>> Not a quick solution but possible a direction to try!
> >>>>>>>>>
> >>>>>>>>> Keith
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
> >>>>>>>>>
> >>>>>>>>>  Hi!
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> My web application is large and consists of Struts, T4 and T5
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> pages.
> >>>>>
> >>>>>
> >>>>>> In
> >>>>>>>
> >>>>>>>
> >>>>>>>> Struts and T4, I use the current http request to figure out
> whether
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> to
> >>>>>
> >>>>>
> >>>>>> use
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> https or not. Users can choose if they want to log in using
> https
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> or
> >>>>>
> >>>>>
> >>>>>> not.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> The chosen protocol is used on all pages after login.
> >>>>>>>>>>
> >>>>>>>>>> In T5, this is either a global static setting, or a static
> setting
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> per
> >>>>>
> >>>>>
> >>>>>> page.
> >>>>>>>>>> Is there a service or something I can override to implement my
> own
> >>>>>>>>>> "protocol
> >>>>>>>>>> builder"? Something like this:
> >>>>>>>>>>
> >>>>>>>>>> public class HttpProtocolBuilder {
> >>>>>>>>>>  public HttpProtocolBuilder (final HttpServletRequest request)
> {
> >>>>>>>>>>  this.request = request
> >>>>>>>>>>  }
> >>>>>>>>>>
> >>>>>>>>>>  public String getProtocol() {
> >>>>>>>>>>  if (request.isSecure()) {
> >>>>>>>>>>    return "https";
> >>>>>>>>>>  }
> >>>>>>>>>>  else {
> >>>>>>>>>>   return "http";
> >>>>>>>>>>   }
> >>>>>>>>>> }
> >>>>>>>>>>
> >>>>>>>>>> Regards
> >>>>>>>>>>
> >>>>>>>>>> Inge
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>
> ---------------------------------------------------------------------
> >>>>>
> >>>>>
> >>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>
> ---------------------------------------------------------------------
> >>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>
> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>

Antwort: Re: [T5] Pick up https/http from request

Posted by Kristian Marinkovic <kr...@porsche.co.at>.
try creating the proxy manually... almost worked every time for me

constructor injection will be performed as expected

public static void contributeAlias(
    ObjectLocator locator,
    Configuration<AliasContribution> configuration ) {

    configuration.add( AliasContribution.create(
           BaseURLSource.class,
           locator.proxy(BaseURLSource.class,SomeImplementation.class) );

   }

g,
kris




"Inge Solvoll" <in...@gmail.com> 
26.11.2008 11:37
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>


An
"Tapestry users" <us...@tapestry.apache.org>
Kopie

Thema
Re: [T5] Pick up https/http from request






Thanks!

But this still gives me the same loop error, because I have to inject
Request (where you inject SiteServices) into the builder method to access
the secure state of the request:

Caused by: org.apache.tapestry5.ioc.internal.OperationException:
Construction of service 'Alias' has failed due to recursion: the service
depends on itself in some way. Please check
org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, String,
AliasManager, Collection) (at TapestryModule.java:214) for references to
another service that is itself dependent on service 'Alias'.

Inge

On Wed, Nov 26, 2008 at 11:28 AM, Michael Gerzabek 
<michael.gerzabek@gmx.net
> wrote:

> Inge,
>
> I did it successfully for a similar purpose:
>
>   @SuppressWarnings("unchecked")
>   public static void contributeAlias(
>       @InjectService( "SiteBaseURLSource" )
>       BaseURLSource baseUrlSource,
>       Configuration<AliasContribution> configuration ) {
>
>       configuration.add( AliasContribution.create(
>           BaseURLSource.class,
>           baseUrlSource ) );
>
>   }
>
> Don't use the binder but create your own build method:
>
>   @Marker( SiteServices.class )
>   public static BaseURLSource buildSiteBaseURLSource(
>       @SiteServices
>       SiteService site ) {
>
>       return new SiteBaseURLSource( site );
>   }
>
> You can ommit the Marker annotation.
>
> /Michael
>
> Solvoll schrieb:
>
>  Hi!
>>
>> I'm really struggling here as I think I'm approaching a solution. What 
I'm
>> trying to do is to override/decorate/alias/replace the BaseURLSource 
with
>> my
>> own implementation, like this:
>>
>> public class MyBaseURLSource implements BaseURLSource {
>>
>>  private final Request request;
>>
>>  public MyBaseURLSource(Request request) {
>>    this.request = request;
>>  }
>>
>>  public String getBaseURL(boolean secure) {
>>    boolean secureRequest = request.isSecure();
>>    String baseURL = String.format("%s://%s", secureRequest ? "https" :
>> "http", request.getServerName());
>>    return baseURL;
>>  }
>>
>> }
>>
>>
>> Essentially, I've copied the default implementation and replaced the 
usage
>> of the secure parameter with the secure value of the request. My 
problem
>> is
>> that I'm not capable of putting this code to actual work in the 
framework.
>>
>> I've tried:
>> - aliasing, but that didn't work because of circular dependency (I have 
to
>> inject the Request)
>> - binder.bind(BaseURLSource.class, MyBaseURLSource.class), combinded 
with
>> a
>> builder for MyBaseURLSource. Causes redirect loop.
>> - Decorating. Not managed to find out how I do this yet, have tried a 
few
>> things.
>>
>> I'm guessing this is rather simple, it's just a bit complicated when
>> you're
>> not experienced in IoC... Anyone who wants to point me in the right
>> direction?
>>
>> Regards
>> Inge
>>
>>
>>
>> On Wed, Nov 19, 2008 at 10:22 AM, Inge Solvoll <inge.tapestry@gmail.com
>> >wrote:
>>
>>
>>
>>> I voted for this issue now.
>>>
>>> https://issues.apache.org/jira/browse/TAP5-167
>>>
>>> This is really a big issue for our usage of T5, T5 is now forcing us 
to
>>> redirect users away from http access, because we no longer can support
>>> both
>>> modes as long as T5 is fixed on either http or https.
>>>
>>> Anyone who's got a working version of a BaseURLSource contribution, 
that
>>> actually can output a URL using the protocol from the initial request?
>>>
>>> Regards
>>> Inge
>>>
>>>
>>> On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <inge.tapestry@gmail.com
>>> >wrote:
>>>
>>>
>>>
>>>> I know, this isn't really a problem for regular pages, they load 
using
>>>> the
>>>> requested protocol, when not marked as secure. But when I create
>>>> eventlinks
>>>> that updates zones, these don't work when they are generated with 
http
>>>> and
>>>> the rest of the page is generated in https...
>>>>
>>>> What I would like to do is to try some more on the BaseURLSource
>>>> approach.
>>>> Anyone who's got any idea why this has no effect here? I copied and
>>>> pasted
>>>> the code from the T5 docs and put in my Appmodule, and the contribute
>>>> method
>>>> is called on server startup. I replaced the "localhost" url with an
>>>> obviously bad url, for testing, but nothing happens, all pages just 
load
>>>> as
>>>> always, including eventlinks and actionlinks.
>>>>
>>>> Inge
>>>>
>>>>
>>>> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <carl.crowder@taptu.com
>>>> >wrote:
>>>>
>>>>
>>>>
>>>>> I don't know if you're aware, but if you create a href something 
like
>>>>>
>>>>> href="//something.com/page"
>>>>>
>>>>> then the current protocol is maintained. So if you were viewing the
>>>>> page
>>>>> at https://something.com the HREF would resolve to
>>>>> https://something.com/page and similarly with http. Unfortunately it
>>>>> requires using absolute URLs all the time.
>>>>>
>>>>> I'm not sure if that helps, but perhaps it could be used in fixing 
that
>>>>> issue.
>>>>>
>>>>> Carl
>>>>>
>>>>> Inge Solvoll wrote:
>>>>>
>>>>>
>>>>>> Yes, I might. This is a major blow for us, our customers choose 
freely
>>>>>> whether they want to use http or https, so the T5 way of doing 
things
>>>>>>
>>>>>>
>>>>> just
>>>>>
>>>>>
>>>>>> doesn't work for us...
>>>>>>
>>>>>> On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
>>>>>> jonathan.theitguy@gmail.com> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> You might want to vote for this:
>>>>>>>
>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
>>>>>>>> Sent: Friday, November 14, 2008 15:10
>>>>>>>> To: Tapestry users
>>>>>>>> Subject: Re: [T5] Pick up https/http from request
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>>
>>>>>>>> I tried copying your code into my AppModule with some small
>>>>>>>>
>>>>>>>>
>>>>>>> modifications.
>>>>>>>
>>>>>>>
>>>>>>>> But the code only runs on server startup, not when I access a
>>>>>>>>
>>>>>>>>
>>>>>>> tapestry 5
>>>>>
>>>>>
>>>>>> page. I tried to add deliberate errors in the code, like naming the
>>>>>>>>
>>>>>>>>
>>>>>>> server
>>>>>>>
>>>>>>>
>>>>>>>> loooocalhost, but I never saw the results when accessing pages.
>>>>>>>>
>>>>>>>> Also, when I try to add "final HttpServletRequest request" as a
>>>>>>>>
>>>>>>>>
>>>>>>> parameter
>>>>>
>>>>>
>>>>>> to
>>>>>>>> the contributeAlias method, my T5.0.13 crashes complaining about
>>>>>>>>
>>>>>>>>
>>>>>>> service
>>>>>
>>>>>
>>>>>> recursion.
>>>>>>>>
>>>>>>>> What I need is for T5 to figure out that a user accesses a page 
with
>>>>>>>> either
>>>>>>>> http or https, and respond on the same protocol...
>>>>>>>>
>>>>>>>>
>>>>>>>> Regards
>>>>>>>> Inge
>>>>>>>>
>>>>>>>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner 
<kb...@gmail.com>
>>>>>>>>
>>>>>>>>
>>>>>>> wrote:
>>>>>>>
>>>>>>>
>>>>>>>> I believe you might be able to use an alternation of a solution I
>>>>>>>>>
>>>>>>>>>
>>>>>>>> used
>>>>>
>>>>>
>>>>>> for
>>>>>>>>
>>>>>>>>
>>>>>>>>> getting https to work properly between my development and
>>>>>>>>> production
>>>>>>>>> servers.
>>>>>>>>>
>>>>>>>>> public static void 
contributeAlias(Configuration<AliasContribution>
>>>>>>>>> configuration,
>>>>>>>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
>>>>>>>>>
>>>>>>>>>
>>>>>>>> String
>>>>>
>>>>>
>>>>>> production
>>>>>>>>>  {
>>>>>>>>>               if (0 != production.compareToIgnoreCase("true"))
>>>>>>>>>               {
>>>>>>>>>             BaseURLSource source = new BaseURLSource()
>>>>>>>>>             {
>>>>>>>>>                 public String getBaseURL(boolean secure)
>>>>>>>>>                 {
>>>>>>>>>                     String protocol = secure ? "https" : "http";
>>>>>>>>>
>>>>>>>>>                     int port = secure ? 8443 : 8080;
>>>>>>>>>
>>>>>>>>>                     return String.format("%s://localhost:%d",
>>>>>>>>>
>>>>>>>>>
>>>>>>>> protocol,
>>>>>>>
>>>>>>>
>>>>>>>> port);
>>>>>>>>>                 }
>>>>>>>>>             };
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
>>>>>>>>>
>>>>>>>>>
>>>>>>>> source));
>>>>>>>>
>>>>>>>>
>>>>>>>>>               }
>>>>>>>>>  }
>>>>>>>>>
>>>>>>>>> Somehow make this dependent on the user selection and return it
>>>>>>>>> accordingly.
>>>>>>>>>
>>>>>>>>> Not a quick solution but possible a direction to try!
>>>>>>>>>
>>>>>>>>> Keith
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>>>>>>>>>
>>>>>>>>>  Hi!
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> My web application is large and consists of Struts, T4 and T5
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> pages.
>>>>>
>>>>>
>>>>>> In
>>>>>>>
>>>>>>>
>>>>>>>> Struts and T4, I use the current http request to figure out 
whether
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> to
>>>>>
>>>>>
>>>>>> use
>>>>>>>>
>>>>>>>>
>>>>>>>>> https or not. Users can choose if they want to log in using 
https
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> or
>>>>>
>>>>>
>>>>>> not.
>>>>>>>>
>>>>>>>>
>>>>>>>>> The chosen protocol is used on all pages after login.
>>>>>>>>>>
>>>>>>>>>> In T5, this is either a global static setting, or a static 
setting
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> per
>>>>>
>>>>>
>>>>>> page.
>>>>>>>>>> Is there a service or something I can override to implement my 
own
>>>>>>>>>> "protocol
>>>>>>>>>> builder"? Something like this:
>>>>>>>>>>
>>>>>>>>>> public class HttpProtocolBuilder {
>>>>>>>>>>  public HttpProtocolBuilder (final HttpServletRequest request) 
{
>>>>>>>>>>  this.request = request
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  public String getProtocol() {
>>>>>>>>>>  if (request.isSecure()) {
>>>>>>>>>>    return "https";
>>>>>>>>>>  }
>>>>>>>>>>  else {
>>>>>>>>>>   return "http";
>>>>>>>>>>   }
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> Regards
>>>>>>>>>>
>>>>>>>>>> Inge
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>> 
---------------------------------------------------------------------
>>>>>
>>>>>
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>> 
---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> 
---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


Re: [T5] Pick up https/http from request

Posted by Inge Solvoll <in...@gmail.com>.
Thanks!

But this still gives me the same loop error, because I have to inject
Request (where you inject SiteServices) into the builder method to access
the secure state of the request:

Caused by: org.apache.tapestry5.ioc.internal.OperationException:
Construction of service 'Alias' has failed due to recursion: the service
depends on itself in some way. Please check
org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, String,
AliasManager, Collection) (at TapestryModule.java:214) for references to
another service that is itself dependent on service 'Alias'.

Inge

On Wed, Nov 26, 2008 at 11:28 AM, Michael Gerzabek <michael.gerzabek@gmx.net
> wrote:

> Inge,
>
> I did it successfully for a similar purpose:
>
>   @SuppressWarnings("unchecked")
>   public static void contributeAlias(
>       @InjectService( "SiteBaseURLSource" )
>       BaseURLSource baseUrlSource,
>       Configuration<AliasContribution> configuration ) {
>
>       configuration.add( AliasContribution.create(
>           BaseURLSource.class,
>           baseUrlSource ) );
>
>   }
>
> Don't use the binder but create your own build method:
>
>   @Marker( SiteServices.class )
>   public static BaseURLSource buildSiteBaseURLSource(
>       @SiteServices
>       SiteService site ) {
>
>       return new SiteBaseURLSource( site );
>   }
>
> You can ommit the Marker annotation.
>
> /Michael
>
> Solvoll schrieb:
>
>  Hi!
>>
>> I'm really struggling here as I think I'm approaching a solution. What I'm
>> trying to do is to override/decorate/alias/replace the BaseURLSource with
>> my
>> own implementation, like this:
>>
>> public class MyBaseURLSource implements BaseURLSource {
>>
>>  private final Request request;
>>
>>  public MyBaseURLSource(Request request) {
>>    this.request = request;
>>  }
>>
>>  public String getBaseURL(boolean secure) {
>>    boolean secureRequest = request.isSecure();
>>    String baseURL = String.format("%s://%s", secureRequest ? "https" :
>> "http", request.getServerName());
>>    return baseURL;
>>  }
>>
>> }
>>
>>
>> Essentially, I've copied the default implementation and replaced the usage
>> of the secure parameter with the secure value of the request. My problem
>> is
>> that I'm not capable of putting this code to actual work in the framework.
>>
>> I've tried:
>> - aliasing, but that didn't work because of circular dependency (I have to
>> inject the Request)
>> - binder.bind(BaseURLSource.class, MyBaseURLSource.class), combinded with
>> a
>> builder for MyBaseURLSource. Causes redirect loop.
>> - Decorating. Not managed to find out how I do this yet, have tried a few
>> things.
>>
>> I'm guessing this is rather simple, it's just a bit complicated when
>> you're
>> not experienced in IoC... Anyone who wants to point me in the right
>> direction?
>>
>> Regards
>> Inge
>>
>>
>>
>> On Wed, Nov 19, 2008 at 10:22 AM, Inge Solvoll <inge.tapestry@gmail.com
>> >wrote:
>>
>>
>>
>>> I voted for this issue now.
>>>
>>> https://issues.apache.org/jira/browse/TAP5-167
>>>
>>> This is really a big issue for our usage of T5, T5 is now forcing us to
>>> redirect users away from http access, because we no longer can support
>>> both
>>> modes as long as T5 is fixed on either http or https.
>>>
>>> Anyone who's got a working version of a BaseURLSource contribution, that
>>> actually can output a URL using the protocol from the initial request?
>>>
>>> Regards
>>> Inge
>>>
>>>
>>> On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <inge.tapestry@gmail.com
>>> >wrote:
>>>
>>>
>>>
>>>> I know, this isn't really a problem for regular pages, they load using
>>>> the
>>>> requested protocol, when not marked as secure. But when I create
>>>> eventlinks
>>>> that updates zones, these don't work when they are generated with http
>>>> and
>>>> the rest of the page is generated in https...
>>>>
>>>> What I would like to do is to try some more on the BaseURLSource
>>>> approach.
>>>> Anyone who's got any idea why this has no effect here? I copied and
>>>> pasted
>>>> the code from the T5 docs and put in my Appmodule, and the contribute
>>>> method
>>>> is called on server startup. I replaced the "localhost" url with an
>>>> obviously bad url, for testing, but nothing happens, all pages just load
>>>> as
>>>> always, including eventlinks and actionlinks.
>>>>
>>>> Inge
>>>>
>>>>
>>>> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <carl.crowder@taptu.com
>>>> >wrote:
>>>>
>>>>
>>>>
>>>>> I don't know if you're aware, but if you create a href something like
>>>>>
>>>>> href="//something.com/page"
>>>>>
>>>>> then the current protocol is maintained. So if you were viewing the
>>>>> page
>>>>> at https://something.com the HREF would resolve to
>>>>> https://something.com/page and similarly with http. Unfortunately it
>>>>> requires using absolute URLs all the time.
>>>>>
>>>>> I'm not sure if that helps, but perhaps it could be used in fixing that
>>>>> issue.
>>>>>
>>>>> Carl
>>>>>
>>>>> Inge Solvoll wrote:
>>>>>
>>>>>
>>>>>> Yes, I might. This is a major blow for us, our customers choose freely
>>>>>> whether they want to use http or https, so the T5 way of doing things
>>>>>>
>>>>>>
>>>>> just
>>>>>
>>>>>
>>>>>> doesn't work for us...
>>>>>>
>>>>>> On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
>>>>>> jonathan.theitguy@gmail.com> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> You might want to vote for this:
>>>>>>>
>>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
>>>>>>>> Sent: Friday, November 14, 2008 15:10
>>>>>>>> To: Tapestry users
>>>>>>>> Subject: Re: [T5] Pick up https/http from request
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>>
>>>>>>>> I tried copying your code into my AppModule with some small
>>>>>>>>
>>>>>>>>
>>>>>>> modifications.
>>>>>>>
>>>>>>>
>>>>>>>> But the code only runs on server startup, not when I access a
>>>>>>>>
>>>>>>>>
>>>>>>> tapestry 5
>>>>>
>>>>>
>>>>>> page. I tried to add deliberate errors in the code, like naming the
>>>>>>>>
>>>>>>>>
>>>>>>> server
>>>>>>>
>>>>>>>
>>>>>>>> loooocalhost, but I never saw the results when accessing pages.
>>>>>>>>
>>>>>>>> Also, when I try to add "final HttpServletRequest request" as a
>>>>>>>>
>>>>>>>>
>>>>>>> parameter
>>>>>
>>>>>
>>>>>> to
>>>>>>>> the contributeAlias method, my T5.0.13 crashes complaining about
>>>>>>>>
>>>>>>>>
>>>>>>> service
>>>>>
>>>>>
>>>>>> recursion.
>>>>>>>>
>>>>>>>> What I need is for T5 to figure out that a user accesses a page with
>>>>>>>> either
>>>>>>>> http or https, and respond on the same protocol...
>>>>>>>>
>>>>>>>>
>>>>>>>> Regards
>>>>>>>> Inge
>>>>>>>>
>>>>>>>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner <kb...@gmail.com>
>>>>>>>>
>>>>>>>>
>>>>>>> wrote:
>>>>>>>
>>>>>>>
>>>>>>>> I believe you might be able to use an alternation of a solution I
>>>>>>>>>
>>>>>>>>>
>>>>>>>> used
>>>>>
>>>>>
>>>>>> for
>>>>>>>>
>>>>>>>>
>>>>>>>>> getting https to work properly between my development and
>>>>>>>>> production
>>>>>>>>> servers.
>>>>>>>>>
>>>>>>>>> public static void contributeAlias(Configuration<AliasContribution>
>>>>>>>>> configuration,
>>>>>>>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
>>>>>>>>>
>>>>>>>>>
>>>>>>>> String
>>>>>
>>>>>
>>>>>> production
>>>>>>>>>  {
>>>>>>>>>               if (0 != production.compareToIgnoreCase("true"))
>>>>>>>>>               {
>>>>>>>>>             BaseURLSource source = new BaseURLSource()
>>>>>>>>>             {
>>>>>>>>>                 public String getBaseURL(boolean secure)
>>>>>>>>>                 {
>>>>>>>>>                     String protocol = secure ? "https" : "http";
>>>>>>>>>
>>>>>>>>>                     int port = secure ? 8443 : 8080;
>>>>>>>>>
>>>>>>>>>                     return String.format("%s://localhost:%d",
>>>>>>>>>
>>>>>>>>>
>>>>>>>> protocol,
>>>>>>>
>>>>>>>
>>>>>>>> port);
>>>>>>>>>                 }
>>>>>>>>>             };
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
>>>>>>>>>
>>>>>>>>>
>>>>>>>> source));
>>>>>>>>
>>>>>>>>
>>>>>>>>>               }
>>>>>>>>>  }
>>>>>>>>>
>>>>>>>>> Somehow make this dependent on the user selection and return it
>>>>>>>>> accordingly.
>>>>>>>>>
>>>>>>>>> Not a quick solution but possible a direction to try!
>>>>>>>>>
>>>>>>>>> Keith
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>>>>>>>>>
>>>>>>>>>  Hi!
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> My web application is large and consists of Struts, T4 and T5
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> pages.
>>>>>
>>>>>
>>>>>> In
>>>>>>>
>>>>>>>
>>>>>>>> Struts and T4, I use the current http request to figure out whether
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> to
>>>>>
>>>>>
>>>>>> use
>>>>>>>>
>>>>>>>>
>>>>>>>>> https or not. Users can choose if they want to log in using https
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> or
>>>>>
>>>>>
>>>>>> not.
>>>>>>>>
>>>>>>>>
>>>>>>>>> The chosen protocol is used on all pages after login.
>>>>>>>>>>
>>>>>>>>>> In T5, this is either a global static setting, or a static setting
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> per
>>>>>
>>>>>
>>>>>> page.
>>>>>>>>>> Is there a service or something I can override to implement my own
>>>>>>>>>> "protocol
>>>>>>>>>> builder"? Something like this:
>>>>>>>>>>
>>>>>>>>>> public class HttpProtocolBuilder {
>>>>>>>>>>  public HttpProtocolBuilder (final HttpServletRequest request) {
>>>>>>>>>>  this.request = request
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  public String getProtocol() {
>>>>>>>>>>  if (request.isSecure()) {
>>>>>>>>>>    return "https";
>>>>>>>>>>  }
>>>>>>>>>>  else {
>>>>>>>>>>   return "http";
>>>>>>>>>>   }
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> Regards
>>>>>>>>>>
>>>>>>>>>> Inge
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>>
>>>>>
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: [T5] Pick up https/http from request

Posted by Michael Gerzabek <mi...@gmx.net>.
Inge,

I did it successfully for a similar purpose:

    @SuppressWarnings("unchecked")
    public static void contributeAlias(
        @InjectService( "SiteBaseURLSource" )
        BaseURLSource baseUrlSource,
        Configuration<AliasContribution> configuration ) {

        configuration.add( AliasContribution.create(
            BaseURLSource.class,
            baseUrlSource ) );

    }

Don't use the binder but create your own build method:

    @Marker( SiteServices.class )
    public static BaseURLSource buildSiteBaseURLSource(
        @SiteServices
        SiteService site ) {

        return new SiteBaseURLSource( site );
    }

You can ommit the Marker annotation.

/Michael

 Solvoll schrieb:
> Hi!
>
> I'm really struggling here as I think I'm approaching a solution. What I'm
> trying to do is to override/decorate/alias/replace the BaseURLSource with my
> own implementation, like this:
>
> public class MyBaseURLSource implements BaseURLSource {
>
>   private final Request request;
>
>   public MyBaseURLSource(Request request) {
>     this.request = request;
>   }
>
>   public String getBaseURL(boolean secure) {
>     boolean secureRequest = request.isSecure();
>     String baseURL = String.format("%s://%s", secureRequest ? "https" :
> "http", request.getServerName());
>     return baseURL;
>   }
>
> }
>
>
> Essentially, I've copied the default implementation and replaced the usage
> of the secure parameter with the secure value of the request. My problem is
> that I'm not capable of putting this code to actual work in the framework.
>
> I've tried:
> - aliasing, but that didn't work because of circular dependency (I have to
> inject the Request)
> - binder.bind(BaseURLSource.class, MyBaseURLSource.class), combinded with a
> builder for MyBaseURLSource. Causes redirect loop.
> - Decorating. Not managed to find out how I do this yet, have tried a few
> things.
>
> I'm guessing this is rather simple, it's just a bit complicated when you're
> not experienced in IoC... Anyone who wants to point me in the right
> direction?
>
> Regards
> Inge
>
>
>
> On Wed, Nov 19, 2008 at 10:22 AM, Inge Solvoll <in...@gmail.com>wrote:
>
>   
>> I voted for this issue now.
>>
>> https://issues.apache.org/jira/browse/TAP5-167
>>
>> This is really a big issue for our usage of T5, T5 is now forcing us to
>> redirect users away from http access, because we no longer can support both
>> modes as long as T5 is fixed on either http or https.
>>
>> Anyone who's got a working version of a BaseURLSource contribution, that
>> actually can output a URL using the protocol from the initial request?
>>
>> Regards
>> Inge
>>
>>
>> On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <in...@gmail.com>wrote:
>>
>>     
>>> I know, this isn't really a problem for regular pages, they load using the
>>> requested protocol, when not marked as secure. But when I create eventlinks
>>> that updates zones, these don't work when they are generated with http and
>>> the rest of the page is generated in https...
>>>
>>> What I would like to do is to try some more on the BaseURLSource approach.
>>> Anyone who's got any idea why this has no effect here? I copied and pasted
>>> the code from the T5 docs and put in my Appmodule, and the contribute method
>>> is called on server startup. I replaced the "localhost" url with an
>>> obviously bad url, for testing, but nothing happens, all pages just load as
>>> always, including eventlinks and actionlinks.
>>>
>>> Inge
>>>
>>>
>>> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <ca...@taptu.com>wrote:
>>>
>>>       
>>>> I don't know if you're aware, but if you create a href something like
>>>>
>>>> href="//something.com/page"
>>>>
>>>> then the current protocol is maintained. So if you were viewing the page
>>>> at https://something.com the HREF would resolve to
>>>> https://something.com/page and similarly with http. Unfortunately it
>>>> requires using absolute URLs all the time.
>>>>
>>>> I'm not sure if that helps, but perhaps it could be used in fixing that
>>>> issue.
>>>>
>>>> Carl
>>>>
>>>> Inge Solvoll wrote:
>>>>         
>>>>> Yes, I might. This is a major blow for us, our customers choose freely
>>>>> whether they want to use http or https, so the T5 way of doing things
>>>>>           
>>>> just
>>>>         
>>>>> doesn't work for us...
>>>>>
>>>>> On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
>>>>> jonathan.theitguy@gmail.com> wrote:
>>>>>
>>>>>           
>>>>>> You might want to vote for this:
>>>>>>
>>>>>> https://issues.apache.org/jira/browse/TAP5-167
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> -----Original Message-----
>>>>>>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
>>>>>>> Sent: Friday, November 14, 2008 15:10
>>>>>>> To: Tapestry users
>>>>>>> Subject: Re: [T5] Pick up https/http from request
>>>>>>>
>>>>>>> Thanks!
>>>>>>>
>>>>>>> I tried copying your code into my AppModule with some small
>>>>>>>               
>>>>>> modifications.
>>>>>>             
>>>>>>> But the code only runs on server startup, not when I access a
>>>>>>>               
>>>> tapestry 5
>>>>         
>>>>>>> page. I tried to add deliberate errors in the code, like naming the
>>>>>>>               
>>>>>> server
>>>>>>             
>>>>>>> loooocalhost, but I never saw the results when accessing pages.
>>>>>>>
>>>>>>> Also, when I try to add "final HttpServletRequest request" as a
>>>>>>>               
>>>> parameter
>>>>         
>>>>>>> to
>>>>>>> the contributeAlias method, my T5.0.13 crashes complaining about
>>>>>>>               
>>>> service
>>>>         
>>>>>>> recursion.
>>>>>>>
>>>>>>> What I need is for T5 to figure out that a user accesses a page with
>>>>>>> either
>>>>>>> http or https, and respond on the same protocol...
>>>>>>>
>>>>>>>
>>>>>>> Regards
>>>>>>> Inge
>>>>>>>
>>>>>>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner <kb...@gmail.com>
>>>>>>>               
>>>>>> wrote:
>>>>>>             
>>>>>>>> I believe you might be able to use an alternation of a solution I
>>>>>>>>                 
>>>> used
>>>>         
>>>>>>> for
>>>>>>>               
>>>>>>>> getting https to work properly between my development and production
>>>>>>>> servers.
>>>>>>>>
>>>>>>>> public static void contributeAlias(Configuration<AliasContribution>
>>>>>>>> configuration,
>>>>>>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
>>>>>>>>                 
>>>> String
>>>>         
>>>>>>>> production
>>>>>>>>  {
>>>>>>>>                if (0 != production.compareToIgnoreCase("true"))
>>>>>>>>                {
>>>>>>>>              BaseURLSource source = new BaseURLSource()
>>>>>>>>              {
>>>>>>>>                  public String getBaseURL(boolean secure)
>>>>>>>>                  {
>>>>>>>>                      String protocol = secure ? "https" : "http";
>>>>>>>>
>>>>>>>>                      int port = secure ? 8443 : 8080;
>>>>>>>>
>>>>>>>>                      return String.format("%s://localhost:%d",
>>>>>>>>                 
>>>>>> protocol,
>>>>>>             
>>>>>>>> port);
>>>>>>>>                  }
>>>>>>>>              };
>>>>>>>>
>>>>>>>>
>>>>>>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
>>>>>>>>                 
>>>>>>> source));
>>>>>>>               
>>>>>>>>                }
>>>>>>>>  }
>>>>>>>>
>>>>>>>> Somehow make this dependent on the user selection and return it
>>>>>>>> accordingly.
>>>>>>>>
>>>>>>>> Not a quick solution but possible a direction to try!
>>>>>>>>
>>>>>>>> Keith
>>>>>>>>
>>>>>>>>
>>>>>>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>>>>>>>>
>>>>>>>>  Hi!
>>>>>>>>                 
>>>>>>>>> My web application is large and consists of Struts, T4 and T5
>>>>>>>>>                   
>>>> pages.
>>>>         
>>>>>> In
>>>>>>             
>>>>>>>>> Struts and T4, I use the current http request to figure out whether
>>>>>>>>>                   
>>>> to
>>>>         
>>>>>>> use
>>>>>>>               
>>>>>>>>> https or not. Users can choose if they want to log in using https
>>>>>>>>>                   
>>>> or
>>>>         
>>>>>>> not.
>>>>>>>               
>>>>>>>>> The chosen protocol is used on all pages after login.
>>>>>>>>>
>>>>>>>>> In T5, this is either a global static setting, or a static setting
>>>>>>>>>                   
>>>> per
>>>>         
>>>>>>>>> page.
>>>>>>>>> Is there a service or something I can override to implement my own
>>>>>>>>> "protocol
>>>>>>>>> builder"? Something like this:
>>>>>>>>>
>>>>>>>>> public class HttpProtocolBuilder {
>>>>>>>>>  public HttpProtocolBuilder (final HttpServletRequest request) {
>>>>>>>>>   this.request = request
>>>>>>>>>  }
>>>>>>>>>
>>>>>>>>>  public String getProtocol() {
>>>>>>>>>   if (request.isSecure()) {
>>>>>>>>>     return "https";
>>>>>>>>>   }
>>>>>>>>>   else {
>>>>>>>>>    return "http";
>>>>>>>>>    }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> Regards
>>>>>>>>>
>>>>>>>>> Inge
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>                 
>>>> ---------------------------------------------------------------------
>>>>         
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>>             
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>         
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Pick up https/http from request

Posted by Inge Solvoll <in...@gmail.com>.
Hi!

I'm really struggling here as I think I'm approaching a solution. What I'm
trying to do is to override/decorate/alias/replace the BaseURLSource with my
own implementation, like this:

public class MyBaseURLSource implements BaseURLSource {

  private final Request request;

  public MyBaseURLSource(Request request) {
    this.request = request;
  }

  public String getBaseURL(boolean secure) {
    boolean secureRequest = request.isSecure();
    String baseURL = String.format("%s://%s", secureRequest ? "https" :
"http", request.getServerName());
    return baseURL;
  }

}


Essentially, I've copied the default implementation and replaced the usage
of the secure parameter with the secure value of the request. My problem is
that I'm not capable of putting this code to actual work in the framework.

I've tried:
- aliasing, but that didn't work because of circular dependency (I have to
inject the Request)
- binder.bind(BaseURLSource.class, MyBaseURLSource.class), combinded with a
builder for MyBaseURLSource. Causes redirect loop.
- Decorating. Not managed to find out how I do this yet, have tried a few
things.

I'm guessing this is rather simple, it's just a bit complicated when you're
not experienced in IoC... Anyone who wants to point me in the right
direction?

Regards
Inge



On Wed, Nov 19, 2008 at 10:22 AM, Inge Solvoll <in...@gmail.com>wrote:

> I voted for this issue now.
>
> https://issues.apache.org/jira/browse/TAP5-167
>
> This is really a big issue for our usage of T5, T5 is now forcing us to
> redirect users away from http access, because we no longer can support both
> modes as long as T5 is fixed on either http or https.
>
> Anyone who's got a working version of a BaseURLSource contribution, that
> actually can output a URL using the protocol from the initial request?
>
> Regards
> Inge
>
>
> On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <in...@gmail.com>wrote:
>
>> I know, this isn't really a problem for regular pages, they load using the
>> requested protocol, when not marked as secure. But when I create eventlinks
>> that updates zones, these don't work when they are generated with http and
>> the rest of the page is generated in https...
>>
>> What I would like to do is to try some more on the BaseURLSource approach.
>> Anyone who's got any idea why this has no effect here? I copied and pasted
>> the code from the T5 docs and put in my Appmodule, and the contribute method
>> is called on server startup. I replaced the "localhost" url with an
>> obviously bad url, for testing, but nothing happens, all pages just load as
>> always, including eventlinks and actionlinks.
>>
>> Inge
>>
>>
>> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <ca...@taptu.com>wrote:
>>
>>> I don't know if you're aware, but if you create a href something like
>>>
>>> href="//something.com/page"
>>>
>>> then the current protocol is maintained. So if you were viewing the page
>>> at https://something.com the HREF would resolve to
>>> https://something.com/page and similarly with http. Unfortunately it
>>> requires using absolute URLs all the time.
>>>
>>> I'm not sure if that helps, but perhaps it could be used in fixing that
>>> issue.
>>>
>>> Carl
>>>
>>> Inge Solvoll wrote:
>>> > Yes, I might. This is a major blow for us, our customers choose freely
>>> > whether they want to use http or https, so the T5 way of doing things
>>> just
>>> > doesn't work for us...
>>> >
>>> > On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
>>> > jonathan.theitguy@gmail.com> wrote:
>>> >
>>> >> You might want to vote for this:
>>> >>
>>> >> https://issues.apache.org/jira/browse/TAP5-167
>>> >>
>>> >>
>>> >>> -----Original Message-----
>>> >>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
>>> >>> Sent: Friday, November 14, 2008 15:10
>>> >>> To: Tapestry users
>>> >>> Subject: Re: [T5] Pick up https/http from request
>>> >>>
>>> >>> Thanks!
>>> >>>
>>> >>> I tried copying your code into my AppModule with some small
>>> >> modifications.
>>> >>> But the code only runs on server startup, not when I access a
>>> tapestry 5
>>> >>> page. I tried to add deliberate errors in the code, like naming the
>>> >> server
>>> >>> loooocalhost, but I never saw the results when accessing pages.
>>> >>>
>>> >>> Also, when I try to add "final HttpServletRequest request" as a
>>> parameter
>>> >>> to
>>> >>> the contributeAlias method, my T5.0.13 crashes complaining about
>>> service
>>> >>> recursion.
>>> >>>
>>> >>> What I need is for T5 to figure out that a user accesses a page with
>>> >>> either
>>> >>> http or https, and respond on the same protocol...
>>> >>>
>>> >>>
>>> >>> Regards
>>> >>> Inge
>>> >>>
>>> >>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner <kb...@gmail.com>
>>> >> wrote:
>>> >>>> I believe you might be able to use an alternation of a solution I
>>> used
>>> >>> for
>>> >>>> getting https to work properly between my development and production
>>> >>>> servers.
>>> >>>>
>>> >>>> public static void contributeAlias(Configuration<AliasContribution>
>>> >>>> configuration,
>>> >>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
>>> String
>>> >>>> production
>>> >>>>  {
>>> >>>>                if (0 != production.compareToIgnoreCase("true"))
>>> >>>>                {
>>> >>>>              BaseURLSource source = new BaseURLSource()
>>> >>>>              {
>>> >>>>                  public String getBaseURL(boolean secure)
>>> >>>>                  {
>>> >>>>                      String protocol = secure ? "https" : "http";
>>> >>>>
>>> >>>>                      int port = secure ? 8443 : 8080;
>>> >>>>
>>> >>>>                      return String.format("%s://localhost:%d",
>>> >> protocol,
>>> >>>> port);
>>> >>>>                  }
>>> >>>>              };
>>> >>>>
>>> >>>>
>>> >>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
>>> >>> source));
>>> >>>>                }
>>> >>>>  }
>>> >>>>
>>> >>>> Somehow make this dependent on the user selection and return it
>>> >>>> accordingly.
>>> >>>>
>>> >>>> Not a quick solution but possible a direction to try!
>>> >>>>
>>> >>>> Keith
>>> >>>>
>>> >>>>
>>> >>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>>> >>>>
>>> >>>>  Hi!
>>> >>>>> My web application is large and consists of Struts, T4 and T5
>>> pages.
>>> >> In
>>> >>>>> Struts and T4, I use the current http request to figure out whether
>>> to
>>> >>> use
>>> >>>>> https or not. Users can choose if they want to log in using https
>>> or
>>> >>> not.
>>> >>>>> The chosen protocol is used on all pages after login.
>>> >>>>>
>>> >>>>> In T5, this is either a global static setting, or a static setting
>>> per
>>> >>>>> page.
>>> >>>>> Is there a service or something I can override to implement my own
>>> >>>>> "protocol
>>> >>>>> builder"? Something like this:
>>> >>>>>
>>> >>>>> public class HttpProtocolBuilder {
>>> >>>>>  public HttpProtocolBuilder (final HttpServletRequest request) {
>>> >>>>>   this.request = request
>>> >>>>>  }
>>> >>>>>
>>> >>>>>  public String getProtocol() {
>>> >>>>>   if (request.isSecure()) {
>>> >>>>>     return "https";
>>> >>>>>   }
>>> >>>>>   else {
>>> >>>>>    return "http";
>>> >>>>>    }
>>> >>>>> }
>>> >>>>>
>>> >>>>> Regards
>>> >>>>>
>>> >>>>> Inge
>>> >>>>>
>>> >>>>
>>> >>>>
>>> ---------------------------------------------------------------------
>>> >>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> >>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>> >>>>
>>> >>>>
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>>> >>
>>> >>
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>

Re: [T5] Pick up https/http from request

Posted by Inge Solvoll <in...@gmail.com>.
I voted for this issue now.

https://issues.apache.org/jira/browse/TAP5-167

This is really a big issue for our usage of T5, T5 is now forcing us to
redirect users away from http access, because we no longer can support both
modes as long as T5 is fixed on either http or https.

Anyone who's got a working version of a BaseURLSource contribution, that
actually can output a URL using the protocol from the initial request?

Regards
Inge

On Mon, Nov 17, 2008 at 8:57 AM, Inge Solvoll <in...@gmail.com>wrote:

> I know, this isn't really a problem for regular pages, they load using the
> requested protocol, when not marked as secure. But when I create eventlinks
> that updates zones, these don't work when they are generated with http and
> the rest of the page is generated in https...
>
> What I would like to do is to try some more on the BaseURLSource approach.
> Anyone who's got any idea why this has no effect here? I copied and pasted
> the code from the T5 docs and put in my Appmodule, and the contribute method
> is called on server startup. I replaced the "localhost" url with an
> obviously bad url, for testing, but nothing happens, all pages just load as
> always, including eventlinks and actionlinks.
>
> Inge
>
>
> On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <ca...@taptu.com>wrote:
>
>> I don't know if you're aware, but if you create a href something like
>>
>> href="//something.com/page"
>>
>> then the current protocol is maintained. So if you were viewing the page
>> at https://something.com the HREF would resolve to
>> https://something.com/page and similarly with http. Unfortunately it
>> requires using absolute URLs all the time.
>>
>> I'm not sure if that helps, but perhaps it could be used in fixing that
>> issue.
>>
>> Carl
>>
>> Inge Solvoll wrote:
>> > Yes, I might. This is a major blow for us, our customers choose freely
>> > whether they want to use http or https, so the T5 way of doing things
>> just
>> > doesn't work for us...
>> >
>> > On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
>> > jonathan.theitguy@gmail.com> wrote:
>> >
>> >> You might want to vote for this:
>> >>
>> >> https://issues.apache.org/jira/browse/TAP5-167
>> >>
>> >>
>> >>> -----Original Message-----
>> >>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
>> >>> Sent: Friday, November 14, 2008 15:10
>> >>> To: Tapestry users
>> >>> Subject: Re: [T5] Pick up https/http from request
>> >>>
>> >>> Thanks!
>> >>>
>> >>> I tried copying your code into my AppModule with some small
>> >> modifications.
>> >>> But the code only runs on server startup, not when I access a tapestry
>> 5
>> >>> page. I tried to add deliberate errors in the code, like naming the
>> >> server
>> >>> loooocalhost, but I never saw the results when accessing pages.
>> >>>
>> >>> Also, when I try to add "final HttpServletRequest request" as a
>> parameter
>> >>> to
>> >>> the contributeAlias method, my T5.0.13 crashes complaining about
>> service
>> >>> recursion.
>> >>>
>> >>> What I need is for T5 to figure out that a user accesses a page with
>> >>> either
>> >>> http or https, and respond on the same protocol...
>> >>>
>> >>>
>> >>> Regards
>> >>> Inge
>> >>>
>> >>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner <kb...@gmail.com>
>> >> wrote:
>> >>>> I believe you might be able to use an alternation of a solution I
>> used
>> >>> for
>> >>>> getting https to work properly between my development and production
>> >>>> servers.
>> >>>>
>> >>>> public static void contributeAlias(Configuration<AliasContribution>
>> >>>> configuration,
>> >>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
>> String
>> >>>> production
>> >>>>  {
>> >>>>                if (0 != production.compareToIgnoreCase("true"))
>> >>>>                {
>> >>>>              BaseURLSource source = new BaseURLSource()
>> >>>>              {
>> >>>>                  public String getBaseURL(boolean secure)
>> >>>>                  {
>> >>>>                      String protocol = secure ? "https" : "http";
>> >>>>
>> >>>>                      int port = secure ? 8443 : 8080;
>> >>>>
>> >>>>                      return String.format("%s://localhost:%d",
>> >> protocol,
>> >>>> port);
>> >>>>                  }
>> >>>>              };
>> >>>>
>> >>>>
>> >>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
>> >>> source));
>> >>>>                }
>> >>>>  }
>> >>>>
>> >>>> Somehow make this dependent on the user selection and return it
>> >>>> accordingly.
>> >>>>
>> >>>> Not a quick solution but possible a direction to try!
>> >>>>
>> >>>> Keith
>> >>>>
>> >>>>
>> >>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>> >>>>
>> >>>>  Hi!
>> >>>>> My web application is large and consists of Struts, T4 and T5 pages.
>> >> In
>> >>>>> Struts and T4, I use the current http request to figure out whether
>> to
>> >>> use
>> >>>>> https or not. Users can choose if they want to log in using https or
>> >>> not.
>> >>>>> The chosen protocol is used on all pages after login.
>> >>>>>
>> >>>>> In T5, this is either a global static setting, or a static setting
>> per
>> >>>>> page.
>> >>>>> Is there a service or something I can override to implement my own
>> >>>>> "protocol
>> >>>>> builder"? Something like this:
>> >>>>>
>> >>>>> public class HttpProtocolBuilder {
>> >>>>>  public HttpProtocolBuilder (final HttpServletRequest request) {
>> >>>>>   this.request = request
>> >>>>>  }
>> >>>>>
>> >>>>>  public String getProtocol() {
>> >>>>>   if (request.isSecure()) {
>> >>>>>     return "https";
>> >>>>>   }
>> >>>>>   else {
>> >>>>>    return "http";
>> >>>>>    }
>> >>>>> }
>> >>>>>
>> >>>>> Regards
>> >>>>>
>> >>>>> Inge
>> >>>>>
>> >>>>
>> >>>> ---------------------------------------------------------------------
>> >>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >>>> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>>>
>> >>>>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

Re: [T5] Pick up https/http from request

Posted by Inge Solvoll <in...@gmail.com>.
I know, this isn't really a problem for regular pages, they load using the
requested protocol, when not marked as secure. But when I create eventlinks
that updates zones, these don't work when they are generated with http and
the rest of the page is generated in https...

What I would like to do is to try some more on the BaseURLSource approach.
Anyone who's got any idea why this has no effect here? I copied and pasted
the code from the T5 docs and put in my Appmodule, and the contribute method
is called on server startup. I replaced the "localhost" url with an
obviously bad url, for testing, but nothing happens, all pages just load as
always, including eventlinks and actionlinks.

Inge

On Sun, Nov 16, 2008 at 9:44 PM, Carl Crowder <ca...@taptu.com>wrote:

> I don't know if you're aware, but if you create a href something like
>
> href="//something.com/page"
>
> then the current protocol is maintained. So if you were viewing the page
> at https://something.com the HREF would resolve to
> https://something.com/page and similarly with http. Unfortunately it
> requires using absolute URLs all the time.
>
> I'm not sure if that helps, but perhaps it could be used in fixing that
> issue.
>
> Carl
>
> Inge Solvoll wrote:
> > Yes, I might. This is a major blow for us, our customers choose freely
> > whether they want to use http or https, so the T5 way of doing things
> just
> > doesn't work for us...
> >
> > On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
> > jonathan.theitguy@gmail.com> wrote:
> >
> >> You might want to vote for this:
> >>
> >> https://issues.apache.org/jira/browse/TAP5-167
> >>
> >>
> >>> -----Original Message-----
> >>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
> >>> Sent: Friday, November 14, 2008 15:10
> >>> To: Tapestry users
> >>> Subject: Re: [T5] Pick up https/http from request
> >>>
> >>> Thanks!
> >>>
> >>> I tried copying your code into my AppModule with some small
> >> modifications.
> >>> But the code only runs on server startup, not when I access a tapestry
> 5
> >>> page. I tried to add deliberate errors in the code, like naming the
> >> server
> >>> loooocalhost, but I never saw the results when accessing pages.
> >>>
> >>> Also, when I try to add "final HttpServletRequest request" as a
> parameter
> >>> to
> >>> the contributeAlias method, my T5.0.13 crashes complaining about
> service
> >>> recursion.
> >>>
> >>> What I need is for T5 to figure out that a user accesses a page with
> >>> either
> >>> http or https, and respond on the same protocol...
> >>>
> >>>
> >>> Regards
> >>> Inge
> >>>
> >>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner <kb...@gmail.com>
> >> wrote:
> >>>> I believe you might be able to use an alternation of a solution I used
> >>> for
> >>>> getting https to work properly between my development and production
> >>>> servers.
> >>>>
> >>>> public static void contributeAlias(Configuration<AliasContribution>
> >>>> configuration,
> >>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final
> String
> >>>> production
> >>>>  {
> >>>>                if (0 != production.compareToIgnoreCase("true"))
> >>>>                {
> >>>>              BaseURLSource source = new BaseURLSource()
> >>>>              {
> >>>>                  public String getBaseURL(boolean secure)
> >>>>                  {
> >>>>                      String protocol = secure ? "https" : "http";
> >>>>
> >>>>                      int port = secure ? 8443 : 8080;
> >>>>
> >>>>                      return String.format("%s://localhost:%d",
> >> protocol,
> >>>> port);
> >>>>                  }
> >>>>              };
> >>>>
> >>>>
> >>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
> >>> source));
> >>>>                }
> >>>>  }
> >>>>
> >>>> Somehow make this dependent on the user selection and return it
> >>>> accordingly.
> >>>>
> >>>> Not a quick solution but possible a direction to try!
> >>>>
> >>>> Keith
> >>>>
> >>>>
> >>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
> >>>>
> >>>>  Hi!
> >>>>> My web application is large and consists of Struts, T4 and T5 pages.
> >> In
> >>>>> Struts and T4, I use the current http request to figure out whether
> to
> >>> use
> >>>>> https or not. Users can choose if they want to log in using https or
> >>> not.
> >>>>> The chosen protocol is used on all pages after login.
> >>>>>
> >>>>> In T5, this is either a global static setting, or a static setting
> per
> >>>>> page.
> >>>>> Is there a service or something I can override to implement my own
> >>>>> "protocol
> >>>>> builder"? Something like this:
> >>>>>
> >>>>> public class HttpProtocolBuilder {
> >>>>>  public HttpProtocolBuilder (final HttpServletRequest request) {
> >>>>>   this.request = request
> >>>>>  }
> >>>>>
> >>>>>  public String getProtocol() {
> >>>>>   if (request.isSecure()) {
> >>>>>     return "https";
> >>>>>   }
> >>>>>   else {
> >>>>>    return "http";
> >>>>>    }
> >>>>> }
> >>>>>
> >>>>> Regards
> >>>>>
> >>>>> Inge
> >>>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>>
> >>>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: [T5] Pick up https/http from request

Posted by Carl Crowder <ca...@taptu.com>.
I don't know if you're aware, but if you create a href something like

href="//something.com/page"

then the current protocol is maintained. So if you were viewing the page
at https://something.com the HREF would resolve to
https://something.com/page and similarly with http. Unfortunately it
requires using absolute URLs all the time.

I'm not sure if that helps, but perhaps it could be used in fixing that
issue.

Carl

Inge Solvoll wrote:
> Yes, I might. This is a major blow for us, our customers choose freely
> whether they want to use http or https, so the T5 way of doing things just
> doesn't work for us...
> 
> On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
> jonathan.theitguy@gmail.com> wrote:
> 
>> You might want to vote for this:
>>
>> https://issues.apache.org/jira/browse/TAP5-167
>>
>>
>>> -----Original Message-----
>>> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
>>> Sent: Friday, November 14, 2008 15:10
>>> To: Tapestry users
>>> Subject: Re: [T5] Pick up https/http from request
>>>
>>> Thanks!
>>>
>>> I tried copying your code into my AppModule with some small
>> modifications.
>>> But the code only runs on server startup, not when I access a tapestry 5
>>> page. I tried to add deliberate errors in the code, like naming the
>> server
>>> loooocalhost, but I never saw the results when accessing pages.
>>>
>>> Also, when I try to add "final HttpServletRequest request" as a parameter
>>> to
>>> the contributeAlias method, my T5.0.13 crashes complaining about service
>>> recursion.
>>>
>>> What I need is for T5 to figure out that a user accesses a page with
>>> either
>>> http or https, and respond on the same protocol...
>>>
>>>
>>> Regards
>>> Inge
>>>
>>> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner <kb...@gmail.com>
>> wrote:
>>>> I believe you might be able to use an alternation of a solution I used
>>> for
>>>> getting https to work properly between my development and production
>>>> servers.
>>>>
>>>> public static void contributeAlias(Configuration<AliasContribution>
>>>> configuration,
>>>>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final String
>>>> production
>>>>  {
>>>>                if (0 != production.compareToIgnoreCase("true"))
>>>>                {
>>>>              BaseURLSource source = new BaseURLSource()
>>>>              {
>>>>                  public String getBaseURL(boolean secure)
>>>>                  {
>>>>                      String protocol = secure ? "https" : "http";
>>>>
>>>>                      int port = secure ? 8443 : 8080;
>>>>
>>>>                      return String.format("%s://localhost:%d",
>> protocol,
>>>> port);
>>>>                  }
>>>>              };
>>>>
>>>>
>>>>  configuration.add(AliasContribution.create(BaseURLSource.class,
>>> source));
>>>>                }
>>>>  }
>>>>
>>>> Somehow make this dependent on the user selection and return it
>>>> accordingly.
>>>>
>>>> Not a quick solution but possible a direction to try!
>>>>
>>>> Keith
>>>>
>>>>
>>>> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>>>>
>>>>  Hi!
>>>>> My web application is large and consists of Struts, T4 and T5 pages.
>> In
>>>>> Struts and T4, I use the current http request to figure out whether to
>>> use
>>>>> https or not. Users can choose if they want to log in using https or
>>> not.
>>>>> The chosen protocol is used on all pages after login.
>>>>>
>>>>> In T5, this is either a global static setting, or a static setting per
>>>>> page.
>>>>> Is there a service or something I can override to implement my own
>>>>> "protocol
>>>>> builder"? Something like this:
>>>>>
>>>>> public class HttpProtocolBuilder {
>>>>>  public HttpProtocolBuilder (final HttpServletRequest request) {
>>>>>   this.request = request
>>>>>  }
>>>>>
>>>>>  public String getProtocol() {
>>>>>   if (request.isSecure()) {
>>>>>     return "https";
>>>>>   }
>>>>>   else {
>>>>>    return "http";
>>>>>    }
>>>>> }
>>>>>
>>>>> Regards
>>>>>
>>>>> Inge
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Pick up https/http from request

Posted by Inge Solvoll <in...@gmail.com>.
Yes, I might. This is a major blow for us, our customers choose freely
whether they want to use http or https, so the T5 way of doing things just
doesn't work for us...

On Fri, Nov 14, 2008 at 9:28 PM, Jonathan Barker <
jonathan.theitguy@gmail.com> wrote:

> You might want to vote for this:
>
> https://issues.apache.org/jira/browse/TAP5-167
>
>
> > -----Original Message-----
> > From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
> > Sent: Friday, November 14, 2008 15:10
> > To: Tapestry users
> > Subject: Re: [T5] Pick up https/http from request
> >
> > Thanks!
> >
> > I tried copying your code into my AppModule with some small
> modifications.
> > But the code only runs on server startup, not when I access a tapestry 5
> > page. I tried to add deliberate errors in the code, like naming the
> server
> > loooocalhost, but I never saw the results when accessing pages.
> >
> > Also, when I try to add "final HttpServletRequest request" as a parameter
> > to
> > the contributeAlias method, my T5.0.13 crashes complaining about service
> > recursion.
> >
> > What I need is for T5 to figure out that a user accesses a page with
> > either
> > http or https, and respond on the same protocol...
> >
> >
> > Regards
> > Inge
> >
> > On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner <kb...@gmail.com>
> wrote:
> >
> > > I believe you might be able to use an alternation of a solution I used
> > for
> > > getting https to work properly between my development and production
> > > servers.
> > >
> > > public static void contributeAlias(Configuration<AliasContribution>
> > > configuration,
> > >  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final String
> > > production
> > >  {
> > >                if (0 != production.compareToIgnoreCase("true"))
> > >                {
> > >              BaseURLSource source = new BaseURLSource()
> > >              {
> > >                  public String getBaseURL(boolean secure)
> > >                  {
> > >                      String protocol = secure ? "https" : "http";
> > >
> > >                      int port = secure ? 8443 : 8080;
> > >
> > >                      return String.format("%s://localhost:%d",
> protocol,
> > > port);
> > >                  }
> > >              };
> > >
> > >
> > >  configuration.add(AliasContribution.create(BaseURLSource.class,
> > source));
> > >                }
> > >  }
> > >
> > > Somehow make this dependent on the user selection and return it
> > > accordingly.
> > >
> > > Not a quick solution but possible a direction to try!
> > >
> > > Keith
> > >
> > >
> > > On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
> > >
> > >  Hi!
> > >>
> > >> My web application is large and consists of Struts, T4 and T5 pages.
> In
> > >> Struts and T4, I use the current http request to figure out whether to
> > use
> > >> https or not. Users can choose if they want to log in using https or
> > not.
> > >> The chosen protocol is used on all pages after login.
> > >>
> > >> In T5, this is either a global static setting, or a static setting per
> > >> page.
> > >> Is there a service or something I can override to implement my own
> > >> "protocol
> > >> builder"? Something like this:
> > >>
> > >> public class HttpProtocolBuilder {
> > >>  public HttpProtocolBuilder (final HttpServletRequest request) {
> > >>   this.request = request
> > >>  }
> > >>
> > >>  public String getProtocol() {
> > >>   if (request.isSecure()) {
> > >>     return "https";
> > >>   }
> > >>   else {
> > >>    return "http";
> > >>    }
> > >> }
> > >>
> > >> Regards
> > >>
> > >> Inge
> > >>
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

RE: [T5] Pick up https/http from request

Posted by Jonathan Barker <jo...@gmail.com>.
You might want to vote for this:

https://issues.apache.org/jira/browse/TAP5-167


> -----Original Message-----
> From: Inge Solvoll [mailto:inge.tapestry@gmail.com]
> Sent: Friday, November 14, 2008 15:10
> To: Tapestry users
> Subject: Re: [T5] Pick up https/http from request
> 
> Thanks!
> 
> I tried copying your code into my AppModule with some small modifications.
> But the code only runs on server startup, not when I access a tapestry 5
> page. I tried to add deliberate errors in the code, like naming the server
> loooocalhost, but I never saw the results when accessing pages.
> 
> Also, when I try to add "final HttpServletRequest request" as a parameter
> to
> the contributeAlias method, my T5.0.13 crashes complaining about service
> recursion.
> 
> What I need is for T5 to figure out that a user accesses a page with
> either
> http or https, and respond on the same protocol...
> 
> 
> Regards
> Inge
> 
> On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner <kb...@gmail.com> wrote:
> 
> > I believe you might be able to use an alternation of a solution I used
> for
> > getting https to work properly between my development and production
> > servers.
> >
> > public static void contributeAlias(Configuration<AliasContribution>
> > configuration,
> >  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final String
> > production
> >  {
> >                if (0 != production.compareToIgnoreCase("true"))
> >                {
> >              BaseURLSource source = new BaseURLSource()
> >              {
> >                  public String getBaseURL(boolean secure)
> >                  {
> >                      String protocol = secure ? "https" : "http";
> >
> >                      int port = secure ? 8443 : 8080;
> >
> >                      return String.format("%s://localhost:%d", protocol,
> > port);
> >                  }
> >              };
> >
> >
> >  configuration.add(AliasContribution.create(BaseURLSource.class,
> source));
> >                }
> >  }
> >
> > Somehow make this dependent on the user selection and return it
> > accordingly.
> >
> > Not a quick solution but possible a direction to try!
> >
> > Keith
> >
> >
> > On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
> >
> >  Hi!
> >>
> >> My web application is large and consists of Struts, T4 and T5 pages. In
> >> Struts and T4, I use the current http request to figure out whether to
> use
> >> https or not. Users can choose if they want to log in using https or
> not.
> >> The chosen protocol is used on all pages after login.
> >>
> >> In T5, this is either a global static setting, or a static setting per
> >> page.
> >> Is there a service or something I can override to implement my own
> >> "protocol
> >> builder"? Something like this:
> >>
> >> public class HttpProtocolBuilder {
> >>  public HttpProtocolBuilder (final HttpServletRequest request) {
> >>   this.request = request
> >>  }
> >>
> >>  public String getProtocol() {
> >>   if (request.isSecure()) {
> >>     return "https";
> >>   }
> >>   else {
> >>    return "http";
> >>    }
> >> }
> >>
> >> Regards
> >>
> >> Inge
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Pick up https/http from request

Posted by Inge Solvoll <in...@gmail.com>.
Thanks!

I tried copying your code into my AppModule with some small modifications.
But the code only runs on server startup, not when I access a tapestry 5
page. I tried to add deliberate errors in the code, like naming the server
loooocalhost, but I never saw the results when accessing pages.

Also, when I try to add "final HttpServletRequest request" as a parameter to
the contributeAlias method, my T5.0.13 crashes complaining about service
recursion.

What I need is for T5 to figure out that a user accesses a page with either
http or https, and respond on the same protocol...


Regards
Inge

On Fri, Nov 14, 2008 at 4:43 PM, Keith Bottner <kb...@gmail.com> wrote:

> I believe you might be able to use an alternation of a solution I used for
> getting https to work properly between my development and production
> servers.
>
> public static void contributeAlias(Configuration<AliasContribution>
> configuration,
>  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final String
> production
>  {
>                if (0 != production.compareToIgnoreCase("true"))
>                {
>              BaseURLSource source = new BaseURLSource()
>              {
>                  public String getBaseURL(boolean secure)
>                  {
>                      String protocol = secure ? "https" : "http";
>
>                      int port = secure ? 8443 : 8080;
>
>                      return String.format("%s://localhost:%d", protocol,
> port);
>                  }
>              };
>
>
>  configuration.add(AliasContribution.create(BaseURLSource.class, source));
>                }
>  }
>
> Somehow make this dependent on the user selection and return it
> accordingly.
>
> Not a quick solution but possible a direction to try!
>
> Keith
>
>
> On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:
>
>  Hi!
>>
>> My web application is large and consists of Struts, T4 and T5 pages. In
>> Struts and T4, I use the current http request to figure out whether to use
>> https or not. Users can choose if they want to log in using https or not.
>> The chosen protocol is used on all pages after login.
>>
>> In T5, this is either a global static setting, or a static setting per
>> page.
>> Is there a service or something I can override to implement my own
>> "protocol
>> builder"? Something like this:
>>
>> public class HttpProtocolBuilder {
>>  public HttpProtocolBuilder (final HttpServletRequest request) {
>>   this.request = request
>>  }
>>
>>  public String getProtocol() {
>>   if (request.isSecure()) {
>>     return "https";
>>   }
>>   else {
>>    return "http";
>>    }
>> }
>>
>> Regards
>>
>> Inge
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: [T5] Pick up https/http from request

Posted by Keith Bottner <kb...@gmail.com>.
I believe you might be able to use an alternation of a solution I used  
for getting https to work properly between my development and  
production servers.

public static void contributeAlias(Configuration<AliasContribution>  
configuration,
  @Inject @Value("${"+SymbolConstants.PRODUCTION_MODE+"}" ) final  
String production
  {
  		if (0 != production.compareToIgnoreCase("true"))
  		{
	      BaseURLSource source = new BaseURLSource()
	      {
	          public String getBaseURL(boolean secure)
	          {
	              String protocol = secure ? "https" : "http";
	
	              int port = secure ? 8443 : 8080;
	
	              return String.format("%s://localhost:%d", protocol,  
port);
	          }
	      };
	
	      configuration.add(AliasContribution.create(BaseURLSource.class,  
source));
  		}
  }

Somehow make this dependent on the user selection and return it  
accordingly.

Not a quick solution but possible a direction to try!

Keith

On Nov 14, 2008, at 7:18 AM, Inge Solvoll wrote:

> Hi!
>
> My web application is large and consists of Struts, T4 and T5 pages.  
> In
> Struts and T4, I use the current http request to figure out whether  
> to use
> https or not. Users can choose if they want to log in using https or  
> not.
> The chosen protocol is used on all pages after login.
>
> In T5, this is either a global static setting, or a static setting  
> per page.
> Is there a service or something I can override to implement my own  
> "protocol
> builder"? Something like this:
>
> public class HttpProtocolBuilder {
>  public HttpProtocolBuilder (final HttpServletRequest request) {
>    this.request = request
>  }
>
>  public String getProtocol() {
>    if (request.isSecure()) {
>      return "https";
>    }
>    else {
>     return "http";
>     }
> }
>
> Regards
>
> Inge


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org