SDK update

上级 822210c2
/**
*
*/
/**
* @author Administrator
*
*/
package org.maxkey.client;
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.scribe</groupId>
<artifactId>scribe</artifactId>
<packaging>jar</packaging>
<version>1.3.5</version>
<name>Scribe OAuth Library</name>
<description>The best OAuth library out there</description>
<url>http://github.com/fernandezpablo85/scribe-java</url>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>5</version>
</parent>
<developers>
<developer>
<id>fernandezpablo85</id>
<name>Pablo Fernandez</name>
<email>fernandezpablo85@gmail.com</email>
<timezone>-3</timezone>
</developer>
</developers>
<licenses>
<license>
<name>MIT</name>
<url>http://github.com/fernandezpablo85/scribe-java/blob/master/LICENSE.txt</url>
</license>
</licenses>
<scm>
<connection>scm:http://github.com/fernandezpablo85/scribe-java.git</connection>
<developerConnection>scm:http://github.com/fernandezpablo85/scribe-java.git</developerConnection>
<url>http://github.com/fernandezpablo85/scribe-java.git</url>
</scm>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>failing-on-high</id>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<threshold>Low</threshold>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package com.connsec.client.oauth.test;
import java.util.*;
import org.maxkey.client.oauth.builder.ServiceBuilder;
import org.maxkey.client.oauth.builder.api.MaxkeyApi10a;
import org.maxkey.client.oauth.model.Token;
import org.maxkey.client.oauth.oauth.OAuthService;
public class Connsec10aExample
{
private static final String PROTECTED_RESOURCE_URL = "http://api.foursquare.com/v1/user";
public static void main(String[] args)
{
OAuthService service = new ServiceBuilder()
.provider(MaxkeyApi10a.class)
.apiKey("tonr-consumer-key")
.apiSecret("SHHHHH!!!!!!!!!!")
.callback(PROTECTED_RESOURCE_URL)
.build();
Scanner in = new Scanner(System.in);
System.out.println("=== Foursquare's OAuth Workflow ===");
System.out.println();
// Obtain the Request Token
System.out.println("Fetching the Request Token...");
Token requestToken = service.getRequestToken();
System.out.println("Got the Request Token!");
System.out.println();
System.out.println("Now go and authorize Scribe here:");
System.out.println(service.getAuthorizationUrl(requestToken));
/* System.out.println("And paste the verifier here");
System.out.print(">>");
Verifier verifier = new Verifier(in.nextLine());
System.out.println();
Token requestToken =new Token("3f1fe990-6795-4241-911e-ca0357ecab89","");
Verifier verifier = new Verifier("w3LGBc");
// Trade the Request Token and Verfier for the Access Token
System.out.println("Trading the Request Token for an Access Token...");
Token accessToken = service.getAccessToken(requestToken, verifier);
System.out.println("Got the Access Token!");
System.out.println("(if your curious it looks like this: " + accessToken + " )");
System.out.println();
// Now let's go and ask for a protected resource!
System.out.println("Now we're going to access a protected resource...");
OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
service.signRequest(accessToken, request);
Response response = request.send();
System.out.println("Got it! Lets see what we found...");
System.out.println();
System.out.println(response.getBody());
System.out.println();
System.out.println("Thats it man! Go and build something awesome with Scribe! :)");
*/
}
}
package com.connsec.client.oauth.test;
import java.util.*;
import org.maxkey.client.http.HttpVerb;
import org.maxkey.client.http.Response;
import org.maxkey.client.oauth.builder.ServiceBuilder;
import org.maxkey.client.oauth.builder.api.MaxkeyApi10a;
import org.maxkey.client.oauth.model.OAuthRequest;
import org.maxkey.client.oauth.model.Token;
import org.maxkey.client.oauth.model.Verifier;
import org.maxkey.client.oauth.oauth.OAuthService;
public class Connsec10aVerifierExample
{
private static final String PROTECTED_RESOURCE_URL = "http://api.foursquare.com/v1/user";
public static void main(String[] args)
{
OAuthService service = new ServiceBuilder()
.provider(MaxkeyApi10a.class)
.apiKey("tonr-consumer-key")
.apiSecret("SHHHHH!!!!!!!!!!")
.callback(PROTECTED_RESOURCE_URL)
.build();
Scanner in = new Scanner(System.in);
System.out.println("=== Foursquare's OAuth Workflow ===");
System.out.println();
// Obtain the Request Token
/* System.out.println("Fetching the Request Token...");
Token requestToken = service.getRequestToken();
System.out.println("Got the Request Token!");
System.out.println();
System.out.println("Now go and authorize Scribe here:");
System.out.println(service.getAuthorizationUrl(requestToken));
System.out.println("And paste the verifier here");
System.out.print(">>");
Verifier verifier = new Verifier(in.nextLine());
System.out.println();
*/
Token requestToken =new Token("d5df60ae-78fa-4a6e-9a66-cd7a84e746ea","");
Verifier verifier = new Verifier("MSHAor");
// Trade the Request Token and Verfier for the Access Token
System.out.println("Trading the Request Token for an Access Token...");
Token accessToken = service.getAccessToken(requestToken, verifier);
System.out.println("Got the Access Token!");
System.out.println("(if your curious it looks like this: " + accessToken + " )");
System.out.println();
// Now let's go and ask for a protected resource!
System.out.println("Now we're going to access a protected resource...");
OAuthRequest request = new OAuthRequest(HttpVerb.GET, PROTECTED_RESOURCE_URL);
service.signRequest(accessToken, request);
Response response = request.send();
System.out.println("Got it! Lets see what we found...");
System.out.println();
System.out.println(response.getBody());
System.out.println();
System.out.println("Thats it man! Go and build something awesome with Scribe! :)");
}
}
package com.connsec.client.oauth.test;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class LogerTest {
private static Log log = LogFactory.getLog(LogerTest. class );
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
log.info("teset");
}
}
......@@ -11,7 +11,7 @@ import org.maxkey.client.oauth.model.Token;
import org.maxkey.client.oauth.model.Verifier;
import org.maxkey.client.oauth.oauth.OAuthService;
public class Connsec20Example
public class MaxKey20Example
{
private static final String NETWORK_NAME = "SinaWeibo";
private static final String PROTECTED_RESOURCE_URL = "https://api.weibo.com/2/account/get_uid.json";
......
......@@ -6,7 +6,7 @@ import org.maxkey.client.oauth.model.OAuthConfig;
import org.maxkey.client.oauth.model.Token;
import org.maxkey.client.oauth.oauth.OAuthPasswordService;
public class ConnsecPasswordDemo {
public class MaxkeyPasswordDemo {
/**
* @param args
......
......@@ -16,19 +16,19 @@ public class RestClientTest {
OAuthClient tokenRestClient=new OAuthClient("https://exmail.qq.com/cgi-bin/token");
tokenRestClient.addParameter("grant_type", "client_credentials");
tokenRestClient.addBasicAuthorization("connsec", "66199e4c36b6dfcfb6f1ebceda789432");
tokenRestClient.addBasicAuthorization("maxkey", "66199e4c36b6dfcfb6f1ebceda789432");
Token token =tokenRestClient.requestAccessToken();
System.out.println(token);
OAuthClient authkeyRestClient=new OAuthClient("http://openapi.exmail.qq.com:12211/openapi/mail/authkey");
authkeyRestClient.addBearerAuthorization(token.getAccess_token());
authkeyRestClient.addParameter("Alias", "test@connsec.com");
authkeyRestClient.addParameter("Alias", "test@maxkey.org");
HashMap authKey=JsonUtils.gson2Object(authkeyRestClient.execute().getBody(), HashMap.class);
String login_url="https://exmail.qq.com/cgi-bin/login?fun=bizopenssologin&method=bizauth&agent=%s&user=%s&ticket=%s";
System.out.println(String.format(login_url, "connsec","test@connsec.com",authKey.get("auth_key")));
System.out.println(String.format(login_url, "connsec","test@maxkey.org",authKey.get("auth_key")));
//https://exmail.qq.com/cgi-bin/login?fun=bizopenssologin&method=bizauth&agent=connsec&user=test@connsec.com&ticket=25640C491CA4A056BD1A936C6AA4ABBCAB13AE76EB80E6C3A9259F5E8BFD91D7EA05D10DA3FB18F9BFB445D104CB58A0B4CDE97D9F219F3C
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册