Skip to content

Commit

Permalink
Merge pull request #300 from boncey/scribe-upgrade
Browse files Browse the repository at this point in the history
Upgrade to new version of Scribe.

Includes breaking changes (new scribe packages) so have moved to version 3.0.0.
  • Loading branch information
boncey authored Feb 6, 2019
2 parents 8e62bbc + cb9179e commit f78a4b9
Showing 104 changed files with 629 additions and 1,306 deletions.
56 changes: 0 additions & 56 deletions LICENSE-apache.txt

This file was deleted.

70 changes: 25 additions & 45 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,45 +1,25 @@
/*--

Copyright (C) 2005 Aetrion LLC.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions, and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions, and the disclaimer that follows
these conditions in the documentation and/or other materials
provided with the distribution.

3. The name "flickrj" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact [email protected].

4. Products derived from this software may not be called "flickrj", nor
may "flickrj" appear in their name, without prior written permission
from Aetrion LLC ([email protected]).

In addition, I request (but do not require) that you include in the
end-user documentation provided with the redistribution and/or in the
software itself an acknowledgement equivalent to the following:
"This product includes software developed by Aetrion LLC."

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

For more information on flickrj, please see <http://flickrj.sf.net/>.

*/
BSD 2-Clause License

Copyright (c) 2004, Anthony Eden (@aeden), Darren Greaves (@boncey), Allan (@callmeal) and contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ __Note:__ This API has been forked from [FlickrJ at Sourceforge](http://flickrj.

This is a Java API which wraps the [REST-based Flickr API](http://www.flickr.com/services/api/).

Comments and questions should be sent to the [GitHub Repo](https://github.com/callmeal/Flickr4Java).
Comments and questions should be raised on the [GitHub Repo issue tracker](https://github.com/boncey/Flickr4Java/issues).

### Usage

@@ -18,13 +18,8 @@ For example, to send a test ping to the Flickr service:
Flickr f = new Flickr(apiKey, sharedSecret, new REST());
TestInterface testInterface = f.getTestInterface();
Collection results = testInterface.echo(Collections.EMPTY_MAP);

__Please note:__ this library is not thread safe.

###Setup for gradle
```gradle
compile 'com.aetrion.flickr:flickrapi:1.1'
```

See `/src/examples/java` for more.

### Requirements

@@ -34,23 +29,27 @@ An API key is required to use this API. You can [request one on Flickr](http://

#### Required libraries

- [scribe-java (v.1.3.2 onwards)](https://github.com/fernandezpablo85/scribe-java/wiki/Getting-Started) (required for the OAuth functionality).
- [log4j](http://www.apache.org/dyn/closer.cgi/logging/log4j/1.2.17/log4j-1.2.17.zip) (runtime dependency for logging)
- [scribejava-api (v 6.2.0 onwards)](https://github.com/scribejava/scribejava) (required for the OAuth functionality).
- [slf4j](https://www.slf4j.org) (runtime dependency for logging)

### Download

[Download the latest version from bintray](https://bintray.com/boncey/Flickr4Java/Flickr4Java).


### Gradle

compile 'com.flickr4java:flickr4java:3.0.0'

### Maven

<dependency>
<groupId>com.flickr4java</groupId>
<artifactId>flickr4java</artifactId>
<version>2.19</version>
<version>3.0.0</version>
</dependency>

Flickr4Java is now available on Maven Central so the above settings should be all you need (it used to only be available on [JCenter](https://bintray.com/bintray/jcenter).
Flickr4Java is available on Maven Central so the above settings should be all you need.

### Testing
The tests now run against captured responses from Flickr (see `src/test/resources/payloads`) and don't contact the Flickr API at all.
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'application'

version = '2.19'
version = '3.0.0'
group = 'com.flickr4java.flickr'

sourceCompatibility = '1.5'
@@ -27,9 +27,8 @@ sourceSets {
}

dependencies {
compile 'org.scribe:scribe:1.3.3'
compile 'axis:axis:1.4'
compile 'log4j:log4j:1.2.17'
compile 'com.github.scribejava:scribejava-apis:6.2.0'
compile 'org.slf4j:slf4j-api:1.7.25'
testCompile group: 'junit', name: 'junit', version: '4.11'
}

23 changes: 11 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

<groupId>com.flickr4java</groupId>
<artifactId>flickr4java</artifactId>
<version>2.20-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>flickr4java</name>
<description>Java API For Flickr. Fork of FlickrJ.</description>
@@ -16,14 +16,6 @@
<version>7</version>
</parent>

<licenses>
<license>
<name>Apache License, Version 1.1</name>
<url>http://www.apache.org/licenses/LICENSE-1.1.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<developer>
<id>boncey</id>
@@ -45,19 +37,26 @@
<javaVersion>1.8</javaVersion>
<junitVersion>4.11</junitVersion>
<slf4j.version>1.7.25</slf4j.version>
<scribe.version>6.2.0</scribe.version>
</properties>

<dependencies>
<dependency>
<groupId>org.scribe</groupId>
<artifactId>scribe</artifactId>
<version>1.3.5</version>
<groupId>com.github.scribejava</groupId>
<artifactId>scribejava-apis</artifactId>
<version>${scribe.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
22 changes: 11 additions & 11 deletions src/examples/java/AuthExample.java
Original file line number Diff line number Diff line change
@@ -5,14 +5,14 @@
import com.flickr4java.flickr.auth.AuthInterface;
import com.flickr4java.flickr.auth.Permission;
import com.flickr4java.flickr.util.IOUtilities;

import org.scribe.model.Token;
import org.scribe.model.Verifier;
import com.github.scribejava.core.model.OAuth1RequestToken;
import com.github.scribejava.core.model.OAuth1Token;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.Scanner;
import java.util.concurrent.ExecutionException;

/**
* Demonstrates the authentication-process.
@@ -26,7 +26,7 @@
*/
public class AuthExample {

public static void auth() throws IOException, FlickrException {
public static void auth() throws IOException, FlickrException, ExecutionException, InterruptedException {
Properties properties;
InputStream in = null;
try {
@@ -43,10 +43,10 @@ public static void auth() throws IOException, FlickrException {

Scanner scanner = new Scanner(System.in);

Token token = authInterface.getRequestToken();
System.out.println("token: " + token);
OAuth1RequestToken requestToken = authInterface.getRequestToken();
System.out.println("token: " + requestToken);

String url = authInterface.getAuthorizationUrl(token, Permission.DELETE);
String url = authInterface.getAuthorizationUrl(requestToken, Permission.DELETE);
System.out.println("Follow this URL to authorise yourself on Flickr");
System.out.println(url);
System.out.println("Paste in the token it gives you:");
@@ -55,14 +55,14 @@ public static void auth() throws IOException, FlickrException {
String tokenKey = scanner.nextLine();
scanner.close();

Token requestToken = authInterface.getAccessToken(token, new Verifier(tokenKey));
OAuth1Token accessToken = authInterface.getAccessToken(requestToken, tokenKey);
System.out.println("Authentication success");

Auth auth = authInterface.checkToken(requestToken);
Auth auth = authInterface.checkToken(accessToken);

// This token can be used until the user revokes it.
System.out.println("Token: " + requestToken.getToken());
System.out.println("Secret: " + requestToken.getSecret());
System.out.println("Token: " + accessToken.getToken());
System.out.println("Secret: " + accessToken.getTokenSecret());
System.out.println("nsid: " + auth.getUser().getId());
System.out.println("Realname: " + auth.getUser().getRealName());
System.out.println("Username: " + auth.getUser().getUsername());
16 changes: 7 additions & 9 deletions src/examples/java/Backup.java
Original file line number Diff line number Diff line change
@@ -13,10 +13,8 @@
import com.flickr4java.flickr.photosets.PhotosetsInterface;
import com.flickr4java.flickr.util.AuthStore;
import com.flickr4java.flickr.util.FileAuthStore;

import org.scribe.model.Token;
import org.scribe.model.Verifier;
import org.xml.sax.SAXException;
import com.github.scribejava.core.model.OAuth1RequestToken;
import com.github.scribejava.core.model.OAuth1Token;

import java.io.BufferedInputStream;
import java.io.File;
@@ -57,21 +55,21 @@ public Backup(String apiKey, String nsid, String sharedSecret, File authsDir) th
}
}

private void authorize() throws IOException, SAXException, FlickrException {
private void authorize() throws IOException, FlickrException {
AuthInterface authInterface = flickr.getAuthInterface();
Token accessToken = authInterface.getRequestToken();
OAuth1RequestToken requestToken = authInterface.getRequestToken();

String url = authInterface.getAuthorizationUrl(accessToken, Permission.READ);
String url = authInterface.getAuthorizationUrl(requestToken, Permission.READ);
System.out.println("Follow this URL to authorise yourself on Flickr");
System.out.println(url);
System.out.println("Paste in the token it gives you:");
System.out.print(">>");

String tokenKey = new Scanner(System.in).nextLine();

Token requestToken = authInterface.getAccessToken(accessToken, new Verifier(tokenKey));
OAuth1Token accessToken = authInterface.getAccessToken(requestToken, tokenKey);

Auth auth = authInterface.checkToken(requestToken);
Auth auth = authInterface.checkToken(accessToken);
RequestContext.getRequestContext().setAuth(auth);
this.authStore.store(auth);
System.out.println("Thanks. You probably will not have to do this every time. Now starting backup.");
Loading

0 comments on commit f78a4b9

Please sign in to comment.