I haven't tried generating a cookie from scratch, I prefer to avoid storing the password on the client, but I've modified something I use to also include the rememberme cookie. Attached, hope that helps.

-Arne


On 11/26/10 4:40 PM, Jamie Popkin wrote:
Good to know... Thanks Alexandre.

On Thu, Nov 25, 2010 at 3:22 PM, Jamie Popkin <[email protected] <mailto:[email protected]>> wrote:

    Interesting... Could it be how you're generating the hash in your
    php code? I'm struggling with the same issue and trying to avoid
    it with Perl CGI... With no solution as of yet.

    I'm going to start another thread regarding authenticating by
    generating your own cookie.... Maybe that will solve your problem
    as well.

    Jamie


    On Thu, Nov 25, 2010 at 2:01 PM, Alexandre Busquets
    <[email protected] <mailto:[email protected]>> wrote:

        The layer works correctly without password protection

        2010/11/25 Jamie Popkin <[email protected]
        <mailto:[email protected]>>:
        > Hmmm... If you are successfully logged in and still can't
        see the layer... I
        > would check to make sure the layer actually works when not
        password
        > protected.


/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
    
$cookie_file = SET PATH HERE, CONSIDER CONCURRENT REQUESTS
$geoserver_url = 'HOST/geoserver/j_acegi_security_check';
$post_str = 'username=' . urlencode(USERNAME) . '&password=' . 
urlencode(CLEARTEXTPASSWORD) . '&_acegi_security_remember_me=on';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $geoserver_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch,CURLOPT_POST, 3);
curl_setopt($ch,CURLOPT_POSTFIELDS, $post_str);

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);

$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
   
$fh = fopen($cookie_file, 'r');

// THE CODE BELOW ASSUMES A FIXED ORDER FOR THE COOKIES.
// MAY BREAK BETWEEN CURL OR GS UPDATES!
// ALSO, I'VE OMITTED THE FAILURE SECTION BECAUSE IT'S NOT GENERAL

// Skip 3 lines
for($i=0;$i<4;$i++) {
    $line = fgets($fh);
}

// JSESSIONID  
$line = fgets($fh);
$tokens = split("\t", $line);
setcookie(trim($tokens[5]),trim($tokens[6]), 0, '/geoserver');

// ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE
$line = fgets($fh);
$tokens = split("\t", $line);
setrawcookie(trim($tokens[5]),trim($tokens[6]), (time() + 
14*24*3600),'/geoserver');
fclose($fh);
    
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to