Hi Jason,

Sorry for the long time to answer your question.

I don't understand what's happen with the OAuth, because now I
received other error with same code.

--------------THIS is my Server Code (exactly its presented in the
article ):---------

package auth;
import net.oauth.OAuthAccessor;
import net.oauth.OAuthConsumer;
import net.oauth.OAuthMessage;
import net.oauth.OAuthProblemException;
import net.oauth.OAuthServiceProvider;
import net.oauth.OAuthValidator;
import net.oauth.SimpleOAuthValidator;
import net.oauth.server.OAuthServlet;
import net.oauth.signature.RSA_SHA1;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class SignedFetchVerifyServlet extends HttpServlet {

  /**
         *
         */
        private static final long serialVersionUID = 1L;


private final static String CERTIFICATE =
        "-----BEGIN CERTIFICATE-----"
        + "MIIDHDCCAoWgAwIBAgIJAMbTCksqLiWeMA0GCSqGSIb3DQEBBQUAMGgxCzAJBgNV"
        + "BAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIG"
        + "A1UEChMLR29vZ2xlIEluYy4xDjAMBgNVBAsTBU9ya3V0MQ4wDAYDVQQDEwVscnlh"
        + "bjAeFw0wODAxMDgxOTE1MjdaFw0wOTAxMDcxOTE1MjdaMGgxCzAJBgNVBAYTAlVT"
        + "MQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChML"
        + "R29vZ2xlIEluYy4xDjAMBgNVBAsTBU9ya3V0MQ4wDAYDVQQDEwVscnlhbjCBnzAN"
        + "BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAseBXZ4NDhm24nX3sJRiZJhvy9eDZX12G"
        + "j4HWAMmhAcnm2iBgYpAigwhVHtOs+ZIUIdzQHvHeNd0ydc1Jg8e+C+Mlzo38OvaG"
        + "D3qwvzJ0LNn7L80c0XVrvEALdD9zrO+0XSZpTK9PJrl2W59lZlJFUk3pV+jFR8NY"
        + "eB/fto7AVtECAwEAAaOBzTCByjAdBgNVHQ4EFgQUv7TZGZaI+FifzjpTVjtPHSvb"
        + "XqUwgZoGA1UdIwSBkjCBj4AUv7TZGZaI+FifzjpTVjtPHSvbXqWhbKRqMGgxCzAJ"
        + "BgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEU"
        + "MBIGA1UEChMLR29vZ2xlIEluYy4xDjAMBgNVBAsTBU9ya3V0MQ4wDAYDVQQDEwVs"
        + "cnlhboIJAMbTCksqLiWeMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEA"
        + "CETnhlEnCJVDXoEtSSwUBLP/147sqiu9a4TNqchTHJObwTwDPUMaU6XIs2OTMmFu"
        + "GeIYpkHXzTa9Q6IKlc7Bt2xkSeY3siRWCxvZekMxPvv7YTcnaVlZzHrVfAzqNsTG"
        + "P3J//C0j+8JWg6G+zuo5k7pNRKDY76GxxHPYamdLfwk="
        + "-----END CERTIFICATE-----";


  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse
resp)
      throws ServletException, IOException {
    verifyFetch(req, resp);
  }


  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse
resp)
      throws ServletException, IOException {
    verifyFetch(req, resp);
  }


  private void verifyFetch(HttpServletRequest request,
HttpServletResponse resp)
      throws IOException, ServletException {
    resp.setContentType("text/html; charset=UTF-8");
    PrintWriter out = resp.getWriter();

    try {
      OAuthServiceProvider provider =
          new OAuthServiceProvider(null, null, null);
      OAuthConsumer consumer =
          new OAuthConsumer(null, "orkut.com", null, provider);
      consumer.setProperty(RSA_SHA1.X509_CERTIFICATE, CERTIFICATE);
      OAuthMessage message = OAuthServlet.getMessage(request, null);

      OAuthAccessor accessor = new OAuthAccessor(consumer);
      out.print("*** OAuthMessage Params:");
      out.print("<br>URL: " + OAuthServlet.htmlEncode(message.URL));
      for (java.util.Map.Entry param : message.getParameters()) {
        String key = param.getKey().toString();
        String value = param.getValue().toString();
        out.print("<br>");
        out.print("Param Name-->" + OAuthServlet.htmlEncode(key));
        out.print("&nbsp;");
        out.print("Value-->" + OAuthServlet.htmlEncode(value));
      }
      out.print("<br>");
      out.print(" VALIDATING SIGNATURE ");
      out.print("<br>");
      message.validateSignature(accessor);
      //OAuthValidator validator = new SimpleOAuthValidator();
      //validator.validateMessage(message, accessor);
      out.print("REQUEST STATUS::OK");
      out.print("<br>");
    } catch (OAuthProblemException ope) {
      out.print("<br>");
      out.print("OAuthProblemException-->"
          + OAuthServlet.htmlEncode(ope.getProblem()));
     } catch (Exception e) {
         out.println(e);
         System.out.println(e);
      throw new ServletException(e);
    } finally {

      out.flush();

    }
  }

}




