일반 자바 서버 프로그램에서 java jdk1.6 / os : 2003 서버 구성

 

아래와 같이  오류가 발생합니다.

 

정상적으로 인증받아서.. 회신 메일로 왔구요.. 근데 뭐가 문제인지? 도대체 알수가 없네요..

 

pc의 환경설정에 뭐 해줘야 하는지 아니면 현재 해당 구글 서비스가 안된는건지 알수가 없네요...

 tgsvc0001@gmail.com 메일도 정상적으로 로그인 됩니다....

 

그래서 다시 한번 문의 드립니다.

 

 

=========회신 메일=====================

Thank you for your interest in Android Cloud to Device Messaging (C2DM).
We've accepted your application into the trial group. The Google account
you requested as the sender account for your application:

   tgsvc0001@gmail.com

has been added to our list of allowed senders, and you should be able to
start using it to send messages to Android 2.2 devices within the next
day or so. If at any point you'd like to change the role account used for
sending messages, please fill out the sign-up form again.

By default, all new sender accounts are granted an initial production-level
quota as documented in:

   http://code.google.com/android/c2dm/quotas.html

If you need a higher quota, please follow the instructions on that page
to submit a quota request.

Note that since Android Cloud to Device Messaging is currently an API in Labs,
we reserve the right to fundamentally change the service and associated quotas
at any time.

For more information on Android Cloud to Device Messaging, you can read
our documentation and sample code at:

   http://code.google.com/android/c2dm/

If you have questions or feedback, please visit the Google Group at:

   http://groups.google.com/group/android-c2dm

Please don't reply to this email, since the sender address is unmonitored.

Thanks,
Android Cloud to Device Messaging Team

 

 

=================오류 메세세지==================

java.io.IOException: Server returned HTTP response code: 403 for URL: https://www.google.com/accounts/ClientLogin
 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1313)
 at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
 at com.incross.c2dm.service.C2dmMain.getAuthToken(C2dmMain.java:141)
 at com.incross.c2dm.service.C2dmMain.main(C2dmMain.java:172)

==================소스====================

package com.incross.c2dm.service;

 

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.URL;
import java.net.URLEncoder;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;


public class C2dmMain{
 
  private OutputStream out = null;
 
  public void sender(String regId,String authToken) throws Exception
  {
      StringBuffer postDataBuilder = new StringBuffer();
  }
 
 
  private String getAuthToken() throws Exception
   {
     String email = "strawberryit@gmail.com";
     String password = "tempmytrace";
     String authTokenUrl = "https://www.google.com/accounts/ClientLogin";
     StringBuffer parameter = new StringBuffer();

     parameter.append("accountType=HOSTED_OR_GOOGLE");
     parameter.append("&Email=tgsvc0001@gmail.com");
     parameter.append("&Passwd=????????");
     parameter.append("&service=ac2dm");
     parameter.append("&source=pe-mytrace-1");

     byte[] postData = parameter.toString().getBytes("UTF8");

     URL url = new URL("https://www.google.com/accounts/ClientLogin");

     HttpsURLConnection.setDefaultHostnameVerifier(new FakeHostnameVerifier());
     HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
     conn.setDoOutput(true);
     conn.setUseCaches(false);
     conn.setRequestMethod("POST");
     conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
     conn.setRequestProperty("Content-Length", Integer.toString(postData.length));

     OutputStream out = conn.getOutputStream();
     out.write(postData);
     out.close();

     BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));

     String sid = br.readLine();

     String lsid = br.readLine();
     String authToken = br.readLine();
     authToken = authToken.substring(5, authToken.length());
     System.out.println("DEBUG : AuthKey : " + authToken);
     return authToken;
   }
 
//   private static class FakeHostnameVerifier implements HostnameVerifier
//   {
//     public boolean verify(String hostname, SSLSession session)
//     {
//       return true;
//     }
//   } 

   private static class FakeHostnameVerifier implements HostnameVerifier {                
       @Override                                                                        
       public boolean verify(String hostname, SSLSession session) {                     
        return true;                                                                    
       }                                                                                
  }                                                                                     
                                                                                        
  
  public static void main (String[] args)
  {
   C2dmMain ac2dmtest = new C2dmMain();
    try {
     ac2dmtest.sender("234234",ac2dmtest.getAuthToken());
    } catch (Exception e) {
     e.printStackTrace();
    }
  }
}