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 <
[EMAIL PROTECTED]> 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" <[EMAIL PROTECTED]>
26.11.2008 11:37
Bitte antworten an
"Tapestry users" <users@tapestry.apache.org>
An
"Tapestry users" <users@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
<[EMAIL PROTECTED]
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 <[EMAIL PROTECTED]
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 <[EMAIL PROTECTED]
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 <[EMAIL PROTECTED]
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 <
[EMAIL PROTECTED]> wrote:
You might want to vote for this:
https://issues.apache.org/jira/browse/TAP5-167
-----Original Message-----
From: Inge Solvoll [mailto:[EMAIL PROTECTED]
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
<[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]