-------------------AND This is My Client Code (exactly presented in
the article too, I change only the makeRequest URL):------------------
<?xml version="1.0" encoding="UTF-8"?>
<Module>
 <ModulePrefs title="oAuth Java Example">
   <Require feature="opensocial-0.7"></Require>
   <Require feature="dynamic-height"></Require>
 </ModulePrefs>
 <Content type="html">
  <![CDATA[
   <script type="text/javascript">
     var servletUrl="http://200.143.19.19:8080/opensocial/
SignedFetchVerifyServlet";

     function response(data) {
       document.getElementById('dom_handle').innerHTML=data.text;
     };

     function request() {
       var params={};
       params[gadgets.io.RequestParameters.AUTHORIZATION] =
gadgets.io.AuthorizationType.SIGNED;
       gadgets.io.makeRequest(servletUrl,response,params);
     };

     gadgets.util.registerOnLoadHandler(request);
   </script>

   <div id="dom_handle"></div>
  ]]>
  </Content>
</Module>



------------AND Now I received OTHER error with same
code:-------------

*** OAuthMessage Params:
URL: http://200.143.19.19/opensocial/SignedFetchVerifyServlet
Param Name-->oauth_consumer_key Value-->orkut.com
Param Name-->oauth_nonce Value-->56b18b0b9b8e3782
Param Name-->opensocial_app_id Value-->16779347088120873432
Param Name-->opensocial_viewer_id Value-->14142410513136437956
Param Name-->oauth_timestamp Value-->1214914475
Param Name-->opensocial_owner_id Value-->14142410513136437956
Param Name-->oauth_signature Value-->TCz//879WtyIzZQbn7JJYjzQD9oBYjuZL/
FtxQkc2KkVvW4qqRvxC0JtHSPxtdPp6w9fJQeGG5blrIyahNDdOv07ohR501fJBY40ISIi8op/
IaYOtRrdtous0SAWygmlDJ05L4PrhBdTqxWsc7oLrfXHrbv/sTLxdU5Fw9JA1p4=
Param Name-->xoauth_signature_publickey Value-->pub.
1199819524.-1556113204990931254.cer
Param Name-->oauth_token Value-->
Param Name-->oauth_signature_method Value-->RSA-SHA1
VALIDATING SIGNATURE
net.oauth.OAuthException: java.security.cert.CertificateException:
Could not parse certificate: java.io.IOException: Unsupported encoding


Can you Help me? I am confused with this differents errors.

Thanks in Advanced,

Renan Ribeiro


On 26 jun, 21:37, Jason <[EMAIL PROTECTED]> wrote:
> Are you using the servlet exactly as its presented in the article? Can
> you provide a snippet of your client-side code that requests this
> resource?
>
> - Jason
>
> On Jun 24, 7:02 am, Renan <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I did the Java example of the OAuth wiki 
> > (http://code.google.com/p/opensocial-resources/wiki/OrkutValidatingSig...
> > ). But I don't have success, I did exataly like the example, and I get
> > this error:
>
> > *** OAuthMessage Params:
> > URL:http://200.143.19.19/opensocial/SignedFetchVerifyServlet
> > Param Name-->oauth_nonce Value-->5d5aa2c285976ee9
> > Param Name-->opensocial_viewer_id Value-->14142410513136437956
> > Param Name-->oauth_timestamp Value-->1214311012
> > Param Name-->opensocial_owner_id Value-->14142410513136437956
> > Param Name-->xoauth_signature_publickey Value-->pub.
> > 1199819524.-1556113204990931254.cer
> > Param Name-->oauth_token Value-->
> > Param Name-->oauth_consumer_key Value-->orkut.com
> > Param Name-->opensocial_app_id Value-->16779347088120873432
> > Param Name-->oauth_signature 
> > Value-->UGg9fa33rQnuxXGVmWOZWH2yr6QrjBpXSUFx40rcdEo0BFftxhh3c3ObP
>
> > +BI4fb0QCD1ufanW
> > +wsaegSG0A4o1UfXgZYTg319PesPU9uqa62ZwCtwDS1QGFQMNPwUWMkLbG2J2D5FT0ElXT75f5+cPqcJsWOb7YVdlWMwYZz/
> > 2A=
> > Param Name-->oauth_signature_method Value-->RSA-SHA1
> > VALIDATING SIGNATURE
>
> > OAuthProblemException-->signature_invalid
>
> > I research a lot for an answer, Who was able to do this in Java?
>
> > PS: Sorry for english errors, I don't know to write in english very
> > well.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Orkut Developer Forum" group.
To post to this group, send email to opensocial-orkut@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/opensocial-orkut?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to