You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Andreas Hartmann <an...@apache.org> on 2008/06/02 11:44:49 UTC

Re: How to load a JSP page "before" loading .../live/index.html

Hi,

jazzhazze schrieb:
> When a user visit my site I would like to load a custom .jsp page (index.jsp
> for example) with some script code, before the main Lenya index.html page of
> my publication is loaded?

I don't quite understand this - do you want to show this JSP page and 
then make a redirect to the index.html page?

> Which files do I have to modify to make that work,
> how should I modify them, and where should I put the .jsp file ?

You might try the JSPGenerator:

http://cocoon.apache.org/2.1/userdocs/jsp-generator.html

You could either store the JSP page as a Lenya document (with a 
dedicated resource type like "jsp"), or in the file system (depending on 
your requirements re. editing and versioning).

BTW, why do you want to use JSP? Did you already take a look at Cocoon 
Flow and JX templates?

-- Andreas


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to load a JSP page "before" loading .../live/index.html

Posted by jazzhazze <ha...@glocalnet.net>.
Thanks for the advice!

I've solved the problems by creating another publication in the tomcat
directory which contains the jsp files. To access my main publication, one
first loads the jsp file of the "dummy" publication, which forwards the
Windows user id to the Lenya login module. In this way it is possible to
target the jcifs filter to the dummy publication, thus avoiding "disturbing"
the main Lenya publication.

After some alterings of the login module, "manual" creation of users in
Lenya with usernames from the AD, I've succeded to create a kind of "ad hoc"
SSO-solution for Lenya. It is not pretty, but it works... 
 

Thorsten Scherler-3 wrote:
> 
> On Mon, 2008-06-02 at 03:01 -0700, jazzhazze wrote:
>> Thanks for the reply.
>> I would like to implement this jsp-page (or at least a modification of
>> it)
>> to solve my "old problem" with the authentication to certain pages of my
>> intranet-site. I want to use the url that is passed as a key to grant
>> access
>> to certain pages of my publication.
> 
> As I understand it you are trying to "just" set some request headers,
> right? To load a page before a page is NOT what you are not want nor
> should do in any apps.
> 
> You problem can be solved best as an Action.
> http://cocoon.apache.org/2.1/userdocs/concepts/actions.html
> 
> Use the action from
> http://cocoon.apache.org/2.1/userdocs/concepts/actions.html#Creating+the
> +Action as basis and add your code there. The part you need is setting
> the request headers and if auth fails the action should return null
> otherwise a empty map (not null !!!).
> 
> Then in your pub sitemap it would be something like:
> <map:match pattern="**">
>   <map:act type="AuthAction">
>     <map:generate src="{1}"/>
>     <map:serialize/>
>   </map:act>
>    <map:generate src="SomeErrorPage"/>
>    <map:serialize/>
> </map:match>
> 
> If you return an empty map (not null) the code inside the action is used
> and if you return null the other part.
> 
> In any case I personally would implement this with Apache http and the
> mod_auth (and a like).
> http://httpd.apache.org/docs/2.0/mod/mod_auth.html 
> 
> HTH
> 
> salu2
> -- 
> Thorsten Scherler                                 thorsten.at.apache.org
> Open Source Java                      consulting, training and solutions
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-load-a-JSP-page-%22before%22-loading-...-live-index.html-tp17552620p17866236.html
Sent from the Lenya - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to load a JSP page "before" loading .../live/index.html

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Mon, 2008-06-02 at 03:01 -0700, jazzhazze wrote:
> Thanks for the reply.
> I would like to implement this jsp-page (or at least a modification of it)
> to solve my "old problem" with the authentication to certain pages of my
> intranet-site. I want to use the url that is passed as a key to grant access
> to certain pages of my publication.

As I understand it you are trying to "just" set some request headers,
right? To load a page before a page is NOT what you are not want nor
should do in any apps.

You problem can be solved best as an Action.
http://cocoon.apache.org/2.1/userdocs/concepts/actions.html

Use the action from
http://cocoon.apache.org/2.1/userdocs/concepts/actions.html#Creating+the
+Action as basis and add your code there. The part you need is setting
the request headers and if auth fails the action should return null
otherwise a empty map (not null !!!).

Then in your pub sitemap it would be something like:
<map:match pattern="**">
  <map:act type="AuthAction">
    <map:generate src="{1}"/>
    <map:serialize/>
  </map:act>
   <map:generate src="SomeErrorPage"/>
   <map:serialize/>
</map:match>

If you return an empty map (not null) the code inside the action is used
and if you return null the other part.

In any case I personally would implement this with Apache http and the
mod_auth (and a like).
http://httpd.apache.org/docs/2.0/mod/mod_auth.html 

HTH

salu2
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to load a JSP page "before" loading .../live/index.html

Posted by jazzhazze <ha...@glocalnet.net>.
Thanks for the reply.
I would like to implement this jsp-page (or at least a modification of it)
to solve my "old problem" with the authentication to certain pages of my
intranet-site. I want to use the url that is passed as a key to grant access
to certain pages of my publication.

