mirror of https://github.com/MISP/misp-bump
resolved most warnings
parent
974f3a6e5d
commit
07654028a2
|
@ -21,21 +21,21 @@
|
|||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:screenOrientation="portrait"
|
||||
android:name=".SyncActivity"
|
||||
android:label="Sync"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.Fullscreen">
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:screenOrientation="portrait"
|
||||
android:name=".CredentialsActivity"
|
||||
android:label="@string/credentials_activity"
|
||||
android:parentActivityName=".MainActivity"/>
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
|
||||
<activity android:name=".UploadActivity"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -36,7 +36,9 @@ import org.json.JSONObject;
|
|||
public class CredentialsActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
private boolean changesMade;
|
||||
private boolean saveAuthkey, saveAuthkeyPrefSet;
|
||||
private boolean saveAuthKey;
|
||||
|
||||
private PreferenceManager preferenceManager;
|
||||
|
||||
private TextInputLayout urlLayout, apiLayout;
|
||||
private TextView emptyView;
|
||||
|
@ -48,14 +50,65 @@ public class CredentialsActivity extends AppCompatActivity implements View.OnCli
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_credentials);
|
||||
|
||||
preferenceManager = PreferenceManager.Instance(this);
|
||||
|
||||
initializeViews();
|
||||
loadPreferences();
|
||||
addSaveChangesListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_credentials, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
int id = item.getItemId();
|
||||
|
||||
switch (id) {
|
||||
case android.R.id.home:
|
||||
exitSafely();
|
||||
return true;
|
||||
|
||||
case R.id.load_config:
|
||||
|
||||
// MOTOROLA
|
||||
if (Build.VERSION.SDK_INT <= 25) {
|
||||
urlLayout.getEditText().setText("http://192.168.178.200");
|
||||
apiLayout.getEditText().setText("dcfgDrNy3SyASmo9WRqyJ4LhsN1xWJ7phfTjklFa");
|
||||
} else {
|
||||
urlLayout.getEditText().setText("http://192.168.178.201");
|
||||
apiLayout.getEditText().setText("5BGhMzdHIWvaxyrTUUVNk2NflDPzXJRZQvOa3CE2");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
exitSafely();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
|
||||
switch (id) {
|
||||
case R.id.fab_download_own_org_info:
|
||||
downloadOrgInfo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeViews() {
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
|
@ -64,24 +117,21 @@ public class CredentialsActivity extends AppCompatActivity implements View.OnCli
|
|||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
|
||||
progressBar = findViewById(R.id.progressBar);
|
||||
|
||||
urlLayout = findViewById(R.id.input_layout_server_url);
|
||||
apiLayout = findViewById(R.id.input_layout_api_key);
|
||||
|
||||
FloatingActionButton fab = findViewById(R.id.fab_download_own_org_info);
|
||||
fab.setOnClickListener(this);
|
||||
|
||||
emptyView = findViewById(R.id.empty);
|
||||
organisationView = findViewById(R.id.myOrganisationView);
|
||||
|
||||
FloatingActionButton fab = findViewById(R.id.fab_download_own_org_info);
|
||||
fab.setOnClickListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads preferences
|
||||
*/
|
||||
private void loadPreferences() {
|
||||
|
||||
PreferenceManager preferenceManager = PreferenceManager.Instance(this);
|
||||
|
||||
saveAuthkeyPrefSet = preferenceManager.saveAuthkeyEnabledExists();
|
||||
saveAuthkey = preferenceManager.saveAuthkeyEnabled();
|
||||
saveAuthKey = preferenceManager.saveAuthKeyEnabled();
|
||||
|
||||
urlLayout.getEditText().setText(preferenceManager.getMyServerUrl());
|
||||
apiLayout.getEditText().setText(preferenceManager.getMyServerApiKey());
|
||||
|
@ -102,15 +152,12 @@ public class CredentialsActivity extends AppCompatActivity implements View.OnCli
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
private void savePreferences() {
|
||||
|
||||
PreferenceManager preferenceManager = PreferenceManager.Instance(this);
|
||||
|
||||
preferenceManager.setMyServerUrl(urlLayout.getEditText().getText().toString());
|
||||
preferenceManager.setSaveAuthkeyEnabled(saveAuthkey);
|
||||
preferenceManager.setSaveAuthKeyEnabled(saveAuthKey);
|
||||
|
||||
if (saveAuthkey) {
|
||||
if (saveAuthKey) {
|
||||
preferenceManager.setMyServerApiKey(apiLayout.getEditText().getText().toString());
|
||||
} else {
|
||||
preferenceManager.setMyServerApiKey("");
|
||||
|
@ -127,6 +174,9 @@ public class CredentialsActivity extends AppCompatActivity implements View.OnCli
|
|||
changesMade = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether changes were made to the URL or the API Key
|
||||
*/
|
||||
private void addSaveChangesListener() {
|
||||
urlLayout.getEditText().addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
|
@ -163,7 +213,34 @@ public class CredentialsActivity extends AppCompatActivity implements View.OnCli
|
|||
});
|
||||
}
|
||||
|
||||
private void tryDownloadOrgInfo() {
|
||||
private boolean validCredentials() {
|
||||
|
||||
boolean inputError = false;
|
||||
|
||||
String url = urlLayout.getEditText().getText().toString();
|
||||
String auth = apiLayout.getEditText().getText().toString();
|
||||
|
||||
if (url.equals("")) {
|
||||
urlLayout.setError(getResources().getString(R.string.error_url_required));
|
||||
inputError = true;
|
||||
}
|
||||
|
||||
if (auth.equals("")) {
|
||||
apiLayout.setError(getResources().getString(R.string.error_api_required));
|
||||
inputError = true;
|
||||
}
|
||||
|
||||
if (inputError) {
|
||||
return false;
|
||||
}
|
||||
|
||||
urlLayout.setError(null);
|
||||
apiLayout.setError(null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void downloadOrgInfo() {
|
||||
|
||||
if (myOrganisation != null) {
|
||||
|
||||
|
@ -181,34 +258,6 @@ public class CredentialsActivity extends AppCompatActivity implements View.OnCli
|
|||
downloadOrgInfo();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validCredentials() {
|
||||
boolean inputError = false;
|
||||
String url = urlLayout.getEditText().getText().toString();
|
||||
String auth = apiLayout.getEditText().getText().toString();
|
||||
|
||||
if (url.equals("")) {
|
||||
urlLayout.setError("Required");
|
||||
inputError = true;
|
||||
}
|
||||
|
||||
if (auth.equals("")) {
|
||||
apiLayout.setError("Required");
|
||||
inputError = true;
|
||||
}
|
||||
|
||||
if (inputError) {
|
||||
return false;
|
||||
}
|
||||
|
||||
urlLayout.setError(null);
|
||||
apiLayout.setError(null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void downloadOrgInfo() {
|
||||
|
||||
if (!validCredentials()) {
|
||||
return;
|
||||
|
@ -220,7 +269,8 @@ public class CredentialsActivity extends AppCompatActivity implements View.OnCli
|
|||
progressBar.setVisibility(View.VISIBLE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
|
||||
final MispRequest mispRequest = MispRequest.Instance(this);
|
||||
final MispRequest mispRequest = MispRequest.Instance(this, false);
|
||||
|
||||
mispRequest.setServerCredentials(urlLayout.getEditText().getText().toString(), apiLayout.getEditText().getText().toString());
|
||||
|
||||
mispRequest.getMyUser(new MispRequest.UserCallback() {
|
||||
|
@ -295,75 +345,9 @@ public class CredentialsActivity extends AppCompatActivity implements View.OnCli
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
|
||||
switch (id) {
|
||||
case R.id.fab_download_own_org_info:
|
||||
tryDownloadOrgInfo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_credentials, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
int id = item.getItemId();
|
||||
|
||||
switch (id) {
|
||||
case android.R.id.home:
|
||||
exitSafely();
|
||||
return true;
|
||||
|
||||
// case R.id.menu_item_deleteData:
|
||||
// DialogInterface.OnClickListener pos = new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int which) {
|
||||
// PreferenceManager.Instance(getApplicationContext()).clearCredentialPreferences();
|
||||
// urlLayout.getEditText().setText("");
|
||||
// apiLayout.getEditText().setText("");
|
||||
// myOrganisation = null;
|
||||
// myUser = null;
|
||||
// emptyView.setVisibility(View.VISIBLE);
|
||||
// organisationView.setVisibility(View.GONE);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// new DialogFactory(this).createDeleteDialog(pos, null).show();
|
||||
//
|
||||
// break;
|
||||
|
||||
case R.id.load_config:
|
||||
|
||||
// MOTOROLA
|
||||
if (Build.VERSION.SDK_INT <= 25) {
|
||||
urlLayout.getEditText().setText("http://192.168.178.200");
|
||||
apiLayout.getEditText().setText("dcfgDrNy3SyASmo9WRqyJ4LhsN1xWJ7phfTjklFa");
|
||||
} else {
|
||||
urlLayout.getEditText().setText("http://192.168.178.201");
|
||||
apiLayout.getEditText().setText("5BGhMzdHIWvaxyrTUUVNk2NflDPzXJRZQvOa3CE2");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
exitSafely();
|
||||
}
|
||||
|
||||
private void exitSafely() {
|
||||
|
||||
if (changesMade || !saveAuthkeyPrefSet) {
|
||||
if (changesMade || !preferenceManager.saveAuthKeyEnabledExists()) {
|
||||
saveDialog(new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
@ -394,12 +378,11 @@ public class CredentialsActivity extends AppCompatActivity implements View.OnCli
|
|||
@SuppressLint("InflateParams")
|
||||
View checkBoxView = getLayoutInflater().inflate(R.layout.dialog_save_authkey, null);
|
||||
CheckBox c = checkBoxView.findViewById(R.id.checkbox);
|
||||
c.setChecked(saveAuthkey);
|
||||
|
||||
c.setChecked(saveAuthKey);
|
||||
c.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
saveAuthkey = isChecked;
|
||||
saveAuthKey = isChecked;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import android.widget.CheckBox;
|
|||
import android.widget.TextView;
|
||||
import de.overview.wg.its.mispauth.adapter.SyncedPartnerAdapter;
|
||||
import de.overview.wg.its.mispauth.auxiliary.PreferenceManager;
|
||||
import de.overview.wg.its.mispauth.cam.DialogFactory;
|
||||
import de.overview.wg.its.mispauth.model.SyncedPartner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -47,7 +47,7 @@ public class UploadActivity extends AppCompatActivity implements View.OnClickLis
|
|||
|
||||
partnerInformation = new Gson().fromJson(info, SyncInformationQr.class);
|
||||
|
||||
mispRequest = MispRequest.Instance(this);
|
||||
mispRequest = MispRequest.Instance(this, true);
|
||||
|
||||
initializeViews();
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package de.overview.wg.its.mispauth.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -16,9 +15,10 @@ public class SyncedPartnerAdapter extends RecyclerView.Adapter<SyncedPartnerAdap
|
|||
|
||||
private List<SyncedPartner> syncedPartnerList;
|
||||
|
||||
public class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
public TextView title, dateAdded, url;
|
||||
public MyViewHolder(View view) {
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView title, dateAdded, url;
|
||||
|
||||
MyViewHolder(View view) {
|
||||
super(view);
|
||||
title = view.findViewById(R.id.title);
|
||||
dateAdded = view.findViewById(R.id.dateSynced);
|
||||
|
@ -26,7 +26,7 @@ public class SyncedPartnerAdapter extends RecyclerView.Adapter<SyncedPartnerAdap
|
|||
}
|
||||
}
|
||||
|
||||
public SyncedPartnerAdapter(Context context, List<SyncedPartner> syncedPartnerList) {
|
||||
public SyncedPartnerAdapter(List<SyncedPartner> syncedPartnerList) {
|
||||
this.syncedPartnerList = syncedPartnerList;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,13 +50,13 @@ public class PreferenceManager {
|
|||
editor.apply();
|
||||
}
|
||||
|
||||
public boolean saveAuthkeyEnabledExists() {
|
||||
public boolean saveAuthKeyEnabledExists() {
|
||||
return userPreferences.contains(PREF_KEY_SAVE_AUTHKEY_ENABLED);
|
||||
}
|
||||
public boolean saveAuthkeyEnabled() {
|
||||
public boolean saveAuthKeyEnabled() {
|
||||
return userPreferences.getBoolean(PREF_KEY_SAVE_AUTHKEY_ENABLED, false);
|
||||
}
|
||||
public void setSaveAuthkeyEnabled(boolean save) {
|
||||
public void setSaveAuthKeyEnabled(boolean save) {
|
||||
SharedPreferences.Editor editor = userPreferences.edit();
|
||||
editor.putBoolean(PREF_KEY_SAVE_AUTHKEY_ENABLED, save);
|
||||
editor.apply();
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Random;
|
|||
|
||||
public class RandomString {
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
private static final String upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
private static final String lower = upper.toLowerCase(Locale.ROOT);
|
||||
private static final String digits = "0123456789";
|
||||
|
@ -16,7 +17,7 @@ public class RandomString {
|
|||
private final char[] symbols;
|
||||
private final char[] buf;
|
||||
|
||||
public RandomString(int length, Random random, String symbols) {
|
||||
private RandomString(int length, Random random, String symbols) {
|
||||
|
||||
if (length < 1) {
|
||||
throw new IllegalArgumentException();
|
||||
|
@ -30,11 +31,9 @@ public class RandomString {
|
|||
this.buf = new char[length];
|
||||
|
||||
}
|
||||
|
||||
public RandomString(int length, Random random) {
|
||||
private RandomString(int length, Random random) {
|
||||
this(length, random, alphaNum);
|
||||
}
|
||||
|
||||
public RandomString(int length) {
|
||||
this(length, new SecureRandom());
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package de.overview.wg.its.mispauth.auxiliary;
|
||||
|
||||
import com.android.volley.AuthFailureError;
|
||||
import com.android.volley.NoConnectionError;
|
||||
import com.android.volley.ServerError;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.*;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
@ -21,7 +18,7 @@ public class ReadableError {
|
|||
String name = response.getString("name");
|
||||
String errorName = error.getJSONArray("name").get(0).toString();
|
||||
|
||||
if(!errorName.equals("")) {
|
||||
if (!errorName.equals("")) {
|
||||
return errorName;
|
||||
} else if (!name.equals("")) {
|
||||
return name;
|
||||
|
@ -34,12 +31,19 @@ public class ReadableError {
|
|||
|
||||
if (volleyError instanceof NoConnectionError) {
|
||||
return "Connection failed";
|
||||
} else if (volleyError instanceof TimeoutError) {
|
||||
return "Connection timed out";
|
||||
} else if (volleyError instanceof NetworkError) {
|
||||
return "Network error";
|
||||
} else if (volleyError instanceof AuthFailureError) {
|
||||
return "Authentication failed";
|
||||
} else if (volleyError instanceof ServerError) {
|
||||
return "Server error";
|
||||
} else if (volleyError instanceof ParseError) {
|
||||
return "Parsing error";
|
||||
}
|
||||
|
||||
return volleyError.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class DialogFactory {
|
|||
View title = inflater.inflate(R.layout.dialog_public_key, null);
|
||||
adb.setCustomTitle(title);
|
||||
|
||||
adb.setMessage("\nYou received a Public Key from " + pkqr.getOrganisation() + " (" + pkqr.getUser() + ")");
|
||||
adb.setMessage("\nOrganisation: " + pkqr.getOrganisation() + "\nEmail: " + pkqr.getEmail());
|
||||
|
||||
adb.setPositiveButton(context.getResources().getString(R.string.accept), positiveListener);
|
||||
adb.setNegativeButton(context.getResources().getString(R.string.reject), negativeListener);
|
||||
|
@ -85,36 +85,6 @@ public class DialogFactory {
|
|||
}
|
||||
|
||||
|
||||
public Dialog createDeleteDialog(DialogInterface.OnClickListener pos,
|
||||
DialogInterface.OnClickListener neg) {
|
||||
adb.setTitle(context.getResources().getString(R.string.delete_local_data));
|
||||
adb.setMessage(context.getResources().getString(R.string.delete_local_data_msg));
|
||||
|
||||
adb.setPositiveButton(context.getResources().getString(R.string.delete), pos);
|
||||
adb.setNegativeButton(android.R.string.cancel, neg);
|
||||
|
||||
adb.setCancelable(true);
|
||||
Dialog d = adb.create();
|
||||
d.getWindow().setWindowAnimations(R.style.DialogAnimation);
|
||||
return d;
|
||||
}
|
||||
|
||||
public Dialog createSelectDeleteDialog(DialogInterface.OnClickListener pos,
|
||||
DialogInterface.OnClickListener neg) {
|
||||
|
||||
adb.setTitle("Delete local data");
|
||||
adb.setMessage("");
|
||||
|
||||
adb.setPositiveButton(context.getResources().getString(R.string.delete), pos);
|
||||
adb.setNegativeButton(android.R.string.cancel, neg);
|
||||
|
||||
adb.setCancelable(true);
|
||||
Dialog d = adb.create();
|
||||
d.getWindow().setWindowAnimations(R.style.DialogAnimation);
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
public Dialog createOverrideDialog(DialogInterface.OnClickListener pos,
|
||||
DialogInterface.OnClickListener neg) {
|
||||
|
||||
|
|
|
@ -6,28 +6,26 @@ import org.json.JSONObject;
|
|||
public class PublicKeyQr {
|
||||
|
||||
private static final String KEY_ORG = "org";
|
||||
private static final String KEY_USER = "user";
|
||||
private static final String KEY_EMAIL = "email";
|
||||
private static final String KEY_KEY = "key";
|
||||
|
||||
private String organisation, user, key;
|
||||
private String organisation, email, key;
|
||||
|
||||
public PublicKeyQr(JSONObject qr) throws JSONException {
|
||||
organisation = qr.getString(KEY_ORG);
|
||||
user = qr.getString(KEY_USER);
|
||||
email = qr.getString(KEY_EMAIL);
|
||||
key = qr.getString(KEY_KEY);
|
||||
}
|
||||
|
||||
public PublicKeyQr(String qr) throws JSONException{
|
||||
public PublicKeyQr(String qr) throws JSONException {
|
||||
JSONObject json = new JSONObject(qr);
|
||||
|
||||
organisation = json.getString(KEY_ORG);
|
||||
user = json.getString(KEY_USER);
|
||||
email = json.getString(KEY_EMAIL);
|
||||
key = json.getString(KEY_KEY);
|
||||
}
|
||||
|
||||
public PublicKeyQr(String organisation, String user, String key) {
|
||||
public PublicKeyQr(String organisation, String email, String key) {
|
||||
this.organisation = organisation;
|
||||
this.user = user;
|
||||
this.email = email;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
|
@ -36,7 +34,7 @@ public class PublicKeyQr {
|
|||
JSONObject json = new JSONObject();
|
||||
|
||||
json.put(KEY_ORG, organisation);
|
||||
json.put(KEY_USER, user);
|
||||
json.put(KEY_EMAIL, email);
|
||||
json.put(KEY_KEY, key);
|
||||
|
||||
return json;
|
||||
|
@ -50,11 +48,9 @@ public class PublicKeyQr {
|
|||
public String getOrganisation() {
|
||||
return organisation;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ import java.util.Map;
|
|||
*/
|
||||
public class MispRequest {
|
||||
|
||||
private static final String TAG = "DEBUG";
|
||||
private static MispRequest instance;
|
||||
|
||||
private RequestQueue requestQueue;
|
||||
|
@ -50,11 +49,13 @@ public class MispRequest {
|
|||
/**
|
||||
* @param context for Volley and PreferenceManager
|
||||
*/
|
||||
private MispRequest(Context context) {
|
||||
private MispRequest(Context context, boolean loadSavedCredentials) {
|
||||
requestQueue = Volley.newRequestQueue(context);
|
||||
preferenceManager = PreferenceManager.Instance(context);
|
||||
|
||||
loadSavedCredentials();
|
||||
if (loadSavedCredentials) {
|
||||
preferenceManager = PreferenceManager.Instance(context);
|
||||
loadSavedCredentials();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSavedCredentials() {
|
||||
|
@ -121,13 +122,11 @@ public class MispRequest {
|
|||
Response.ErrorListener errorListener = new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Log.e(TAG, "onErrorResponse: " + error.toString());
|
||||
callback.onError(error);
|
||||
}
|
||||
};
|
||||
|
||||
if (serverUrl.isEmpty() || apiKey.isEmpty()) {
|
||||
Log.e(TAG, "getMyUser: server or api key is empty!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -193,14 +192,13 @@ public class MispRequest {
|
|||
}
|
||||
|
||||
callback.onResult(resultArray);
|
||||
Log.d(TAG, "onResponse: " + resultArray.toString());
|
||||
}
|
||||
};
|
||||
|
||||
Response.ErrorListener errorListener = new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Log.d(TAG, "onErrorResponse: " + ReadableError.toReadable(error));
|
||||
callback.onError(error);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -324,75 +322,10 @@ public class MispRequest {
|
|||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
// private SSLSocketFactory getSocketFactory(Context context) {
|
||||
//
|
||||
// CertificateFactory cf = null;
|
||||
// try {
|
||||
// cf = CertificateFactory.getInstance("X.509");
|
||||
// InputStream caInput = context.getResources().openRawResource(R.raw.server);
|
||||
// Certificate ca;
|
||||
// try {
|
||||
// ca = cf.generateCertificate(caInput);
|
||||
// Log.e("CERT", "ca=" + ((X509Certificate) ca).getSubjectDN());
|
||||
// } finally {
|
||||
// caInput.close();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// String keyStoreType = KeyStore.getDefaultType();
|
||||
// KeyStore keyStore = KeyStore.getInstance(keyStoreType);
|
||||
// keyStore.load(null, null);
|
||||
// keyStore.setCertificateEntry("ca", ca);
|
||||
//
|
||||
//
|
||||
// String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
|
||||
// TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
|
||||
// tmf.init(keyStore);
|
||||
//
|
||||
//
|
||||
// HostnameVerifier hostnameVerifier = new HostnameVerifier() {
|
||||
// @Override
|
||||
// public boolean verify(String hostname, SSLSession session) {
|
||||
//
|
||||
// Log.e("CipherUsed", session.getCipherSuite());
|
||||
// return hostname.compareTo("192.168.1.10")==0; //The Hostname of your server
|
||||
//
|
||||
// }
|
||||
// };
|
||||
//
|
||||
//
|
||||
// HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
|
||||
// SSLContext context = null;
|
||||
// context = SSLContext.getInstance("TLS");
|
||||
//
|
||||
// context.init(null, tmf.getTrustManagers(), null);
|
||||
// HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());
|
||||
//
|
||||
// SSLSocketFactory sf = context.getSocketFactory();
|
||||
//
|
||||
//
|
||||
// return sf;
|
||||
//
|
||||
// } catch (CertificateException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (NoSuchAlgorithmException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (KeyStoreException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (FileNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (KeyManagementException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
public static MispRequest Instance(Context context, boolean loadSavedCredentials) {
|
||||
|
||||
public static MispRequest Instance(Context context) {
|
||||
if (instance == null) {
|
||||
instance = new MispRequest(context);
|
||||
instance = new MispRequest(context, loadSavedCredentials);
|
||||
}
|
||||
|
||||
return instance;
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
android:text="@string/sync_info_let_scan"/>
|
||||
|
||||
<ImageButton
|
||||
android:contentDescription="@string/nav_exit"
|
||||
android:contentDescription="@string/exit"
|
||||
android:id="@+id/close"
|
||||
android:padding="16dp"
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:cardBackgroundColor="@color/colorWhite"
|
||||
app:cardElevation="3dp"
|
||||
app:cardElevation="1dp"
|
||||
app:cardCornerRadius="0dp"
|
||||
app:cardPreventCornerOverlap="true"
|
||||
app:contentPadding="16dp">
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
<resources>
|
||||
<string name="app_name">MISPBump</string>
|
||||
|
||||
<string name="nav_exit">Verlassen</string>
|
||||
<string name="bottom_nav_next">Weiter</string>
|
||||
<string name="bottom_nav_prev">Zurück</string>
|
||||
<string name="exit">Verlassen</string>
|
||||
<string name="previous">Zurück</string>
|
||||
<string name="empty_sync_list">Sie haben bisher keine Instanzen verknüpft</string>
|
||||
<string name="empty_my_org">Keine lokalen Informationen vorhanden</string>
|
||||
<string name="save_authkey">Autorisierungschlüssel speichern (potentielles Sicherheitsrisiko)</string>
|
||||
|
@ -37,4 +36,7 @@
|
|||
<string name="credential_settings">Autentifizierungseinstellungen</string>
|
||||
|
||||
<string name="sync_info_let_scan">Drücken Sie weiter, wenn dieser QR-Code gescannt wurde</string>
|
||||
|
||||
<string name="error_url_required">Url Ihrer MISP Instanz benötigt</string>
|
||||
<string name="error_api_required">Autorisierungsschlüssel Ihrer MISP Instanz benötigt</string>
|
||||
</resources>
|
|
@ -1,14 +1,13 @@
|
|||
<resources>
|
||||
<string name="app_name">MISPBump</string>
|
||||
|
||||
// Bottom Navigation
|
||||
<string name="nav_exit">Exit</string>
|
||||
<string name="exit">Exit</string>
|
||||
<string name="bottom_nav_next">Next</string>
|
||||
<string name="bottom_nav_prev">Back</string>
|
||||
<string name="previous">Back</string>
|
||||
|
||||
<string name="empty_sync_list">You have not synced any instances yet</string>
|
||||
<string name="empty_my_org">No local information available</string>
|
||||
<string name="save_authkey">Save authkey (potential security risk)</string>
|
||||
<string name="save_authkey">Save auth-key (potential security risk)</string>
|
||||
<string name="unsaved_changes">Unsaved changes</string>
|
||||
<string name="save_changes">Do you want to save the changes?</string>
|
||||
<string name="save">Save</string>
|
||||
|
@ -24,17 +23,16 @@
|
|||
<string name="str_continue">continue</string>
|
||||
<string name="delete">delete</string>
|
||||
<string name="delete_local_data">Delete local data</string>
|
||||
<string name="delete_local_data_msg">The URL, Authkey and your local data will be removed.\nThis information is needed for synchronisation.</string>
|
||||
<string name="delete_local_data_msg">The URL, authentication key and your local data will be removed.\nThis information is needed for synchronisation.</string>
|
||||
<string name="override">override</string>
|
||||
<string name="override_local_data">Override local data</string>
|
||||
<string name="override_local_data_msg">Do you really want to override the local information stored on this device?</string>
|
||||
|
||||
<string name="credentials_activity">Sync Profile</string>
|
||||
|
||||
<string name="server_url">Server URL</string>
|
||||
<string name="authkey">Authkey</string>
|
||||
|
||||
<string name="credential_settings">Credential Settings</string>
|
||||
|
||||
<string name="sync_info_let_scan">Press continue if this QR-Code was scanned</string>
|
||||
|
||||
<string name="error_url_required">Enter MISP base url</string>
|
||||
<string name="error_api_required">Enter MISP api key</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue