Skip to content
This repository was archived by the owner on Sep 10, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions exampleapp/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.google.keytransparency.exampleapp"
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
}

dependencies {
compile project(':keytransparency')
compile 'com.android.support:appcompat-v7:26.+'
}
23 changes: 23 additions & 0 deletions exampleapp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.keytransparency.exampleapp">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/keytransparency"
android:label="@string/app_name"
android:roundIcon="@mipmap/keytransparency_round"
android:theme="@style/AppTheme">
<activity android:name=".KeyTransparencyExample">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

<uses-sdk android:minSdkVersion="16"/>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package com.google.keytransparency.exampleapp;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.google.keytransparency.client.KeyTransparencyClient;
import com.google.keytransparency.client.KeyTransparencyException;
import com.google.keytransparency.client.LogReceiver;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

import static android.R.attr.button;

public class KeyTransparencyExample extends AppCompatActivity {

private static final String TAG_LOGS_FROM_GOBIND = "GoKtClient:";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_key_transparency_example);
final TextView tv = (TextView) findViewById(R.id.textView);

tv.setText("");
tv.setMovementMethod(new ScrollingMovementMethod());

KeyTransparencyClient.addVerboseLogsDestination(new LogReceiver() {
@Override
public long write(byte[] bytes) throws Exception {
tv.append(TAG_LOGS_FROM_GOBIND + new String(bytes, "UTF-8"));
return bytes.length;
}
});

final EditText urlEditText = (EditText) findViewById(R.id.ktURL);
urlEditText.setText("35.184.134.53:8080");

final EditText emailEditText = (EditText) findViewById(R.id.email);
emailEditText.setText("non_existing_user@gmail.com");
final EditText appIdEditText = (EditText) findViewById(R.id.appId);
appIdEditText.setText("app1");

final Button addServerButton = (Button) findViewById(R.id.addServerButton);
addServerButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String ktUrl = urlEditText.getText().toString();
tv.append("\n\n --- AddServer test --- \n");
tv.append("\nAdding " + ktUrl + "as a KeyTransparency server\n");
try {
KeyTransparencyClient.addKtServer(ktUrl, true, null, null);
} catch (KeyTransparencyException e) {
tv.append("\nError connecting to the server: " + e.getMessage());
e.printStackTrace();
}
}
});

final Button getEntryButton = (Button) findViewById(R.id.getEntryButton);
getEntryButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String email = emailEditText.getText().toString();
String appId = appIdEditText.getText().toString();
String ktUrl = urlEditText.getText().toString();

tv.append("\n\n --- GetEntry test --- \n");
tv.append("\nTrying to get public key for (" + email + "," + appId + ") from server " + ktUrl + "\n");

try {
byte[] entry = KeyTransparencyClient.getEntry(ktUrl, email, appId);
if (entry == null) {
tv.append("Received key is null: entry does not exists");
} else {
tv.append("Received key: " + bytesToHex(entry));
}
} catch (KeyTransparencyException e) {
tv.append("\nError getting the key: " + e.getMessage());
}
}
});
}

private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
public static String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
for ( int j = 0; j < bytes.length; j++ ) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
}
return new String(hexChars);
}

}
Binary file added exampleapp/src/main/keytransparency-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added exampleapp/src/main/keytransparency_round-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical"
android:gravity="center">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="horizontal"
android:gravity="center">

<EditText
android:id="@+id/ktURL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textNoSuggestions"
android:text="ktURL" />

<Button
android:id="@+id/addServerButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Add Server" />
</LinearLayout>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="horizontal"
android:gravity="center">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical"
android:gravity="center">

<EditText
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textEmailAddress"
android:text="email" />

<EditText
android:id="@+id/appId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textNoSuggestions"
android:text="appId" />
</LinearLayout>

<Button
android:id="@+id/getEntryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Get Entry" />
</LinearLayout>


<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:text="Output Goes Here" />

</LinearLayout>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions exampleapp/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
1 change: 1 addition & 0 deletions exampleapp/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<resources></resources>
3 changes: 3 additions & 0 deletions exampleapp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">KeyTransparency</string>
</resources>
20 changes: 20 additions & 0 deletions exampleapp/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>
15 changes: 0 additions & 15 deletions keytransparency/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,9 @@ android {
targetSdkVersion 26
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile project(':keytransparencygobind')
testCompile 'junit:junit:4.12'
}
8 changes: 1 addition & 7 deletions keytransparency/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.google.keytransparency">
package="com.google.keytransparency.client">

<uses-permission android:name="android.permission.INTERNET" />

<application android:allowBackup="true" android:label="@string/app_name"
android:supportsRtl="true">

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.google.keytransparency;
package com.google.keytransparency.client;

import com.google.keytransparency.gobind.gobindclient.Gobindclient;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.google.keytransparency;
package com.google.keytransparency.client;

/**
* A KeyTransparencyException is thrown whenever the go native code throws an Exception.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.google.keytransparency;
package com.google.keytransparency.client;

import com.google.keytransparency.gobind.gobindclient.LogWriter;

Expand Down
2 changes: 1 addition & 1 deletion keytransparency/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<resources>
<string name="app_name">keytransparency</string>
<string name="app_name">TODO_REMOVE_THIS_FILE</string>
</resources>
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':keytransparencygobind', ':keytransparency'
include ':keytransparency', ':exampleapp', ':keytransparencygobind'