Skip to content

Commit 18b979a

Browse files
authored
Merge pull request #95 from marnberg/twoAuth
Adds ability to inject a http client into the afero client to enable app to handle authentication
2 parents 056be28 + 4dfeca2 commit 18b979a

47 files changed

Lines changed: 610 additions & 159 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ build
66
.classpath
77
bin
88
.vscode
9+
.idea
10+
.gradle

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Change Log
22
==========
33

4+
Version 1.5.0 *(2022-02-24)*
5+
----------------------------
6+
* New: Adds ability to configure the the underlying http client to enable oAuth to be handled by the app.
7+
* New: Adds ability to configure softhub to connect to different services
8+
49
Version 1.4.5 *(2019-09-20)*
510
----------------------------
611
* Fix: `AferoClient.resetPasswordWithCode` now actually works rather than returning a 400 error.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
MIT License
44

5-
© Copyright 2017-2019 Afero, Inc.
5+
© Copyright 2017-2022 Afero, Inc.
66

77
Permission is hereby granted, free of charge, to any person obtaining a copy
88
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
author: Tony Myles
33
title: "AferoJavaSDK"
4-
date: 2019-Sept-20
5-
status: 1.4.5
4+
date: 2022-Feb-28
5+
status: 1.5.0
66
---
77

88
# AferoJavaSDK
@@ -32,23 +32,23 @@ The SDK is composed of four separate modules.
3232

3333
The `afero-sdk-core` module is required for base functionality such as interacting with the Afero Cloud and manipulating devices.
3434
```Gradle
35-
implementation 'io.afero.sdk:afero-sdk-core:1.4.5'
35+
implementation 'io.afero.sdk:afero-sdk-core:1.5.0'
3636
```
3737

