add login
|
@ -1,14 +1,17 @@
|
||||||
# Screenshots
|
# Screenshots
|
||||||
|
|
||||||
|
## Login
|
||||||
|
|
||||||
|
![Login](./screenshots/mispbump-login.png)
|
||||||
|
|
||||||
## Home
|
## Home
|
||||||
Entrypoint of the app.
|
|
||||||
|
|
||||||
Actions: **Profile View** (Menubar) and **New Sync** (Floating Action Button)
|
Actions: **Profile View** (Menubar) and **New Sync** (Floating Action Button)
|
||||||
|
|
||||||
![Home (Empty)](./screenshots/mispbump-home-0.png)
|
![Home (Empty)](./screenshots/mispbump-home-0.png)
|
||||||
|
|
||||||
## Profile
|
## Profile
|
||||||
Basic information about the organisation that is currently logged in.
|
Organisation information loaded automatically from your MISP instance
|
||||||
|
|
||||||
Actions: **Delete and logout** (Menubar) and **Update Info** (Floating Action Button)
|
Actions: **Delete and logout** (Menubar) and **Update Info** (Floating Action Button)
|
||||||
|
|
||||||
|
@ -34,7 +37,7 @@ After a successfull exchange an entry for this organisation will appear.
|
||||||
|
|
||||||
Actions: **Delete Sync information** (Menubar) and **Upload** (Floating Action Button in settings tab)
|
Actions: **Delete Sync information** (Menubar) and **Upload** (Floating Action Button in settings tab)
|
||||||
|
|
||||||
**Credentials:** With this credentials you will be able to log in on the other MISP instance (SyncUser)
|
**Credentials:** With these credentials you will be able to log in on the other MISP instance (SyncUser)
|
||||||
|
|
||||||
![Profile](./screenshots/mispbump-sync-info-credentials.png)
|
![Profile](./screenshots/mispbump-sync-info-credentials.png)
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ import lu.circl.mispbump.models.restModels.User;
|
||||||
public class LoginActivity extends AppCompatActivity {
|
public class LoginActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private PreferenceManager preferenceManager;
|
private PreferenceManager preferenceManager;
|
||||||
|
private MispRestClient mispRestClient;
|
||||||
|
|
||||||
private ConstraintLayout constraintLayout;
|
private ConstraintLayout constraintLayout;
|
||||||
private TextInputLayout serverAutomationKey;
|
private TextInputLayout serverAutomationKey;
|
||||||
private TextInputLayout serverUrl;
|
private TextInputLayout serverUrl;
|
||||||
|
@ -42,6 +44,12 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_login);
|
setContentView(R.layout.activity_login);
|
||||||
|
|
||||||
|
preferenceManager = PreferenceManager.getInstance(this);
|
||||||
|
mispRestClient = MispRestClient.getInstance(LoginActivity.this);
|
||||||
|
|
||||||
|
getWindow().setStatusBarColor(getColor(R.color.colorPrimary));
|
||||||
|
|
||||||
initializeViews();
|
initializeViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,26 +70,25 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initializeViews() {
|
private void initializeViews() {
|
||||||
|
constraintLayout = findViewById(R.id.rootLayout);
|
||||||
|
|
||||||
// populate Toolbar (Actionbar)
|
// populate Toolbar (Actionbar)
|
||||||
Toolbar myToolbar = findViewById(R.id.appbar);
|
Toolbar myToolbar = findViewById(R.id.appbar);
|
||||||
setSupportActionBar(myToolbar);
|
setSupportActionBar(myToolbar);
|
||||||
|
|
||||||
ActionBar ab = getSupportActionBar();
|
ActionBar ab = getSupportActionBar();
|
||||||
if (ab != null) {
|
if (ab != null) {
|
||||||
ab.setDisplayHomeAsUpEnabled(false);
|
ab.setDisplayHomeAsUpEnabled(false);
|
||||||
|
ab.setDisplayShowTitleEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
constraintLayout = findViewById(R.id.rootLayout);
|
|
||||||
|
|
||||||
Button downloadInfoButton = findViewById(R.id.login_download_button);
|
Button downloadInfoButton = findViewById(R.id.login_download_button);
|
||||||
downloadInfoButton.setOnClickListener(onClickDownload);
|
downloadInfoButton.setOnClickListener(onClickDownload);
|
||||||
|
|
||||||
serverUrl = findViewById(R.id.login_server_url);
|
serverUrl = findViewById(R.id.login_server_url);
|
||||||
serverAutomationKey = findViewById(R.id.login_automation_key);
|
serverAutomationKey = findViewById(R.id.login_automation_key);
|
||||||
progressBar = findViewById(R.id.login_progressbar);
|
progressBar = findViewById(R.id.login_progressbar);
|
||||||
|
|
||||||
preferenceManager = PreferenceManager.getInstance(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,8 +98,8 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
String url = Objects.requireNonNull(serverUrl.getEditText()).getText().toString();
|
final String url = Objects.requireNonNull(serverUrl.getEditText()).getText().toString();
|
||||||
String authkey = Objects.requireNonNull(serverAutomationKey.getEditText()).getText().toString();
|
final String authkey = Objects.requireNonNull(serverAutomationKey.getEditText()).getText().toString();
|
||||||
|
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
|
|
||||||
|
@ -113,14 +120,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// save authkey
|
mispRestClient.initMispRestInterface(url);
|
||||||
preferenceManager.setAutomationKey(authkey);
|
|
||||||
|
|
||||||
// save url
|
|
||||||
preferenceManager.setServerUrl(url);
|
|
||||||
|
|
||||||
// instance of MispRestClient with given URL
|
|
||||||
final MispRestClient mispRestClient = MispRestClient.getInstance(getApplicationContext());
|
|
||||||
|
|
||||||
// display progress bar
|
// display progress bar
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
@ -137,6 +137,13 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
public void success(Organisation organisation) {
|
public void success(Organisation organisation) {
|
||||||
preferenceManager.setUserOrgInfo(organisation);
|
preferenceManager.setUserOrgInfo(organisation);
|
||||||
|
|
||||||
|
// save authkey
|
||||||
|
preferenceManager.setAutomationKey(authkey);
|
||||||
|
|
||||||
|
// save url
|
||||||
|
preferenceManager.setServerUrl(url);
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
Intent home = new Intent(getApplicationContext(), HomeActivity.class);
|
Intent home = new Intent(getApplicationContext(), HomeActivity.class);
|
||||||
startActivity(home);
|
startActivity(home);
|
||||||
|
@ -170,7 +177,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if url is valid.
|
* TODO: Check if url is valid.
|
||||||
*
|
*
|
||||||
* @param url url to check
|
* @param url url to check
|
||||||
* @return true or false
|
* @return true or false
|
||||||
|
@ -186,7 +193,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if automation key is valid.
|
* TODO: Check if automation key is valid.
|
||||||
*
|
*
|
||||||
* @param automationKey the key to check
|
* @param automationKey the key to check
|
||||||
* @return true or false
|
* @return true or false
|
||||||
|
|
|
@ -59,26 +59,31 @@ public class MispRestClient {
|
||||||
|
|
||||||
public interface AllUsersCallback {
|
public interface AllUsersCallback {
|
||||||
void success(User[] users);
|
void success(User[] users);
|
||||||
|
|
||||||
void failure(String error);
|
void failure(String error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OrganisationCallback {
|
public interface OrganisationCallback {
|
||||||
void success(Organisation organisation);
|
void success(Organisation organisation);
|
||||||
|
|
||||||
void failure(String error);
|
void failure(String error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface AllOrganisationsCallback {
|
public interface AllOrganisationsCallback {
|
||||||
void success(Organisation[] organisations);
|
void success(Organisation[] organisations);
|
||||||
|
|
||||||
void failure(String error);
|
void failure(String error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ServerCallback {
|
public interface ServerCallback {
|
||||||
void success(Server server);
|
void success(Server server);
|
||||||
|
|
||||||
void failure(String error);
|
void failure(String error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface AllServersCallback {
|
public interface AllServersCallback {
|
||||||
void success(Server[] servers);
|
void success(Server[] servers);
|
||||||
|
|
||||||
void failure(String error);
|
void failure(String error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,21 +102,41 @@ public class MispRestClient {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MispRestClient getInstance(Context context, String url) {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new MispRestClient(context, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private MispRestClient(Context context) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the rest client to communicate with a MISP instance.
|
* Initializes the rest client to communicate with a MISP instance.
|
||||||
*
|
*
|
||||||
* @param context needed to access the preferences for loading credentials
|
* @param context needed to access the preferences for loading credentials
|
||||||
*/
|
*/
|
||||||
private MispRestClient(Context context) {
|
private MispRestClient(Context context, String url) {
|
||||||
|
|
||||||
preferenceManager = PreferenceManager.getInstance(context);
|
preferenceManager = PreferenceManager.getInstance(context);
|
||||||
|
|
||||||
String url = preferenceManager.getServerUrl();
|
if (url == null) {
|
||||||
|
url = preferenceManager.getServerUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
initMispRestInterface(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initMispRestInterface(String url) {
|
||||||
try {
|
try {
|
||||||
Retrofit retrofit = new Retrofit.Builder()
|
Retrofit retrofit = new Retrofit.Builder()
|
||||||
.baseUrl(url)
|
.baseUrl(url)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.client(getCustomClient(true, true))
|
.client(getCustomClient(true, false))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
mispRestInterface = retrofit.create(MispRestInterface.class);
|
mispRestInterface = retrofit.create(MispRestInterface.class);
|
||||||
|
@ -120,8 +145,8 @@ public class MispRestClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param unsafe whether to accept all certificates or only trusted ones
|
* @param unsafe whether to accept all certificates or only trusted ones
|
||||||
* @param logging whether to log Retrofit calls (for debugging)
|
* @param logging whether to log Retrofit calls (for debugging)
|
||||||
* @return {@link OkHttpClient}
|
* @return {@link OkHttpClient}
|
||||||
|
@ -224,7 +249,6 @@ public class MispRestClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches information about the user that is associated with saved auth key.
|
* Fetches information about the user that is associated with saved auth key.
|
||||||
*
|
*
|
||||||
|
@ -549,6 +573,7 @@ public class MispRestClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts error {@link Response}s to human readable info.
|
* Converts error {@link Response}s to human readable info.
|
||||||
|
*
|
||||||
* @param response erroneous response
|
* @param response erroneous response
|
||||||
* @param <T> type of response
|
* @param <T> type of response
|
||||||
* @return human readable String that describes the error
|
* @return human readable String that describes the error
|
||||||
|
@ -603,6 +628,7 @@ public class MispRestClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a {@link Throwable} to a human readable error message.
|
* Converts a {@link Throwable} to a human readable error message.
|
||||||
|
*
|
||||||
* @param t throwable
|
* @param t throwable
|
||||||
* @return human readable String that describes the error.
|
* @return human readable String that describes the error.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,23 +1,44 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/rootLayout"
|
android:id="@+id/rootLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".activities.LoginActivity">
|
tools:context=".activities.LoginActivity"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
android:animateLayoutChanges="true">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/appbar"
|
android:id="@+id/appbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:background="@color/colorPrimary"
|
android:background="@color/colorPrimary"
|
||||||
android:elevation="6dp"
|
android:theme="@style/ToolbarTheme"
|
||||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
app:popupTheme="@style/PopupTheme"
|
||||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="MISPbump"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:id="@+id/login_server_url"
|
android:id="@+id/login_server_url"
|
||||||
|
@ -71,13 +92,13 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="32dp"
|
android:layout_marginTop="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:text="@string/login"
|
android:text="@string/login"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/login_automation_key" />
|
app:layout_constraintTop_toBottomOf="@+id/login_progressbar" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/login_progressbar"
|
android:id="@+id/login_progressbar"
|
||||||
|
@ -87,19 +108,17 @@
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/appbar" />
|
app:layout_constraintTop_toBottomOf="@+id/login_automation_key" />
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.Guideline
|
<androidx.constraintlayout.widget.Guideline
|
||||||
android:id="@+id/guideline"
|
android:id="@+id/guideline"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
app:layout_constraintGuide_percent="0.5" />
|
app:layout_constraintGuide_percent="0.4" />
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 169 KiB After Width: | Height: | Size: 110 KiB |
Before Width: | Height: | Size: 3.4 MiB After Width: | Height: | Size: 539 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 3.3 MiB After Width: | Height: | Size: 574 KiB |
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 114 KiB |
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 116 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 55 KiB |