incubator-clerezza-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reto Bachmann-Gmuer <reto.bachm...@trialox.org>
Subject Re: problem with Cookie Authentication Bundle / Access via Java HTTP Call
Date Thu, 11 Feb 2010 16:27:30 GMT
you can get a fairly recent build on

http://hudson.zones.apache.org/hudson/job/clerezza-trunk-1.6/org.apache.clerezza$org.apache.clerezza.platform.launcher.sesame/

cheers,
reto

On Wed, Feb 10, 2010 at 4:18 PM, Oliver Strässer <
oliver.straesser@getunik.com> wrote:

> can you please create an new sesame launcher, where the bug is fixed?
>
>
>
>
> --getunik ag-------------------------------------------
>   oliver straesser              oliver.straesser@getunik.com
>   hardturmstrasse 101    fon: +41 (0)44 388 55 88
>   ch-8005 zuerich              fax: +41 (0)44 388 55 89
>
>    --aktuelles getunik projekt-------------------------
>    Agieren Sie lokal! Geo Marketing für Ihre E-Mail Kampagne:
> www.geomarketing.com
>
>  --best of swiss web awards 2009------------------
>    Gold & Silber für Connect2Earth / Bronze für WWF UK
>
> we make the web a better place - www.getunik.com
>
>
>
>
> *****************************************************************
> Bitte drucken Sie dieses E-Mail nur bei Bedarf aus. Die Umwelt dankt es
> Ihnen.
> *****************************************************************
>
>
> -----Ursprüngliche Nachricht-----
> Von: manuel.innerhofer@trialox.org [mailto:manuel.innerhofer@trialox.org]
> Gesendet: Dienstag, 9. Februar 2010 15:51
> An: clerezza-dev@incubator.apache.org
> Betreff: Re: problem with Cookie Authentication Bundle / Access via Java
> HTTP Call
>
> Hi Oli,
>
> Thanks for opening the issue. It's a bug in the platform (in
> org.apache.clerezza.triaxrs) and it is fixed now.
> The reason for this server error (500) response is that the java.net
> implementation sends a malformed ACCEPT-header. It contains "*;.2",
> which is wrong. But the Clerezza platform should only write a warning in
> the console (which it does), but at one point we missed to catch the
> exception, which lead to the server error.
> You could have also modified your code to send a proper ACCEPT-header.
> Following is your modified code that should work with the platform
> containing the bug (pre revision 908057).
>
> package test;
> import java.io.BufferedReader;
> import java.io.IOException;
> import java.io.InputStreamReader;
> import java.net.Authenticator;
> import java.net.HttpURLConnection;
> import java.net.InetAddress;
> import java.net.MalformedURLException;
> import java.net.PasswordAuthentication;
> import java.net.URL;
>
> /**
>  *
>  * @author osr
>  */
> public class Main {
>
>    /**
>     * @param args the command line arguments
>     */
>    public static void main(String[] args) {
>        System.out.println("Starting request");
>
>        // TODO code application logic here
>
>
> // Access the page
>        try {
>            Authenticator.setDefault(new MyAuthenticator());
>
>            // Create a URL for the desired page
>            URL url = new
> URL("http://localhost:8080/admin/user-manager/");
>                        HttpURLConnection con = (HttpURLConnection)
> url.openConnection();
>                        con.setRequestProperty("Accept",
> "application/rdf+xml"); // set a
> proper Accept-header
>            // Read all the text returned by the server
>            BufferedReader in = new BufferedReader(new
> InputStreamReader(con.getInputStream()));
>            String str;
>            while ((str = in.readLine()) != null) {
>                // str is one line of text; readLine() strips the
> newline character(s)
>                System.out.println(str);
>            }
>            in.close();
>        } catch (MalformedURLException e) {
>            System.out.println("MalformedURLException");
>        } catch (IOException e) {
>            System.out.println("IOException: " + e.getMessage());
>        }
>    }
>
>    public static class MyAuthenticator extends Authenticator {
>        // This method is called when a password-protected URL is
> accessed
>
>        @Override
>        protected PasswordAuthentication getPasswordAuthentication() {
>            System.out.println("getPasswordAuthentication");
>            // Get information about the request
>            String promptString = getRequestingPrompt();
>            String hostname = getRequestingHost();
>            InetAddress ipaddr = getRequestingSite();
>            int port = getRequestingPort();
>            // Get the username from the user...
>            String username = "admin";
>            // Get the password from the user...
>            String password = "admin";
>            // Return the information
>            return new PasswordAuthentication(username,
> password.toCharArray());
>        }
>    }
> }
>
> Cheers,
> Manuel
>
> On Mon, 2010-02-08 at 08:36 -0500, Oliver Strässer wrote:
> > I try to connect to the Trialox and have problems with the redirecting
> to the login screen.
> > I tried the following code to connect to the Trialox system.
> >
> > if I deactivate the Clerezza - Platform Security Cookie Authentication
> Bundle, the code worked correctly and the authentication is successful.
> > if I activate the bundle my response is:  Server returned HTTP response
> code: 500 for URL:
>
> http://localhost:8080/login?referer=%2Fmacc%2Fcontent%2Forg.greenpeace.ch&cause=1
> >
> > is that an error on my side or at the cookie bundle
> >
> > How is the correct way ?
> >
> > /*
> >  * To change this template, choose Tools | Templates
> >  * and open the template in the editor.
> >  */
> > package test;
> >
> > import java.io.BufferedReader;
> > import java.io.IOException;
> > import java.io.InputStreamReader;
> > import java.net.Authenticator;
> > import java.net.InetAddress;
> > import java.net.MalformedURLException;
> > import java.net.PasswordAuthentication;
> > import java.net.URL;
> >
> > /**
> >  *
> >  * @author osr
> >  */
> > public class Main {
> >
> >     /**
> >      * @param args the command line arguments
> >      */
> >     public static void main(String[] args) {
> >         System.out.println("Starting request");
> >
> >         // TODO code application logic here
> >
> >
> > // Access the page
> >         try {
> >             Authenticator.setDefault(new MyAuthenticator());
> >
> >             // Create a URL for the desired page
> >             URL url = new
> URL("http://localhost:8080/macc/content/org.greenpeace.ch");
> >             // Read all the text returned by the server
> >             BufferedReader in = new BufferedReader(new
> InputStreamReader(url.openStream()));
> >             String str;
> >             while ((str = in.readLine()) != null) {
> >                 // str is one line of text; readLine() strips the
> newline character(s)
> >                 System.out.println(str);
> >             }
> >             in.close();
> >         } catch (MalformedURLException e) {
> >             System.out.println("MalformedURLException");
> >         } catch (IOException e) {
> >             System.out.println("IOException: " + e.getMessage());
> >         }
> >     }
> >
> >     public static class MyAuthenticator extends Authenticator {
> >         // This method is called when a password-protected URL is
> accessed
> >
> >         @Override
> >         protected PasswordAuthentication getPasswordAuthentication() {
> >             System.out.println("getPasswordAuthentication");
> >             // Get information about the request
> >             String promptString = getRequestingPrompt();
> >             String hostname = getRequestingHost();
> >             InetAddress ipaddr = getRequestingSite();
> >             int port = getRequestingPort();
> >             // Get the username from the user...
> >             String username = "admin";
> >             // Get the password from the user...
> >             String password = "admin";
> >             // Return the information
> >             return new PasswordAuthentication(username,
> password.toCharArray());
> >         }
> >     }
> > }
> >
> >
> >
> >
> >
> > --getunik ag-------------------------------------------
> >   oliver straesser
> oliver.straesser@getunik.com<mailto:oliver.straesser@getunik.com>
> >   hardturmstrasse 101    fon: +41 (0)44 388 55 88
> >   ch-8005 zuerich              fax: +41 (0)44 388 55 89
> >
> >    --aktuelles getunik projekt-------------------------
> >    Agieren Sie lokal! Geo Marketing für Ihre E-Mail Kampagne:
> www.geomarketing.com<http://www.geomarketing.com/>
> >
> >  --best of swiss web awards 2009------------------
> >    Gold & Silber für Connect2Earth / Bronze für WWF UK
> >
> > we make the web a better place - www.getunik.com<http://www.getunik.com/
> >
> >
> >
> >
> >
> > *****************************************************************
> > P Bitte drucken Sie dieses E-Mail nur bei Bedarf aus. Die Umwelt dankt
> es Ihnen.
> > *****************************************************************
> >
>
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message