3838
The `afero-sdk-client-retrofit2` module provides an optional implementation of the AferoClient REST API interface using [Retrofit2](http://square.github.io/retrofit/) and [okhttp3](http://square.github.io/okhttp/). If you choose not to include this module in your project, you will need to develop your own implementation of AferoClient using your preferred http client library.
3939

4040
```Gradle
41-
implementation 'io.afero.sdk:afero-sdk-client-retrofit2:1.4.5'
41+
implementation 'io.afero.sdk:afero-sdk-client-retrofit2:1.5.0'
4242
```
4343

4444
The `afero-sdk-android` module is required for Android development.
4545
```Gradle
46-
implementation 'io.afero.sdk:afero-sdk-android:1.4.5'
46+
implementation 'io.afero.sdk:afero-sdk-android:1.5.0'
4747
```
4848

4949
The `afero-sdk-softhub` module is required for soft hub functionality on Android.
5050
```Gradle
51-
implementation 'io.afero.sdk:afero-sdk-softhub:1.4.5'
51+
implementation 'io.afero.sdk:afero-sdk-softhub:1.5.0'
5252
implementation "io.afero.sdk:hubby:1.0.844@aar"
5353
```
5454

afero-sdk-android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
apply plugin: 'com.android.library'
66

77
android {
8-
compileSdkVersion 26
8+
compileSdkVersion 30
99

1010
defaultConfig {
1111
minSdkVersion 19
12-
targetSdkVersion 26
12+
targetSdkVersion 30
1313
versionCode 1
1414
versionName rootProject.version
1515
}

afero-sdk-client-retrofit2/src/main/java/io/afero/sdk/client/retrofit2/AferoClientRetrofit2.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@ private Config validate() {
126126
e = new IllegalArgumentException("oauthClientId must be specified");
127127
}
128128

129-
if (oauthClientSecret == null || oauthClientSecret.isEmpty()) {
130-
e = new IllegalArgumentException("oauthClientSecret must be specified");
131-
}
132-
133129
if (httpLogLevel == null) {
134130
e = new IllegalArgumentException("httpLogLevel cannot be null");
135131
}
@@ -245,11 +241,11 @@ public Config build() {
245241
*
246242
* @param config Config
247243
*/
248-
public AferoClientRetrofit2(Config config) {
244+
public AferoClientRetrofit2(Config config, OkHttpClient client) {
249245
mConfig = config;
250-
mHttpClient = createHttpClient(config.httpLogLevel, config.defaultTimeout);
246+
mHttpClient = client != null ? client : createHttpClient(config.httpLogLevel, config.defaultTimeout);
251247
mAferoService = createRetrofit().create(AferoClientAPI.class);
252-
mOAuthAuthorizationBase64 = Credentials.basic(config.oauthClientId, config.oauthClientSecret);
248+
mOAuthAuthorizationBase64 = config.oauthClientSecret != null ? Credentials.basic(config.oauthClientId, config.oauthClientSecret) : "";
253249
}
254250

255251
// don't use me

afero-sdk-softhub/build.gradle

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,27 @@ repositories {
88
maven {
99
url "https://afero.jfrog.io/afero/hubby-android"
1010
credentials {
11-
username = project.aferoArtifactoryUserName
12-
password = project.aferoArtifactoryPassword
11+
username project.aferoArtifactoryUserName
12+
password project.aferoArtifactoryPassword
13+
}
14+
authentication {
15+
basic(BasicAuthentication)
16+
}
17+
metadataSources {
18+
artifact()
1319
}
1420
}
1521
}
1622

17-
final String hubbyVersion = "1.0.844"
23+
final String hubbyVersion = "1.0.957"
1824
final String hubType = project.findProperty('aferoSofthubType') ?: '"CONSUMER"'
1925

2026
android {
21-
compileSdkVersion 26
27+
compileSdkVersion 30
2228

2329
defaultConfig {
2430
minSdkVersion 19
25-
targetSdkVersion 26
31+
targetSdkVersion 30
2632

2733
versionCode 1
2834
versionName rootProject.version

afero-sdk-softhub/src/main/java/io/afero/sdk/softhub/AferoSofthub.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ public enum HubType {
6666

6767
private boolean mIsActive = true;
6868
private String mService;
69+
private String mHost;
70+
private String mAuthCert;
71+
6972

7073
private PublishSubject<AferoSofthub> mStartSubject;
7174
private final PublishSubject<NotificationCallback.CompleteReason> mCompleteSubject = PublishSubject.create();
@@ -238,6 +241,15 @@ public boolean isStarting() {
238241
return mStartSubject != null;
239242
}
240243

244+
public void setHost(@NonNull String host) {
245+
mHost = host;
246+
}
247+
248+
public void setAuthCert(@NonNull String cert) {
249+
mAuthCert = cert;
250+
}
251+
252+
241253
public void setService(@NonNull String service) {
242254
mService = service;
243255
}
@@ -315,6 +327,14 @@ private void startHubby() {
315327
config.put(Hubby.Config.HARDWARE_INFO, hwInfo);
316328
config.put(Hubby.Config.HUB_TYPE, mHubType.toString());
317329

330+
if (mHost != null) {
331+
config.put(Hubby.Config.API_HOSTNAME, mHost);
332+
}
333+
334+
if(mAuthCert != null) {
335+
config.put(Hubby.Config.AUTHENTICATOR_CERT, mAuthCert);
336+
}
337+
318338
if (mService != null) {
319339
config.put(Hubby.Config.SERVICE, mService);
320340
}

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010
}
1111
dependencies {
1212
classpath 'com.android.tools.build:gradle:3.4.0'
13-
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1"
13+
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.15.2'
1414
classpath "com.mobbeel.plugin:fat-aar:2.0.1"
1515
}
1616
}
@@ -19,6 +19,7 @@ allprojects {
1919
repositories {
2020
google()
2121
jcenter()
22+
mavenCentral()
2223
}
2324

2425
apply plugin: 'com.jfrog.artifactory'

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-all.zip

0 commit comments

Comments
 (0)