Skip to content

Commit

Permalink
Merge pull request #232 from LossyDragon/rev
Browse files Browse the repository at this point in the history
Login Flow revisions
  • Loading branch information
LossyDragon authored Jul 31, 2023
2 parents 667d746 + e3f8474 commit 2eff456
Show file tree
Hide file tree
Showing 23 changed files with 941 additions and 58 deletions.
39 changes: 15 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
// https://mvnrepository.com/artifact/com.google.protobuf/protobuf-gradle-plugin
plugins {
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
id 'com.google.protobuf' version "0.9.2"
id 'com.google.protobuf' version "0.9.4"
id 'jacoco'
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.8.10'
id 'org.jetbrains.kotlin.jvm' version '1.9.0'
id 'projectversiongen'
id 'signing'
id 'steamlanguagegen'
}

allprojects {
group 'in.dragonbra'
version '1.3.0-beta01'
version '1.3.0'
}

sourceCompatibility = 1.8
Expand All @@ -26,11 +26,11 @@ repositories {

// https://mvnrepository.com/artifact/com.google.protobuf/protoc
protobuf.protoc {
artifact = 'com.google.protobuf:protoc:3.22.2'
artifact = 'com.google.protobuf:protoc:3.22.4'
}

// https://www.eclemma.org/jacoco
jacoco.toolVersion = "0.8.8"
jacoco.toolVersion = "0.8.10"

jacocoTestReport.reports {
xml.required = true
Expand Down Expand Up @@ -66,56 +66,47 @@ sourceSets.main {
)
}

compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}

check.dependsOn jacocoTestReport
compileJava.dependsOn(generateSteamLanguage)
compileJava.dependsOn(generateProjectVersion)

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.0-Beta")

// https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'

// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation 'com.google.code.gson:gson:2.10.1'
// https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java
implementation 'com.google.protobuf:protobuf-java:3.22.2'
implementation 'com.google.protobuf:protobuf-java:3.22.4'
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
// https://mvnrepository.com/artifact/commons-validator/commons-validator
implementation 'commons-validator:commons-validator:1.7'
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
implementation 'org.apache.commons:commons-lang3:3.12.0'
// https://mvnrepository.com/artifact/org.java-websocket/Java-WebSocket
implementation 'org.java-websocket:Java-WebSocket:1.5.3'
implementation 'org.java-websocket:Java-WebSocket:1.5.4'
// https://mvnrepository.com/artifact/commons-io/commons-io
implementation 'commons-io:commons-io:2.11.0'
implementation 'commons-io:commons-io:2.13.0'

/* Unit Testing */

// https://mvnrepository.com/artifact/com.squareup.okhttp3/mockwebserver3-junit5
testImplementation 'com.squareup.okhttp3:mockwebserver3-junit5:5.0.0-alpha.11'
// https://mvnrepository.com/artifact/commons-codec/commons-codec
testImplementation 'commons-codec:commons-codec:1.15'
testImplementation 'commons-codec:commons-codec:1.16.0'
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
// https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on
testImplementation 'org.bouncycastle:bcprov-jdk15on:1.70'
// https://mvnrepository.com/artifact/org.mockito/mockito-core
testImplementation 'org.mockito:mockito-core:4.11.0'
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-params
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.0'
// https://mvnrepository.com/artifact/org.mockito/mockito-junit-jupiter
testImplementation 'org.mockito:mockito-junit-jupiter:4.11.0'
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies {
implementation localGroovy()

// https://mvnrepository.com/artifact/commons-io/commons-io
implementation 'commons-io:commons-io:2.11.0'
implementation 'commons-io:commons-io:2.13.0'
}

gradlePlugin {
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ signing.password=
signing.secretKeyRingFile=~/.gnupg/secring.gpg

ossrhUsername=
ossrhPassword=
ossrhPassword=

org.gradle.jvmargs=-Xmx1024m
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 8 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -133,10 +130,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
Expand Down Expand Up @@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
9 changes: 6 additions & 3 deletions javasteam-samples/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.9.0'
}

sourceCompatibility = 1.8
Expand All @@ -11,6 +11,9 @@ repositories {
dependencies {
implementation rootProject

// https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'

// https://mvnrepository.com/artifact/pro.leaco.qrcode/console-qrcode
implementation 'pro.leaco.qrcode:console-qrcode:1.0.1'

Expand All @@ -22,8 +25,8 @@ dependencies {

// To access protobufs directly as shown in Sample #2
// https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java
implementation 'com.google.protobuf:protobuf-java:3.22.2'
implementation 'com.google.protobuf:protobuf-java:3.22.4'

// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import in.dragonbra.javasteam.enums.EResult;
import in.dragonbra.javasteam.steam.authentication.AuthPollResult;
import in.dragonbra.javasteam.steam.authentication.AuthSessionDetails;
import in.dragonbra.javasteam.steam.authentication.CredentialsAuthSession;
import in.dragonbra.javasteam.steam.authentication.SteamAuthentication;
import in.dragonbra.javasteam.steam.authentication.UserConsoleAuthenticator;
import in.dragonbra.javasteam.steam.authentication.*;
import in.dragonbra.javasteam.steam.handlers.steamunifiedmessages.SteamUnifiedMessages;
import in.dragonbra.javasteam.steam.handlers.steamuser.LogOnDetails;
import in.dragonbra.javasteam.steam.handlers.steamuser.SteamUser;
Expand All @@ -23,6 +19,7 @@
import in.dragonbra.javasteam.util.log.LogManager;

import java.util.Base64;
import java.util.concurrent.CancellationException;

/**
* @author lossy
Expand Down Expand Up @@ -114,7 +111,8 @@ private void onConnected(ConnectedCallback callback) {

CredentialsAuthSession authSession = auth.beginAuthSessionViaCredentials(authDetails);

AuthPollResult pollResponse = authSession.pollingWaitForResult();
// AuthPollResult pollResponse = authSession.pollingWaitForResult(); // This method is for Kotlin (coroutines)
AuthPollResult pollResponse = authSession.pollingWaitForResultCompat();

LogOnDetails details = new LogOnDetails();
details.setUsername(pollResponse.getAccountName());
Expand All @@ -131,7 +129,15 @@ private void onConnected(ConnectedCallback callback) {
// parseJsonWebToken(pollResponse.refreshToken, "RefreshToken");
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);

// List a couple of exceptions that could be important to handle.
if (e instanceof AuthenticationException) {
System.out.println("An Authentication error has occurred.");
}

if (e instanceof CancellationException) {
System.out.println("An Cancellation exception was raised. Usually means a timeout occurred");
}
}
}

Expand Down
Loading

0 comments on commit 2eff456

Please sign in to comment.