<%
String s = new String();
String auth = request.getHeader("Authorization");
if (auth == null) {
        response.setStatus(response.SC_UNAUTHORIZED);
        response.setHeader("WWW-Authenticate", "NTLM");
        return;
}
if (auth.startsWith("NTLM ")) {
        byte[] msg = new
sun.misc.BASE64Decoder().decodeBuffer(auth.substring(5));
        int off = 0, length, offset;

        if (msg[8] == 1) {
            off = 18;

            byte z = 0;
            byte[] msg1 = {(byte)'N', (byte)'T', (byte)'L', (byte)'M',
(byte)'S',
                            (byte)'S', (byte)'P', z,
                            (byte)2, z, z, z, z, z, z, z,
                            (byte)40, z, z, z, (byte)1, (byte)130, z, z,
                            z, (byte)2, (byte)2, (byte)2, z, z, z, z, //
                            z, z, z, z, z, z, z, z};
            //
            response.setStatus(response.SC_UNAUTHORIZED);
            response.setHeader("WWW-Authenticate", "NTLM "
                  + new sun.misc.BASE64Encoder().encodeBuffer(msg1).trim());
            return;
        }
        else if (msg[8] == 3) {
                off = 30;
                length = msg[off+17]*256 + msg[off+16];
                offset = msg[off+19]*256 + msg[off+18];
                s = new String(msg, offset, length);
                //out.println(s + " ");
        }
        else
                return;

        length = msg[off+1]*256 + msg[off];
        offset = msg[off+3]*256 + msg[off+2];
        s = new String(msg, offset, length);

        //out.println(s + " ");

        length = msg[off+9]*256 + msg[off+8];
        offset = msg[off+11]*256 + msg[off+10];
        s = new String(msg, offset, length);

	}

String lettres = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" ;
s = s.toUpperCase() ;
String compte = "" ;
char c ;
int i = 0 ;
while(i < s.length()) {
	c = s.charAt(i) ;
	if(lettres.indexOf(c) != -1) {
		compte = compte+""+c ;
	}
	i++ ;
}
s = compte;

StringBuffer url = new StringBuffer();
url = url.append ("/servlet/Identification?id=");
url = url.append (s);
%>

<html>
<head>
<title>Lutece</title>
</head>
<body>
<jsp:forward page="<%=url.toString()%>" />
</body>
</html>


Andreas Hartmann wrote:
> 
> Hi,
> 
> jazzhazze schrieb:
>> When a user visit my site I would like to load a custom .jsp page
>> (index.jsp
>> for example) with some script code, before the main Lenya index.html page
>> of
>> my publication is loaded?
> 
> I don't quite understand this - do you want to show this JSP page and 
> then make a redirect to the index.html page?
> 
>> Which files do I have to modify to make that work,
>> how should I modify them, and where should I put the .jsp file ?
> 
> You might try the JSPGenerator:
> 
> http://cocoon.apache.org/2.1/userdocs/jsp-generator.html
> 
> You could either store the JSP page as a Lenya document (with a 
> dedicated resource type like "jsp"), or in the file system (depending on 
> your requirements re. editing and versioning).
> 
> BTW, why do you want to use JSP? Did you already take a look at Cocoon 
> Flow and JX templates?
> 
> -- Andreas
> 
> 
> -- 
> Andreas Hartmann, CTO
> BeCompany GmbH
> http://www.becompany.ch
> Tel.: +41 (0) 43 818 57 01
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-load-a-JSP-page-%22before%22-loading-...-live-index.html-tp17552620p17597834.html
Sent from the Lenya - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to load a JSP page "before" loading .../live/index.html

Posted by jazzhazze <ha...@glocalnet.net>.
BTW, I would like to load the JSP page before the actual index.html page of
my publication.


Andreas Hartmann wrote:
> 
> Hi,
> 
> jazzhazze schrieb:
>> When a user visit my site I would like to load a custom .jsp page
>> (index.jsp
>> for example) with some script code, before the main Lenya index.html page
>> of
>> my publication is loaded?
> 
> I don't quite understand this - do you want to show this JSP page and 
> then make a redirect to the index.html page?
> 
>> Which files do I have to modify to make that work,
>> how should I modify them, and where should I put the .jsp file ?
> 
> You might try the JSPGenerator:
> 
> http://cocoon.apache.org/2.1/userdocs/jsp-generator.html
> 
> You could either store the JSP page as a Lenya document (with a 
> dedicated resource type like "jsp"), or in the file system (depending on 
> your requirements re. editing and versioning).
> 
> BTW, why do you want to use JSP? Did you already take a look at Cocoon 
> Flow and JX templates?
> 
> -- Andreas
> 
> 
> -- 
> Andreas Hartmann, CTO
> BeCompany GmbH
> http://www.becompany.ch
> Tel.: +41 (0) 43 818 57 01
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-load-a-JSP-page-%22before%22-loading-...-live-index.html-tp17552620p17599610.html
Sent from the Lenya - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org