fix display wrong email

add server url to sync view
replace some icons
pull/5/head
Felix Prahl-Kamps 2019-06-17 12:02:05 +02:00
parent 09fe9b6858
commit 268112b6e4
16 changed files with 135 additions and 127 deletions

View File

@ -1,17 +1,8 @@
# What does this app?
1. Exchange public keys to make following communication private (via QR code)
+ Diffie Hellman key exchange
2. Exchange information needed to sync two MISP instances
2. Exchange encrypted information needed to sync two MISP instances
3. Upload information to MISP instance.
# Problems
+ Androidx migration - bug in material design dependency (just for editor)
+ Loading of self signed certificates (currently not supported)
# TODOs
+ custom password for syncUser
+ upload ack screen
+ translation
# MISPBump
![Alt text](./poster/mispbump.png)

View File

@ -126,10 +126,11 @@ public class SyncActivity extends AppCompatActivity {
public void onClick(View v) {
switch (currentSyncState) {
case settings:
uploadInformation.setCached(syncOptionsFragment.cache.isChecked());
uploadInformation.setPush(syncOptionsFragment.push.isChecked());
uploadInformation.setPull(syncOptionsFragment.pull.isChecked());
uploadInformation.setAllowSelfSigned(syncOptionsFragment.allowSelfSigned.isChecked());
uploadInformation = new UploadInformation();
uploadInformation.setAllowSelfSigned(syncOptionsFragment.getAllowSelfSigned());
uploadInformation.setPush(syncOptionsFragment.getPush());
uploadInformation.setPull(syncOptionsFragment.getPull());
uploadInformation.setCached(syncOptionsFragment.getCache());
switchState(SyncState.publicKeyExchange);
break;
@ -281,7 +282,6 @@ public class SyncActivity extends AppCompatActivity {
switch (currentSyncState) {
case settings:
String fragTag = SyncOptionsFragment.class.getSimpleName();
syncOptionsFragment = (SyncOptionsFragment) fragmentManager.findFragmentByTag(fragTag);
if (syncOptionsFragment == null) {
@ -331,11 +331,9 @@ public class SyncActivity extends AppCompatActivity {
syncInformation.syncUserAuthkey = new RandomString(40).nextString();
syncInformation.baseUrl = preferenceManager.getServerUrl();
syncInformation.syncUserPassword = new RandomString(16).nextString();
syncInformation.syncUserEmail = preferenceManager.getUserInfo().email;
String myEmailDomain = preferenceManager.getUserInfo().email.split("@")[1];
syncInformation.syncUserEmail = "syncuser_[ORG]@" + myEmailDomain;
uploadInformation = new UploadInformation(syncInformation);
uploadInformation.setLocal(syncInformation);
// encrypt serialized content
String encrypted = diffieHellman.encrypt(new Gson().toJson(syncInformation));

View File

@ -108,11 +108,12 @@ public class UploadActivity extends AppCompatActivity {
User syncUser = new User();
syncUser.org_id = organisation.id;
syncUser.role_id = User.ROLE_SYNC_USER;
syncUser.email = uploadInformation.getRemote().syncUserEmail;
String emailSaveOrgName = organisation.name.replace(" ", "").toLowerCase();
String syncUserEmailFormat = uploadInformation.getRemote().syncUserEmail;
syncUser.email = syncUserEmailFormat.replace("[ORG]", emailSaveOrgName);
uploadInformation.getRemote().syncUserEmail = syncUser.email;
// String emailSaveOrgName = organisation.name.replace(" ", "").toLowerCase();
// String syncUserEmailFormat = uploadInformation.getRemote().syncUserEmail;
// syncUser.email = syncUserEmailFormat.replace("[ORG]", emailSaveOrgName);
// uploadInformation.getLocal().syncUserEmail = syncUser.email;
syncUser.password = uploadInformation.getRemote().syncUserPassword;
syncUser.authkey = uploadInformation.getRemote().syncUserAuthkey;
@ -126,28 +127,7 @@ public class UploadActivity extends AppCompatActivity {
public void available() {
availableAction.setCurrentUploadState(UploadAction.UploadState.DONE);
orgAction.setCurrentUploadState(UploadAction.UploadState.LOADING);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
int orgId = organisationExists();
if (orgId != -1) {
Snackbar.make(rootLayout, "exists", Snackbar.LENGTH_INDEFINITE).show();
uploadInformation.getRemote().organisation.id = orgId;
// TODO if exists: add User
} else {
restClient.addOrganisation(uploadInformation.getRemote().organisation, organisationCallback);
Snackbar.make(rootLayout, "does not exist", Snackbar.LENGTH_INDEFINITE).show();
}
} catch (IOException e) {
Snackbar.make(rootLayout, "Some error", Snackbar.LENGTH_INDEFINITE).show();
e.printStackTrace();
}
}
});
t.start();
}
@Override
@ -183,15 +163,11 @@ public class UploadActivity extends AppCompatActivity {
@Override
public void failure(String error) {
// IF error = org already exists:
// resClient.addUser()
orgAction.setCurrentUploadState(UploadAction.UploadState.ERROR);
orgAction.setError(error);
uploadInformation.setCurrentSyncStatus(UploadInformation.SyncStatus.FAILURE);
preferenceManager.addUploadInformation(uploadInformation);
Snackbar.make(rootLayout, error, Snackbar.LENGTH_LONG).show();
}
};
@ -205,6 +181,7 @@ public class UploadActivity extends AppCompatActivity {
server.url = uploadInformation.getRemote().baseUrl;
server.remote_org_id = uploadInformation.getRemote().organisation.id;
server.authkey = uploadInformation.getLocal().syncUserAuthkey;
server.pull = uploadInformation.isPull();
server.push = uploadInformation.isPush();
server.caching_enabled = uploadInformation.isCached();
@ -216,9 +193,10 @@ public class UploadActivity extends AppCompatActivity {
@Override
public void failure(String error) {
userAction.setCurrentUploadState(UploadAction.UploadState.ERROR);
userAction.setError(error);
uploadInformation.setCurrentSyncStatus(UploadInformation.SyncStatus.FAILURE);
preferenceManager.addUploadInformation(uploadInformation);
Snackbar.make(rootLayout, error, Snackbar.LENGTH_LONG).show();
}
};
@ -244,9 +222,10 @@ public class UploadActivity extends AppCompatActivity {
@Override
public void failure(String error) {
serverAction.setCurrentUploadState(UploadAction.UploadState.ERROR);
serverAction.setError(error);
uploadInformation.setCurrentSyncStatus(UploadInformation.SyncStatus.FAILURE);
preferenceManager.addUploadInformation(uploadInformation);
Snackbar.make(rootLayout, error, Snackbar.LENGTH_LONG).show();
}
};

View File

@ -29,7 +29,7 @@ public class SyncAdapter extends RecyclerView.Adapter<SyncAdapter.SyncViewHolder
private IOnItemClickListener<UploadInformation> deleteListener, retryListener;
static class SyncViewHolder extends RecyclerView.ViewHolder {
MaterialPreferenceText email, password;
MaterialPreferenceText baseUrl, email, password, authkey;
TextView orgName, date;
ImageView syncStatus;
ImageButton retry, delete;
@ -57,8 +57,10 @@ public class SyncAdapter extends RecyclerView.Adapter<SyncAdapter.SyncViewHolder
orgName = v.findViewById(R.id.orgName);
date = v.findViewById(R.id.date);
baseUrl = v.findViewById(R.id.baseUrl);
email = v.findViewById(R.id.email);
password = v.findViewById(R.id.password);
authkey = v.findViewById(R.id.authkey);
syncStatus = v.findViewById(R.id.syncStatus);
@ -112,10 +114,14 @@ public class SyncAdapter extends RecyclerView.Adapter<SyncAdapter.SyncViewHolder
@Override
public void onBindViewHolder(@NonNull SyncViewHolder syncViewHolder, int i) {
syncViewHolder.orgName.setText(uploadInformationList.get(i).getRemote().organisation.name);
syncViewHolder.date.setText(uploadInformationList.get(i).getDateString());
syncViewHolder.email.setSubText(uploadInformationList.get(i).getRemote().syncUserEmail);
syncViewHolder.password.setSubText(uploadInformationList.get(i).getRemote().syncUserPassword);
syncViewHolder.orgName.setText(uploadInformationList.get(i).getRemote().organisation.name);
syncViewHolder.baseUrl.setSubText(uploadInformationList.get(i).getRemote().baseUrl);
syncViewHolder.email.setSubText(uploadInformationList.get(i).getLocal().syncUserEmail);
syncViewHolder.password.setSubText(uploadInformationList.get(i).getLocal().syncUserPassword);
syncViewHolder.authkey.setSubText(uploadInformationList.get(i).getLocal().syncUserAuthkey);
switch (uploadInformationList.get(i).getCurrentSyncStatus()) {
case COMPLETE:
@ -130,7 +136,7 @@ public class SyncAdapter extends RecyclerView.Adapter<SyncAdapter.SyncViewHolder
break;
case PENDING:
ImageViewCompat.setImageTintList(syncViewHolder.syncStatus, ColorStateList.valueOf(context.getColor(R.color.status_amber)));
syncViewHolder.syncStatus.setImageResource(R.drawable.ic_error_outline);
syncViewHolder.syncStatus.setImageResource(R.drawable.ic_info_outline);
syncViewHolder.retry.setVisibility(View.VISIBLE);
break;
}

View File

@ -14,7 +14,7 @@ import lu.circl.mispbump.R;
public class SyncOptionsFragment extends Fragment {
public Switch allowSelfSigned, push, pull, cache;
private Switch allowSelfSigned, push, pull, cache;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -27,4 +27,32 @@ public class SyncOptionsFragment extends Fragment {
return v;
}
public boolean getAllowSelfSigned() {
return allowSelfSigned.isChecked();
}
public void setAllowSelfSigned(boolean allowSelfSigned) {
this.allowSelfSigned.setChecked(allowSelfSigned);
}
public boolean getPush() {
return push.isChecked();
}
public void setPush(boolean push) {
this.push.setChecked(push);
}
public boolean getPull() {
return pull.isChecked();
}
public void setPull(boolean pull) {
this.pull.setChecked(pull);
}
public boolean getCache() {
return cache.isChecked();
}
public void setCache(boolean cache) {
this.cache.setChecked(cache);
}
}

View File

@ -84,7 +84,7 @@ public class UploadInformation implements Serializable {
return date;
}
public String getDateString() {
SimpleDateFormat df = new SimpleDateFormat("dd.mm.yyyy", Locale.getDefault());
SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy", Locale.getDefault());
return df.format(date);
}

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/white" />
<item android:color="@color/white_50"/>
</selector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M12.72,2.03C6.63,1.6 1.6,6.63 2.03,12.72 2.39,18.01 7.01,22 12.31,22H16c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1h-3.67c-3.73,0 -7.15,-2.42 -8.08,-6.03 -1.49,-5.8 3.91,-11.21 9.71,-9.71C17.58,5.18 20,8.6 20,12.33v1.1c0,0.79 -0.71,1.57 -1.5,1.57s-1.5,-0.78 -1.5,-1.57v-1.25c0,-2.51 -1.78,-4.77 -4.26,-5.12 -3.4,-0.49 -6.27,2.45 -5.66,5.87 0.34,1.91 1.83,3.49 3.72,3.94 1.84,0.43 3.59,-0.16 4.74,-1.33 0.89,1.22 2.67,1.86 4.3,1.21 1.34,-0.53 2.16,-1.9 2.16,-3.34v-1.09c0,-5.31 -3.99,-9.93 -9.28,-10.29zM12,15c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3z"
android:fillAlpha=".9"/>
</vector>

View File

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM17,13l-5,5 -5,-5h3V9h4v4h3z"/>
</vector>

View File

@ -1,5 +0,0 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM17,13l-5,5 -5,-5h3V9h4v4h3z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM19.6,8.25l-7.07,4.42c-0.32,0.2 -0.74,0.2 -1.06,0L4.4,8.25c-0.25,-0.16 -0.4,-0.43 -0.4,-0.72 0,-0.67 0.73,-1.07 1.3,-0.72L12,11l6.7,-4.19c0.57,-0.35 1.3,0.05 1.3,0.72 0,0.29 -0.15,0.56 -0.4,0.72z"/>
</vector>

View File

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z"/>
</vector>

View File

@ -1,5 +1,9 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12.65,10C11.83,7.67 9.61,6 7,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6c2.61,0 4.83,-1.67 5.65,-4H17v4h4v-4h2v-4H12.65zM7,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M12.65,10C11.7,7.31 8.9,5.5 5.77,6.12c-2.29,0.46 -4.15,2.29 -4.63,4.58C0.32,14.57 3.26,18 7,18c2.61,0 4.83,-1.67 5.65,-4H17v2c0,1.1 0.9,2 2,2s2,-0.9 2,-2v-2c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2h-8.35zM7,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M17,7h-3c-0.55,0 -1,0.45 -1,1s0.45,1 1,1h3c1.65,0 3,1.35 3,3s-1.35,3 -3,3h-3c-0.55,0 -1,0.45 -1,1s0.45,1 1,1h3c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5zM8,12c0,0.55 0.45,1 1,1h6c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L9,11c-0.55,0 -1,0.45 -1,1zM10,15L7,15c-1.65,0 -3,-1.35 -3,-3s1.35,-3 3,-3h3c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5h3c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M11.19,1.36l-7,3.11C3.47,4.79 3,5.51 3,6.3L3,11c0,5.55 3.84,10.74 9,12 5.16,-1.26 9,-6.45 9,-12L21,6.3c0,-0.79 -0.47,-1.51 -1.19,-1.83l-7,-3.11c-0.51,-0.23 -1.11,-0.23 -1.62,0zM9.29,16.29L6.7,13.7c-0.39,-0.39 -0.39,-1.02 0,-1.41 0.39,-0.39 1.02,-0.39 1.41,0L10,14.17l5.88,-5.88c0.39,-0.39 1.02,-0.39 1.41,0 0.39,0.39 0.39,1.02 0,1.41l-6.59,6.59c-0.38,0.39 -1.02,0.39 -1.41,0z"/>
</vector>

View File

@ -73,13 +73,24 @@
android:visibility="visible">
<lu.circl.mispbump.custom_views.MaterialPreferenceText
android:id="@+id/email"
android:id="@+id/baseUrl"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:pref_icon="@drawable/ic_email_black_24dp"
app:pref_icon="@drawable/ic_link"
app:subText="https://google.de"
app:text="URL" />
<lu.circl.mispbump.custom_views.MaterialPreferenceText
android:id="@+id/email"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/baseUrl"
app:pref_icon="@drawable/ic_email"
app:subText="email@email.de"
app:text="Email" />
@ -88,13 +99,23 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/email"
app:pref_icon="@drawable/ic_key"
app:subText="000000000000"
app:text="Password" />
<lu.circl.mispbump.custom_views.MaterialPreferenceText
android:id="@+id/authkey"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/password"
app:pref_icon="@drawable/ic_verified_user"
app:subText="0asd5asd5asd1asda"
app:text="Authkey" />
<ImageButton
android:id="@+id/retryButton"
android:layout_width="wrap_content"
@ -102,9 +123,10 @@
android:layout_marginEnd="8dp"
android:background="?attr/selectableItemBackground"
android:padding="8dp"
android:tint="@color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/deleteButton"
app:layout_constraintTop_toBottomOf="@+id/password"
app:layout_constraintTop_toBottomOf="@+id/authkey"
app:srcCompat="@drawable/ic_autorenew" />
<ImageButton
@ -114,43 +136,14 @@
android:layout_marginEnd="8dp"
android:background="?attr/selectableItemBackground"
android:padding="8dp"
android:tint="@color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/password"
app:layout_constraintTop_toBottomOf="@+id/authkey"
app:srcCompat="@drawable/ic_delete_forever" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!--<LinearLayout-->
<!--android:orientation="horizontal"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:padding="8dp">-->
<!--<View-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="0dp"-->
<!--android:layout_weight="1" />-->
<!--<ImageButton-->
<!--android:id="@+id/retryButton"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_marginEnd="8dp"-->
<!--android:background="?attr/selectableItemBackground"-->
<!--android:padding="8dp"-->
<!--app:srcCompat="@drawable/ic_autorenew" />-->
<!--<ImageButton-->
<!--android:id="@+id/deleteButton"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:background="?attr/selectableItemBackground"-->
<!--android:padding="8dp"-->
<!--app:srcCompat="@drawable/ic_delete_forever" />-->
<!--</LinearLayout>-->
</androidx.appcompat.widget.LinearLayoutCompat>
</com.google.android.material.card.MaterialCardView>