I haven't used the later versions of tapestry (I'm still back on 5.1 or
5.2 or something).
By I replaced the BaseURLSource with my own version.
Just Note: This might not be what you want. It uses the requested port
to determine what port to use on generating links.
Something like this:
package www.services;
import javax.servlet.http.HttpServletRequest;
import org.apache.tapestry5.services.BaseURLSource;
import org.apache.tapestry5.services.RequestGlobals;
public class MyBaseURLSource implements BaseURLSource {
private HttpServletRequest request;
private RequestGlobals requestGlobals;
public MyBaseURLSource(RequestGlobals requestGlobals) {
this.requestGlobals = requestGlobals;
}
public String getBaseURL(boolean secure) {
request = requestGlobals.getHTTPServletRequest();
String hostName = request.getServerName();
int port = request.getServerPort();
if (request.isSecure() == secure) {
if (secure) return "https://" + hostName + (port == 443 ?
"" : ":" + port);
if (!secure) return "http://" + hostName + (port == 80 ? ""
: ":" + port);
}
if (secure) return "https://" + hostName;
return "http://" + hostName;
}
}
Then override it in your AppModule
binder.bind(BaseURLSource.class,
MyBaseURLSource.class).withId("Override");
Thanks, Ryan
On 3/06/2013 7:16 PM, John wrote:
Thanks for that, I guess these settings need to match the externally visible
sockets?
We are using NAT to reassign ports externally. But if we do that then the app
won't work when accessed on the internal network?
regards,
John
----- Original Message -----
From: Alejandro Scandroli
To: Tapestry users
Sent: Monday, June 03, 2013 10:52 AM
Subject: Re: Tapestry links not https
Hi John
These are configuration symbols: http://tapestry.apache.org/symbols.html
One way (there are other ways) you can configured them is through the
ApplicationDefaults provider
public static void
contributeApplicationDefaults(MappedConfiguration<String, Object>
configuration)
{
configuration.add(SymbolConstants.HOSTPORT, 8080);
configuration.add(SymbolConstants.HOSTPORT_SECURE, 8443);
}
Alejandro.
On Fri, May 31, 2013 at 11:44 PM, John <j...@quivinco.com> wrote:
> Hi,
>
> Thanks for pointing out that problem.
>
> Should I set these ports to match my Jetty config, where should I set
these values? Have you got a code snippet pls?
>
> John
> ----- Original Message -----
> From: Alejandro Scandroli
> To: Tapestry users
> Sent: Friday, May 31, 2013 9:29 PM
> Subject: Re: Tapestry links not https
>
>
> John, make sure you set both SymbolConstants.HOSTPORT and
> SymbolConstants.HOSTPORT_SECURE.
> There is a tiny issue with this if you don't do it, see my comments
> here: https://issues.apache.org/jira/browse/TAP5-1973
>
> Alejandro.
>
> On Fri, May 31, 2013 at 10:20 PM, John <j...@quivinco.com> wrote:
> > Yes, I see that.
> >
> > I added the @Secure to some of my pages, they work fine now, but my
pages without @Secure write http://hostname:443 which is screwed up. We only use port
443 externally, in Jetty it's 8443.
> >
> > I guess I need something like below to set the right ports, the server
name is fine though so I don't need to set that.
> >
> > John
> > ----- Original Message -----
> > From: Dmitry Gusev
> > To: Tapestry users
> > Sent: Friday, May 31, 2013 9:01 PM
> > Subject: Re: Tapestry links not https
> >
> >
> > Sorry, looks like you've cited this page, but there's a code sample
that
> > controls port numbers:
> >
> >
> > public static void
> > contributeServiceOverride(MappedConfiguration<Class,Object>
> > configuration)
> > {
> > 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(BaseURLSource.class, source);
> > }
> >
> >
> > On Fri, May 31, 2013 at 11:54 PM, Dmitry Gusev
<dmitry.gu...@gmail.com>wrote:
> >
> > > Have you read this:
> > >
> > > http://tapestry.apache.org/https.html
> > >
> > >
> > > On Fri, May 31, 2013 at 11:50 PM, John <j...@quivinco.com> wrote:
> > >
> > >> hmm, ok so I just read this...
> > >>
> > >> Links to non-secure pages from a secure page will do the reverse:
a
> > >> complete URL with an "http" protocol will be used. In other
words, Tapestry
> > >> manages the transition from insecure to secure and back again.
> > >>
> > >> So tapestry is writing the http:// that for non-secure pages, but
is
> > >> unaware of the port number. I'd like to secure the whole site at
> > >> deployment, rather than have SSL running on my test box. Is there
a way to
> > >> do that?
> > >>
> > >> It seems I must follow the Tapestry way of @Secure in the pages,
but
> > >> that's not configurable.
> > >>
> > >> John
> > >> ----- Original Message -----
> > >> From: John
> > >> To: users@tapestry.apache.org
> > >> Sent: Friday, May 31, 2013 8:45 PM
> > >> Subject: Tapestry links not https
> > >>
> > >>
> > >> My tapestry app doesn't work with SSL set up, the links have
port 443
> > >> added but start http://.
> > >>
> > >> There must be some configuration missing?
> > >>
> > >> John
> > >>
> > >
> > >
> > >
> > > --
> > > Dmitry Gusev
> > >
> > > AnjLab Team
> > > http://anjlab.com
> > >
> >
> >
> >
> > --
> > Dmitry Gusev
> >
> > AnjLab Team
> > http://anjlab.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org