-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add setting to disable HTTPS certificate validation - make lock/unlock available even when status is unknown - show version and website in settings - add gradle build files
- Loading branch information
Showing
46 changed files
with
656 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,11 @@ | ||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
/app/build |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
Sphincter Remote | ||
Sphincter-Remote | ||
================ | ||
|
||
a simple android app to unlock doors :) | ||
Sphincter-Remote is an Android app to unlock doors via simple HTTPS calls. | ||
A server side program that works with this app is [Sphincter](https://github.com/openlab-aux/). | ||
|
||
 | ||
|
||
## Download | ||
|
||
## Build from Sources | ||
|
||
On Linux based systems: | ||
|
||
``` | ||
./gradlew assembleRelease | ||
``` | ||
|
||
## API | ||
|
||
Sphincter-Remote allows you to set an URL (e.g. `https://example.com/door/`) and a token (e.g. `secret123`) that will be used for a HTTP request: | ||
|
||
``` | ||
https://example.com/door/?action=open&token=secret123 | ||
``` | ||
|
||
Sphincter uses `open`, `close` or `state` as an action. | ||
As a reponse, `LOCKED` or `UNLOCKED` may be returned. | ||
|
||
An option allows to ignore certificate errors. But beware, that's dangerous! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
defaultConfig { | ||
applicationId 'com.example.sphincter' | ||
minSdkVersion 25 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
buildToolsVersion '28.0.3' | ||
productFlavors { | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_7 | ||
targetCompatibility JavaVersion.VERSION_1_7 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(include: ['*.jar'], dir: 'libs') | ||
implementation 'com.android.support:appcompat-v7:25.0.0' | ||
implementation 'com.android.support.constraint:constraint-layout:1.1.3' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.2' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | ||
} |
13 changes: 0 additions & 13 deletions
13
app/src/androidTest/java/com/michiwend/sphincterremote/ApplicationTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
app/src/main/java/com/example/sphincter/sphincter/HttpsTrustManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.example.sphincter; | ||
|
||
import java.security.cert.X509Certificate; | ||
|
||
import javax.net.ssl.TrustManager; | ||
import javax.net.ssl.X509TrustManager; | ||
import javax.net.ssl.HttpsURLConnection; | ||
import javax.net.ssl.HostnameVerifier; | ||
import javax.net.ssl.SSLSession; | ||
import javax.net.ssl.SSLContext; | ||
import java.security.SecureRandom; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.KeyManagementException; | ||
|
||
|
||
public class HttpsTrustManager implements X509TrustManager { | ||
private static TrustManager[] trustManagers; | ||
private static final X509Certificate[] _AcceptedIssuers = new X509Certificate[]{}; | ||
|
||
@Override | ||
public void checkClientTrusted( | ||
X509Certificate[] x509Certificates, String s) | ||
throws java.security.cert.CertificateException { | ||
} | ||
|
||
@Override | ||
public void checkServerTrusted( | ||
X509Certificate[] x509Certificates, String s) | ||
throws java.security.cert.CertificateException { | ||
} | ||
|
||
public boolean isClientTrusted(X509Certificate[] chain) { | ||
return true; | ||
} | ||
|
||
public boolean isServerTrusted(X509Certificate[] chain) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public X509Certificate[] getAcceptedIssuers() { | ||
return _AcceptedIssuers; | ||
} | ||
|
||
public static void allowAllSSL() { | ||
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { | ||
@Override | ||
public boolean verify(String arg0, SSLSession arg1) { | ||
return true; | ||
} | ||
}); | ||
|
||
SSLContext context = null; | ||
if (trustManagers == null) { | ||
trustManagers = new TrustManager[]{new HttpsTrustManager()}; | ||
} | ||
|
||
try { | ||
context = SSLContext.getInstance("TLS"); | ||
context.init(null, trustManagers, new SecureRandom()); | ||
} catch (NoSuchAlgorithmException | KeyManagementException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
HttpsURLConnection.setDefaultSSLSocketFactory(context != null ? context.getSocketFactory() : null); | ||
} | ||
} |
Oops, something went wrong.