├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src ├── main │ └── java │ │ └── io │ │ └── breadbutter │ │ ├── BreadButterException.java │ │ ├── BreadButterClient.java │ │ └── dtos.java └── test │ └── java │ └── io │ └── logonlabs │ └── BreadButterClientTest.java ├── gradlew.bat ├── README.md ├── .gitignore └── gradlew /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'breadbutter-java' 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/breadbutter/breadbutter-java/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Mar 28 15:19:34 PDT 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip 7 | -------------------------------------------------------------------------------- /src/main/java/io/breadbutter/BreadButterException.java: -------------------------------------------------------------------------------- 1 | package io.breadbutter; 2 | 3 | import net.servicestack.client.WebServiceException; 4 | 5 | /** 6 | * Class to encapsulate LogonLabs exceptions 7 | */ 8 | public class BreadButterException extends Exception { 9 | 10 | private int httpStatusCode; 11 | private String errorCode; 12 | 13 | BreadButterException(WebServiceException ex) { 14 | super(ex.getErrorMessage(), ex); 15 | httpStatusCode = ex.getStatusCode(); 16 | errorCode = ex.getErrorCode(); 17 | } 18 | 19 | /** 20 | * Gets the httpStatusCode value 21 | * @return the int status code 22 | */ 23 | public int getHttpStatusCode() 24 | { 25 | return httpStatusCode; 26 | } 27 | 28 | /** 29 | * Gets the errorCode value 30 | * @return the String error code 31 | */ 32 | public String getErrorCode() 33 | { 34 | return errorCode; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/io/logonlabs/BreadButterClientTest.java: -------------------------------------------------------------------------------- 1 | package io.logonlabs; 2 | 3 | import io.breadbutter.BreadButterClient; 4 | import io.breadbutter.dtos; 5 | import org.junit.*; 6 | 7 | 8 | public class BreadButterClientTest { 9 | 10 | private static final String GATEWAY_URL = ""; 11 | private static final String APP_ID = ""; 12 | private static final String APP_SECRET = ""; 13 | private static final String VALIDATE_TOKEN = ""; //this has to be hardcoded since redirect can't be performed 14 | 15 | @Test 16 | public void pingTest() throws Exception { 17 | BreadButterClient client = new BreadButterClient(APP_ID, APP_SECRET, GATEWAY_URL); 18 | } 19 | 20 | 21 | @Test 22 | public void getAuthenticationTest() throws Exception { 23 | BreadButterClient client = new BreadButterClient(APP_ID, APP_SECRET, GATEWAY_URL); 24 | 25 | dtos.GetAuthenticationResponse response = client.getAuthentication(VALIDATE_TOKEN); 26 | 27 | if(!response.isAuthSuccess()){ 28 | 29 | throw new Exception("Authentication failed with error: " + response.getAuthError()); 30 | 31 | } else { 32 | //authentication and validation succeeded 33 | dtos.AuthenticationData authData = response.getAuthData(); 34 | String emailAddress = authData.getEmailAddress(); 35 | String firstName = authData.getFirstName(); 36 | String lastName = authData.getLastName(); 37 | } 38 | } 39 | 40 | @Test 41 | public void parseTokenFromUrlTest() throws Exception { 42 | BreadButterClient client = new BreadButterClient(APP_ID, APP_SECRET, GATEWAY_URL); 43 | String tokenValue = "therealtokenvalue"; 44 | String url = "https://www.logonlabs.com/callbacktest?faketoken=123toke&authentication_token="+tokenValue; 45 | String token = client.parseAuthenticationToken(url); 46 | if(!token.equalsIgnoreCase(tokenValue)){ 47 | throw new Exception("Could not parse token correctly"); 48 | } 49 | 50 | System.out.println(String.format("Token parsed as %s", token)); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## The official Java Client library for Bread & Butter 2 | This library allows you to connect your application to the authentication process of Bread & Butter. A user will be redirected to your application when a user is authenticated. Once this authentication is retrieved by your application you can perform an action like creating a user in your system or creating a session for that users. 3 | 4 | ## Download 5 | 6 | Maven 7 | ```xml 8 | 9 | io.breadbutter 10 | breadbutter-java 11 | 5.2.0 12 | 13 | ``` 14 | 15 | ## API 16 | >For more information on the full **DIY Quick Start Guide** visit https://app.breadbutter.io/api/ 17 | 18 | Once the user's authentication is processed on by Bread & Butter, the user is redirected to a callback interface defined in your Bread & Butter app. The example below is a simple interface that accepts the request from Bread & Butter and processes the authentication. 19 | 20 | > After the the interface is created you will need to update the Callback URL with the URL to this interface in your app settings here: https://app.breadbutter.io/app/#/app-settings 21 | 22 | ### Processing an authentication request 23 | 24 | *Instantiating a new client* 25 | 26 | - `APP_ID` can be found in https://app.breadbutter.io/app/#/app-settings 27 | - `APP_SECRET` is configured at https://app.breadbutter.io/app/#/app-settings 28 | - The `BREADBUTTER_API_ENDPOINT` should be set to `https://api.breadbutter.io` 29 | 30 | Create a new instance of `BreadButterClient`. 31 | 32 | ```java 33 | import io.breadbutter.BreadButterClient; 34 | 35 | BreadButterClient client = new BreadButterClient("{APP_ID}", "{APP_SECRET}", "{BREADBUTTER_API_ENDPOINT}"); 36 | ``` 37 | 38 | *Retrieve authentication from Bread & Butter server* 39 | 40 | > You can find the detailed API response here: https://breadbutter.io/api/server-api/ 41 | 42 | ```java 43 | import io.breadbutter.BreadButterClient; 44 | import io.breadbutter.dtos.GetAuthenticationResponse; 45 | import io.breadbutter.dtos.AuthenticationData; 46 | import io.breadbutter.dtos.AuthOptions; 47 | import io.breadbutter.BreadButterException; 48 | 49 | 50 | String authToken = request.getParameter("authentication_token"); 51 | 52 | 53 | GetAuthenticationResponse bbResponse = client.getAuthentication(authToken); 54 | 55 | AuthenticationData authData = bbResponse.getAuthData(); 56 | String emailAddress = authData.getEmailAddress(); 57 | String firstName = authData.getFirstName(); 58 | String lastName = authData.getLastName(); 59 | String profileImage = authData.getProfileImageUrl(); 60 | 61 | AuthOptions authOptions = bbResponse.getOptions(); 62 | String destinationUrl = authOptions.getDestinationUrl(); 63 | 64 | ``` 65 | 66 | *Redirect the user back to your website* 67 | 68 | ```java 69 | response.sendRedirect(destinationUrl); 70 | ``` 71 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/java,gradle,intellij 3 | # Edit at https://www.gitignore.io/?templates=java,gradle,intellij 4 | 5 | ### Intellij ### 6 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 7 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 8 | 9 | # User-specific stuff 10 | .idea/**/workspace.xml 11 | .idea/**/tasks.xml 12 | .idea/**/usage.statistics.xml 13 | .idea/**/dictionaries 14 | .idea/**/shelf 15 | 16 | # Generated files 17 | .idea/**/contentModel.xml 18 | 19 | # Sensitive or high-churn files 20 | .idea/**/dataSources/ 21 | .idea/**/dataSources.ids 22 | .idea/**/dataSources.local.xml 23 | .idea/**/sqlDataSources.xml 24 | .idea/**/dynamic.xml 25 | .idea/**/uiDesigner.xml 26 | .idea/**/dbnavigator.xml 27 | 28 | # Gradle 29 | .idea/**/gradle.xml 30 | .idea/**/libraries 31 | 32 | # Gradle and Maven with auto-import 33 | # When using Gradle or Maven with auto-import, you should exclude module files, 34 | # since they will be recreated, and may cause churn. Uncomment if using 35 | # auto-import. 36 | # .idea/modules.xml 37 | # .idea/*.iml 38 | # .idea/modules 39 | 40 | # CMake 41 | cmake-build-*/ 42 | 43 | # Mongo Explorer plugin 44 | .idea/**/mongoSettings.xml 45 | 46 | # File-based project format 47 | *.iws 48 | 49 | # IntelliJ 50 | out/ 51 | 52 | # mpeltonen/sbt-idea plugin 53 | .idea_modules/ 54 | 55 | # JIRA plugin 56 | atlassian-ide-plugin.xml 57 | 58 | # Cursive Clojure plugin 59 | .idea/replstate.xml 60 | 61 | # Crashlytics plugin (for Android Studio and IntelliJ) 62 | com_crashlytics_export_strings.xml 63 | crashlytics.properties 64 | crashlytics-build.properties 65 | fabric.properties 66 | 67 | # Editor-based Rest Client 68 | .idea/httpRequests 69 | 70 | # Android studio 3.1+ serialized cache file 71 | .idea/caches/build_file_checksums.ser 72 | 73 | # JetBrains templates 74 | **___jb_tmp___ 75 | 76 | ### Intellij Patch ### 77 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 78 | 79 | # *.iml 80 | # modules.xml 81 | # .idea/misc.xml 82 | # *.ipr 83 | 84 | # Sonarlint plugin 85 | .idea/sonarlint 86 | 87 | ### Java ### 88 | # Compiled class file 89 | *.class 90 | 91 | # Log file 92 | *.log 93 | 94 | # BlueJ files 95 | *.ctxt 96 | 97 | # Mobile Tools for Java (J2ME) 98 | .mtj.tmp/ 99 | 100 | # Package Files # 101 | *.jar 102 | *.war 103 | *.nar 104 | *.ear 105 | *.zip 106 | *.tar.gz 107 | *.rar 108 | 109 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 110 | hs_err_pid* 111 | 112 | ### Gradle ### 113 | .gradle 114 | build/ 115 | 116 | # Ignore Gradle GUI config 117 | gradle-app.setting 118 | 119 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 120 | !gradle-wrapper.jar 121 | 122 | # Cache of project 123 | .gradletasknamecache 124 | 125 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 126 | # gradle/wrapper/gradle-wrapper.properties 127 | 128 | ### Gradle Patch ### 129 | **/build/ 130 | 131 | # End of https://www.gitignore.io/api/java,gradle,intellij 132 | .idea/ 133 | -------------------------------------------------------------------------------- /src/main/java/io/breadbutter/BreadButterClient.java: -------------------------------------------------------------------------------- 1 | package io.breadbutter; 2 | 3 | import net.servicestack.client.*; 4 | import org.apache.commons.httpclient.NameValuePair; 5 | import org.apache.commons.httpclient.URIException; 6 | import org.apache.commons.httpclient.util.ParameterParser; 7 | import org.apache.commons.httpclient.util.URIUtil; 8 | 9 | import java.net.MalformedURLException; 10 | import java.net.URL; 11 | import java.util.ArrayList; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * Implementation of the Bread & Butter API defined in https://app.breadbutter.io/api-gateway/#introduction. 17 | */ 18 | public class BreadButterClient { 19 | 20 | private final String appId; 21 | private final String secret; 22 | private final String apiUrl; 23 | private final JsonServiceClient client; 24 | 25 | /** 26 | * Create a new instance of the Client. AppId, secret, and apiUrl can all be retrieved via https://app.breadbutter.io/app/#/app-settings 27 | * @param appId the application's unique identifier 28 | * @param secret the application's secret 29 | * @param apiUrl the API endpoint 30 | */ 31 | public BreadButterClient(String appId, String secret, String apiUrl) { 32 | 33 | if(appId == null) { 34 | throw new IllegalArgumentException("appId must have a value"); 35 | } 36 | 37 | if(apiUrl == null) { 38 | throw new IllegalArgumentException("apiUrl must have a value"); 39 | } 40 | 41 | if(!apiUrl.startsWith("https://") && !apiUrl.startsWith("http://")){ 42 | apiUrl = "https://" + apiUrl; 43 | } 44 | 45 | if(!apiUrl.endsWith("/")) { 46 | apiUrl = apiUrl + "/"; 47 | } 48 | 49 | this.appId = appId; 50 | this.secret = secret; 51 | this.apiUrl = apiUrl; 52 | this.client = new JsonServiceClient(apiUrl); 53 | this.client.RequestFilter = conn -> conn.addRequestProperty("x-app-secret", secret); 54 | } 55 | 56 | 57 | /** 58 | * Request to the API to check status of the server 59 | * @return string representation of the API version on success 60 | */ 61 | public String ping() { 62 | 63 | dtos.Ping request = new dtos.Ping(); 64 | request.setAppId(appId); 65 | 66 | dtos.PingResponse response = client.get(request); 67 | 68 | return response.getVersion(); 69 | } 70 | 71 | 72 | 73 | /** 74 | * Request that continues the SSO process initiated by startAuthentication 75 | * @param authenticationToken the value returned in the callback url 76 | * @return full validation details outlined here https://app.breadbutter.io/api-gateway/#getauthentication 77 | * @throws BreadButterException thrown in case of API error 78 | */ 79 | public dtos.GetAuthenticationResponse getAuthentication(String authenticationToken) throws BreadButterException { 80 | 81 | throwIfNoSecret(); 82 | 83 | try { 84 | dtos.GetAuthentication request = new dtos.GetAuthentication(); 85 | request.setAppId(appId); 86 | request.setAuthenticationToken(authenticationToken); 87 | 88 | dtos.GetAuthenticationResponse response = client.get(request); 89 | return response; 90 | } catch(WebServiceException ex) { 91 | throw new BreadButterException(ex); 92 | } 93 | } 94 | 95 | public String parseAuthenticationToken(String url) throws MalformedURLException, URIException { 96 | if(url == null || url.isEmpty()){ 97 | throw new IllegalArgumentException("url must have value"); 98 | } 99 | 100 | URL parsedUrl = new URL(url); 101 | 102 | String decoded = URIUtil.decode(parsedUrl.getQuery()); 103 | ParameterParser parser = new ParameterParser(); 104 | List pairs = parser.parse(decoded, '&'); 105 | 106 | for (NameValuePair pair : pairs) { 107 | String parameterName = pair.getName(); 108 | if (parameterName.equalsIgnoreCase("authentication_token")) { 109 | return pair.getValue(); 110 | } 111 | } 112 | 113 | throw new IllegalArgumentException(String.format("url %s is missing a token parameter in query string", url)); 114 | } 115 | 116 | private void throwIfNoSecret() 117 | { 118 | if (secret == null || secret.isEmpty()) 119 | { 120 | throw new IllegalArgumentException("Secret must have value"); 121 | } 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /src/main/java/io/breadbutter/dtos.java: -------------------------------------------------------------------------------- 1 | package io.breadbutter; 2 | /* Options: 3 | Date: 2019-10-08 14:31:01 4 | Version: 5.60 5 | Tip: To override a DTO option, remove "//" prefix before updating 6 | BaseUrl: https://local-idpx.logon-dev.com 7 | 8 | //Package: 9 | //GlobalNamespace: dtos 10 | //AddPropertyAccessors: True 11 | //SettersReturnThis: True 12 | //AddServiceStackTypes: True 13 | //AddResponseStatus: False 14 | //AddDescriptionAsComments: True 15 | //AddImplicitVersion: 16 | //IncludeTypes: 17 | //ExcludeTypes: 18 | //TreatTypesAsStrings: 19 | //DefaultImports: java.math.*,java.util.*,net.servicestack.client.* 20 | */ 21 | 22 | /* Options: 23 | Date: 2020-05-14 18:21:09 24 | Version: 5.70 25 | Tip: To override a DTO option, remove "//" prefix before updating 26 | BaseUrl: https://api.logon-dev-stable.com 27 | 28 | //Package: 29 | //GlobalNamespace: dtos 30 | //AddPropertyAccessors: True 31 | //SettersReturnThis: True 32 | //AddServiceStackTypes: True 33 | //AddResponseStatus: False 34 | //AddDescriptionAsComments: True 35 | //AddImplicitVersion: 36 | //IncludeTypes: 37 | //ExcludeTypes: 38 | //TreatTypesAsStrings: 39 | //DefaultImports: java.math.*,java.util.*,net.servicestack.client.* 40 | */ 41 | 42 | import java.math.*; 43 | import java.util.*; 44 | import net.servicestack.client.*; 45 | 46 | public class dtos 47 | { 48 | 49 | 50 | @Route(Path="/ping", Verbs="GET") 51 | @DataContract 52 | public static class Ping implements IReturn, IAppId 53 | { 54 | @DataMember 55 | public String app_id = null; 56 | 57 | public String getAppId() { return app_id; } 58 | public Ping setAppId(String value) { this.app_id = value; return this; } 59 | private static Object responseType = PingResponse.class; 60 | public Object getResponseType() { return responseType; } 61 | } 62 | 63 | public static class PingResponse implements IBaseResponse 64 | { 65 | @DataMember 66 | public String version = null; 67 | 68 | public IErrorResponse error = null; 69 | 70 | public String getVersion() { return version; } 71 | public PingResponse setVersion(String value) { this.version = value; return this; } 72 | public IErrorResponse getError() { return error; } 73 | public PingResponse setError(IErrorResponse value) { this.error = value; return this; } 74 | } 75 | 76 | @Route(Path="/apps/{app_id}/authentications/{authentication_token}", Verbs="GET") 77 | @DataContract 78 | public static class GetAuthentication implements IReturn, IAppId 79 | { 80 | @DataMember(IsRequired=true) 81 | public String app_id = null; 82 | 83 | @DataMember(IsRequired=true) 84 | public String authentication_token = null; 85 | 86 | public String getAppId() { return app_id; } 87 | public GetAuthentication setAppId(String value) { this.app_id = value; return this; } 88 | public String getAuthenticationToken() { return authentication_token; } 89 | public GetAuthentication setAuthenticationToken(String value) { this.authentication_token = value; return this; } 90 | private static Object responseType = GetAuthenticationResponse.class; 91 | public Object getResponseType() { return responseType; } 92 | } 93 | 94 | public static class GetAuthenticationResponse implements IBaseResponse 95 | { 96 | @DataMember 97 | public String app_id = null; 98 | 99 | @DataMember 100 | public ClientDetails client_details = null; 101 | 102 | @DataMember 103 | public Boolean auth_success = null; 104 | 105 | @DataMember 106 | public String auth_error = null; 107 | 108 | @DataMember 109 | public AuthenticationData auth_data = null; 110 | 111 | @DataMember 112 | public GetAuthenticationProvider provider = null; 113 | 114 | @DataMember 115 | public AuthOptions options = null; 116 | 117 | @DataMember 118 | public String user_id = null; 119 | 120 | @DataMember 121 | public IErrorResponse error = null; 122 | 123 | public String getAppId() { return app_id; } 124 | public GetAuthenticationResponse setAppId(String value) { this.app_id = value; return this; } 125 | public ClientDetails getClientDetails() { return client_details; } 126 | public GetAuthenticationResponse setClientDetails(ClientDetails value) { this.client_details = value; return this; } 127 | public Boolean isAuthSuccess() { return auth_success; } 128 | public GetAuthenticationResponse setAuthSuccess(Boolean value) { this.auth_success = value; return this; } 129 | public String getAuthError() { return auth_error; } 130 | public GetAuthenticationResponse setAuthError(String value) { this.auth_error = value; return this; } 131 | public AuthenticationData getAuthData() { return auth_data; } 132 | public GetAuthenticationResponse setAuthData(AuthenticationData value) { this.auth_data = value; return this; } 133 | public GetAuthenticationProvider getProvider() { return provider; } 134 | public GetAuthenticationResponse setProvider(GetAuthenticationProvider value) { this.provider = value; return this; } 135 | public AuthOptions getOptions() { return options; } 136 | public GetAuthenticationResponse setOptions(AuthOptions value) { this.options = value; return this; } 137 | public String getUserId() { return user_id; } 138 | public GetAuthenticationResponse setUserId(String value) { this.user_id = value; return this; } 139 | public IErrorResponse getError() { return error; } 140 | public GetAuthenticationResponse setError(IErrorResponse value) { this.error = value; return this; } 141 | } 142 | 143 | public static class UpdateAppUserResponse implements IBaseResponse 144 | { 145 | @DataMember 146 | public IErrorResponse error = null; 147 | 148 | public IErrorResponse getError() { return error; } 149 | public UpdateAppUserResponse setError(IErrorResponse value) { this.error = value; return this; } 150 | } 151 | 152 | public static interface IAppId 153 | { 154 | public String app_id = null; 155 | } 156 | 157 | public static interface IDeviceId 158 | { 159 | public String device_id = null; 160 | } 161 | 162 | public static interface IErrorResponse 163 | { 164 | public String code = null; 165 | public String message = null; 166 | public ArrayList validation_errors = null; 167 | } 168 | 169 | public static interface IBaseResponse 170 | { 171 | public IErrorResponse error = null; 172 | } 173 | 174 | public static class ClientDetails 175 | { 176 | @DataMember 177 | public String ip_address = null; 178 | 179 | @DataMember 180 | public String continent_code = null; 181 | 182 | @DataMember 183 | public String continent = null; 184 | 185 | @DataMember 186 | public String country_code = null; 187 | 188 | @DataMember 189 | public String country = null; 190 | 191 | @DataMember 192 | public String state_prov_code = null; 193 | 194 | @DataMember 195 | public String state_prov = null; 196 | 197 | @DataMember 198 | public String city = null; 199 | 200 | @DataMember 201 | public String latitude = null; 202 | 203 | @DataMember 204 | public String longitude = null; 205 | 206 | @DataMember 207 | public String operating_system = null; 208 | 209 | @DataMember 210 | public String browser = null; 211 | 212 | @DataMember 213 | public String device = null; 214 | 215 | public String getIpAddress() { return ip_address; } 216 | public ClientDetails setIpAddress(String value) { this.ip_address = value; return this; } 217 | public String getContinentCode() { return continent_code; } 218 | public ClientDetails setContinentCode(String value) { this.continent_code = value; return this; } 219 | public String getContinent() { return continent; } 220 | public ClientDetails setContinent(String value) { this.continent = value; return this; } 221 | public String getCountryCode() { return country_code; } 222 | public ClientDetails setCountryCode(String value) { this.country_code = value; return this; } 223 | public String getCountry() { return country; } 224 | public ClientDetails setCountry(String value) { this.country = value; return this; } 225 | public String getStateProvCode() { return state_prov_code; } 226 | public ClientDetails setStateProvCode(String value) { this.state_prov_code = value; return this; } 227 | public String getStateProv() { return state_prov; } 228 | public ClientDetails setStateProv(String value) { this.state_prov = value; return this; } 229 | public String getCity() { return city; } 230 | public ClientDetails setCity(String value) { this.city = value; return this; } 231 | public String getLatitude() { return latitude; } 232 | public ClientDetails setLatitude(String value) { this.latitude = value; return this; } 233 | public String getLongitude() { return longitude; } 234 | public ClientDetails setLongitude(String value) { this.longitude = value; return this; } 235 | public String getOperatingSystem() { return operating_system; } 236 | public ClientDetails setOperatingSystem(String value) { this.operating_system = value; return this; } 237 | public String getBrowser() { return browser; } 238 | public ClientDetails setBrowser(String value) { this.browser = value; return this; } 239 | public String getDevice() { return device; } 240 | public ClientDetails setDevice(String value) { this.device = value; return this; } 241 | } 242 | 243 | public static class AuthenticationData 244 | { 245 | @DataMember 246 | public String email_address = null; 247 | 248 | @DataMember 249 | public String first_name = null; 250 | 251 | @DataMember 252 | public String last_name = null; 253 | 254 | @DataMember 255 | public String profile_image_url = null; 256 | 257 | @DataMember 258 | public String uid = null; 259 | 260 | @DataMember 261 | public HashMap data = null; 262 | 263 | @DataMember 264 | public AuthorizationDataTokens oauth_tokens = null; 265 | 266 | public String getEmailAddress() { return email_address; } 267 | public AuthenticationData setEmailAddress(String value) { this.email_address = value; return this; } 268 | public String getFirstName() { return first_name; } 269 | public AuthenticationData setFirstName(String value) { this.first_name = value; return this; } 270 | public String getLastName() { return last_name; } 271 | public AuthenticationData setLastName(String value) { this.last_name = value; return this; } 272 | public String getProfileImageUrl() { return profile_image_url; } 273 | public AuthenticationData setProfileImageUrl(String value) { this.profile_image_url = value; return this; } 274 | public String getUid() { return uid; } 275 | public AuthenticationData setUid(String value) { this.uid = value; return this; } 276 | public HashMap getData() { return data; } 277 | public AuthenticationData setData(HashMap value) { this.data = value; return this; } 278 | public AuthorizationDataTokens getOauthTokens() { return oauth_tokens; } 279 | public AuthenticationData setOauthTokens(AuthorizationDataTokens value) { this.oauth_tokens = value; return this; } 280 | } 281 | 282 | public static class GetAuthenticationProvider 283 | { 284 | @DataMember 285 | public String idp = null; 286 | 287 | @DataMember 288 | public String id = null; 289 | 290 | @DataMember 291 | public String protocol = null; 292 | 293 | @DataMember 294 | public String name = null; 295 | 296 | @DataMember 297 | public String type = null; 298 | 299 | public String getIdp() { return idp; } 300 | public GetAuthenticationProvider setIdp(String value) { this.idp = value; return this; } 301 | public String getId() { return id; } 302 | public GetAuthenticationProvider setId(String value) { this.id = value; return this; } 303 | public String getProtocol() { return protocol; } 304 | public GetAuthenticationProvider setProtocol(String value) { this.protocol = value; return this; } 305 | public String getName() { return name; } 306 | public GetAuthenticationProvider setName(String value) { this.name = value; return this; } 307 | public String getType() { return type; } 308 | public GetAuthenticationProvider setType(String value) { this.type = value; return this; } 309 | } 310 | 311 | public static class AuthOptions 312 | { 313 | @DataMember 314 | public String client_data = null; 315 | 316 | @DataMember 317 | public String callback_url = null; 318 | 319 | @DataMember 320 | public String destination_url = null; 321 | 322 | @DataMember 323 | public String force_reauthentication = null; 324 | 325 | public String getClientData() { return client_data; } 326 | public AuthOptions setClientData(String value) { this.client_data = value; return this; } 327 | public String getCallbackUrl() { return callback_url; } 328 | public AuthOptions setCallbackUrl(String value) { this.callback_url = value; return this; } 329 | public String getDestinationUrl() { return destination_url; } 330 | public AuthOptions setDestinationUrl(String value) { this.destination_url = value; return this; } 331 | public String getForceReauthentication() { return force_reauthentication; } 332 | public AuthOptions setForceReauthentication(String value) { this.force_reauthentication = value; return this; } 333 | } 334 | 335 | 336 | 337 | 338 | public static interface IValidationExceptionResponse 339 | { 340 | public String property = null; 341 | public String code = null; 342 | public String message = null; 343 | } 344 | 345 | public static class AuthorizationDataTokens 346 | { 347 | @DataMember 348 | public String access_token = null; 349 | 350 | @DataMember 351 | public Long access_token_expires_in = null; 352 | 353 | @DataMember 354 | public String refresh_token = null; 355 | 356 | @DataMember 357 | public Long refresh_token_expires_in = null; 358 | 359 | @DataMember 360 | public Boolean can_refresh_token = null; 361 | 362 | @DataMember 363 | public Boolean can_revoke_token = null; 364 | 365 | public String getAccessToken() { return access_token; } 366 | public AuthorizationDataTokens setAccessToken(String value) { this.access_token = value; return this; } 367 | public Long getAccessTokenExpiresIn() { return access_token_expires_in; } 368 | public AuthorizationDataTokens setAccessTokenExpiresIn(Long value) { this.access_token_expires_in = value; return this; } 369 | public String getRefreshToken() { return refresh_token; } 370 | public AuthorizationDataTokens setRefreshToken(String value) { this.refresh_token = value; return this; } 371 | public Long getRefreshTokenExpiresIn() { return refresh_token_expires_in; } 372 | public AuthorizationDataTokens setRefreshTokenExpiresIn(Long value) { this.refresh_token_expires_in = value; return this; } 373 | public Boolean isCanRefreshToken() { return can_refresh_token; } 374 | public AuthorizationDataTokens setCanRefreshToken(Boolean value) { this.can_refresh_token = value; return this; } 375 | public Boolean isCanRevokeToken() { return can_revoke_token; } 376 | public AuthorizationDataTokens setCanRevokeToken(Boolean value) { this.can_revoke_token = value; return this; } 377 | } 378 | 379 | 380 | 381 | public static class ParsedIpAddressDataModel 382 | { 383 | public String continent = null; 384 | public String continent_code = null; 385 | public String country = null; 386 | public String country_code = null; 387 | public String state_prov = null; 388 | public String state_prov_code = null; 389 | public String city = null; 390 | public String longitude = null; 391 | public String latitude = null; 392 | 393 | public String getContinent() { return continent; } 394 | public ParsedIpAddressDataModel setContinent(String value) { this.continent = value; return this; } 395 | public String getContinentCode() { return continent_code; } 396 | public ParsedIpAddressDataModel setContinentCode(String value) { this.continent_code = value; return this; } 397 | public String getCountry() { return country; } 398 | public ParsedIpAddressDataModel setCountry(String value) { this.country = value; return this; } 399 | public String getCountryCode() { return country_code; } 400 | public ParsedIpAddressDataModel setCountryCode(String value) { this.country_code = value; return this; } 401 | public String getStateProv() { return state_prov; } 402 | public ParsedIpAddressDataModel setStateProv(String value) { this.state_prov = value; return this; } 403 | public String getStateProvCode() { return state_prov_code; } 404 | public ParsedIpAddressDataModel setStateProvCode(String value) { this.state_prov_code = value; return this; } 405 | public String getCity() { return city; } 406 | public ParsedIpAddressDataModel setCity(String value) { this.city = value; return this; } 407 | public String getLongitude() { return longitude; } 408 | public ParsedIpAddressDataModel setLongitude(String value) { this.longitude = value; return this; } 409 | public String getLatitude() { return latitude; } 410 | public ParsedIpAddressDataModel setLatitude(String value) { this.latitude = value; return this; } 411 | } 412 | 413 | public static class ParsedUserAgentDataModel 414 | { 415 | public String operating_system = null; 416 | public String device = null; 417 | public String browser = null; 418 | public Boolean is_bot = null; 419 | 420 | public String getOperatingSystem() { return operating_system; } 421 | public ParsedUserAgentDataModel setOperatingSystem(String value) { this.operating_system = value; return this; } 422 | public String getDevice() { return device; } 423 | public ParsedUserAgentDataModel setDevice(String value) { this.device = value; return this; } 424 | public String getBrowser() { return browser; } 425 | public ParsedUserAgentDataModel setBrowser(String value) { this.browser = value; return this; } 426 | public Boolean getIsBot() { return is_bot; } 427 | public ParsedUserAgentDataModel setIsBot(Boolean value) { this.is_bot = value; return this; } 428 | } 429 | 430 | 431 | 432 | } --------------------------------------------------------------------------------