mirror of https://github.com/MISP/misp-bump
prepare model change
parent
9fbef90f91
commit
4a9d428266
|
@ -121,79 +121,73 @@ public class ExchangeActivity extends AppCompatActivity {
|
||||||
syncInformation.syncUserAuthkey = new RandomString(40).nextString();
|
syncInformation.syncUserAuthkey = new RandomString(40).nextString();
|
||||||
syncInformation.baseUrl = preferenceManager.getUserCredentials().first;
|
syncInformation.baseUrl = preferenceManager.getUserCredentials().first;
|
||||||
syncInformation.syncUserPassword = new RandomString(16).nextString();
|
syncInformation.syncUserPassword = new RandomString(16).nextString();
|
||||||
syncInformation.syncUserEmail = preferenceManager.getUserInfo().email;
|
syncInformation.syncUserEmail = preferenceManager.getUserInfo().getEmail();
|
||||||
return syncInformation;
|
return syncInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void showQrCode(final Bitmap bitmap) {
|
private void showQrCode(final Bitmap bitmap) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(() -> {
|
||||||
@Override
|
qrCode.setImageBitmap(bitmap);
|
||||||
public void run() {
|
qrFrame.setVisibility(View.VISIBLE);
|
||||||
qrCode.setImageBitmap(bitmap);
|
|
||||||
qrFrame.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSyncState(SyncState state) {
|
private void setSyncState(SyncState state) {
|
||||||
currentSyncState = state;
|
currentSyncState = state;
|
||||||
|
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(() -> {
|
||||||
@Override
|
switch (currentSyncState) {
|
||||||
public void run() {
|
case KEY_EXCHANGE:
|
||||||
switch (currentSyncState) {
|
prevButton.setImageDrawable(getDrawable(R.drawable.ic_close));
|
||||||
case KEY_EXCHANGE:
|
prevButton.setVisibility(View.VISIBLE);
|
||||||
prevButton.setImageDrawable(getDrawable(R.drawable.ic_close));
|
nextButton.setVisibility(View.GONE);
|
||||||
prevButton.setVisibility(View.VISIBLE);
|
|
||||||
nextButton.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
setCameraPreviewEnabled(true);
|
setCameraPreviewEnabled(true);
|
||||||
showQrCode(publicKeyQr);
|
showQrCode(publicKeyQr);
|
||||||
|
|
||||||
setReadQrStatus(ReadQrStatus.PENDING);
|
setReadQrStatus(ReadQrStatus.PENDING);
|
||||||
scanFeedbackText.setText(R.string.scan_qr_hint);
|
scanFeedbackText.setText(R.string.scan_qr_hint);
|
||||||
qrContentInfo.setText(R.string.public_key);
|
qrContentInfo.setText(R.string.public_key);
|
||||||
break;
|
break;
|
||||||
case KEY_EXCHANGE_DONE:
|
case KEY_EXCHANGE_DONE:
|
||||||
prevButton.setImageDrawable(getDrawable(R.drawable.ic_close));
|
prevButton.setImageDrawable(getDrawable(R.drawable.ic_close));
|
||||||
prevButton.setVisibility(View.VISIBLE);
|
prevButton.setVisibility(View.VISIBLE);
|
||||||
nextButton.setImageDrawable(getDrawable(R.drawable.ic_arrow_forward));
|
nextButton.setImageDrawable(getDrawable(R.drawable.ic_arrow_forward));
|
||||||
nextButton.setVisibility(View.VISIBLE);
|
nextButton.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
setCameraPreviewEnabled(false);
|
setCameraPreviewEnabled(false);
|
||||||
showQrCode(publicKeyQr);
|
showQrCode(publicKeyQr);
|
||||||
|
|
||||||
setReadQrStatus(ReadQrStatus.SUCCESS);
|
setReadQrStatus(ReadQrStatus.SUCCESS);
|
||||||
scanFeedbackText.setText(R.string.public_key_received_hint);
|
scanFeedbackText.setText(R.string.public_key_received_hint);
|
||||||
qrContentInfo.setText(R.string.public_key);
|
qrContentInfo.setText(R.string.public_key);
|
||||||
break;
|
break;
|
||||||
case DATA_EXCHANGE:
|
case DATA_EXCHANGE:
|
||||||
prevButton.setImageDrawable(getDrawable(R.drawable.ic_arrow_back));
|
prevButton.setImageDrawable(getDrawable(R.drawable.ic_arrow_back));
|
||||||
prevButton.setVisibility(View.VISIBLE);
|
prevButton.setVisibility(View.VISIBLE);
|
||||||
nextButton.setVisibility(View.GONE);
|
nextButton.setVisibility(View.GONE);
|
||||||
|
|
||||||
setCameraPreviewEnabled(true);
|
setCameraPreviewEnabled(true);
|
||||||
showQrCode(dataQr);
|
showQrCode(dataQr);
|
||||||
|
|
||||||
setReadQrStatus(ReadQrStatus.PENDING);
|
setReadQrStatus(ReadQrStatus.PENDING);
|
||||||
scanFeedbackText.setText(R.string.scan_qr_hint);
|
scanFeedbackText.setText(R.string.scan_qr_hint);
|
||||||
qrContentInfo.setText(R.string.sync_information);
|
qrContentInfo.setText(R.string.sync_information);
|
||||||
break;
|
break;
|
||||||
case DATA_EXCHANGE_DONE:
|
case DATA_EXCHANGE_DONE:
|
||||||
prevButton.setImageDrawable(getDrawable(R.drawable.ic_arrow_back));
|
prevButton.setImageDrawable(getDrawable(R.drawable.ic_arrow_back));
|
||||||
prevButton.setVisibility(View.VISIBLE);
|
prevButton.setVisibility(View.VISIBLE);
|
||||||
nextButton.setImageDrawable(getDrawable(R.drawable.ic_check));
|
nextButton.setImageDrawable(getDrawable(R.drawable.ic_check));
|
||||||
nextButton.setVisibility(View.VISIBLE);
|
nextButton.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
setCameraPreviewEnabled(false);
|
setCameraPreviewEnabled(false);
|
||||||
showQrCode(dataQr);
|
showQrCode(dataQr);
|
||||||
|
|
||||||
setReadQrStatus(ReadQrStatus.SUCCESS);
|
setReadQrStatus(ReadQrStatus.SUCCESS);
|
||||||
scanFeedbackText.setText(R.string.sync_info_received_hint);
|
scanFeedbackText.setText(R.string.sync_info_received_hint);
|
||||||
qrContentInfo.setText(R.string.public_key);
|
qrContentInfo.setText(R.string.public_key);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -261,107 +255,98 @@ public class ExchangeActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
||||||
private CameraFragment.QrScanCallback onQrScanned() {
|
private CameraFragment.QrScanCallback onQrScanned() {
|
||||||
return new CameraFragment.QrScanCallback() {
|
return qrData -> {
|
||||||
@Override
|
cameraFragment.setReadQrEnabled(false);
|
||||||
public void qrScanResult(String qrData) {
|
|
||||||
cameraFragment.setReadQrEnabled(false);
|
|
||||||
|
|
||||||
switch (currentSyncState) {
|
switch (currentSyncState) {
|
||||||
case KEY_EXCHANGE:
|
case KEY_EXCHANGE:
|
||||||
try {
|
try {
|
||||||
diffieHellman.setForeignPublicKey(DiffieHellman.publicKeyFromString(qrData));
|
diffieHellman.setForeignPublicKey(DiffieHellman.publicKeyFromString(qrData));
|
||||||
setSyncState(SyncState.KEY_EXCHANGE_DONE);
|
setSyncState(SyncState.KEY_EXCHANGE_DONE);
|
||||||
dataQr = generateLocalSyncInfoBitmap();
|
dataQr = generateLocalSyncInfoBitmap();
|
||||||
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
|
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
|
||||||
if (currentReadQrStatus == ReadQrStatus.PENDING) {
|
if (currentReadQrStatus == ReadQrStatus.PENDING) {
|
||||||
setReadQrStatus(ReadQrStatus.FAILURE);
|
setReadQrStatus(ReadQrStatus.FAILURE);
|
||||||
Snackbar.make(rootLayout, "Public key not parsable", Snackbar.LENGTH_LONG).show();
|
Snackbar.make(rootLayout, "Public key not parsable", Snackbar.LENGTH_LONG).show();
|
||||||
}
|
|
||||||
|
|
||||||
cameraFragment.setReadQrEnabled(true);
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case DATA_EXCHANGE:
|
|
||||||
try {
|
|
||||||
final SyncInformation remoteSyncInfo = new Gson().fromJson(diffieHellman.decrypt(qrData), SyncInformation.class);
|
|
||||||
|
|
||||||
final List<UploadInformation> uploadInformationList = preferenceManager.getUploadInformationList();
|
cameraFragment.setReadQrEnabled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DATA_EXCHANGE:
|
||||||
|
try {
|
||||||
|
final SyncInformation remoteSyncInfo = new Gson().fromJson(diffieHellman.decrypt(qrData), SyncInformation.class);
|
||||||
|
|
||||||
for (final UploadInformation ui : uploadInformationList) {
|
final List<UploadInformation> uploadInformationList = preferenceManager.getUploadInformationList();
|
||||||
if (ui.getRemote().organisation.getUuid().equals(remoteSyncInfo.organisation.getUuid())) {
|
|
||||||
DialogManager.syncAlreadyExistsDialog(ui.getRemote(), remoteSyncInfo, ExchangeActivity.this, new DialogManager.IDialogFeedback() {
|
|
||||||
@Override
|
|
||||||
public void positive() {
|
|
||||||
// update remote info only
|
|
||||||
uploadInformation.setUuid(ui.getUuid());
|
|
||||||
uploadInformation.setDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
for (final UploadInformation ui : uploadInformationList) {
|
||||||
public void negative() {
|
if (ui.getRemote().organisation.getUuid().equals(remoteSyncInfo.organisation.getUuid())) {
|
||||||
// replace credentials too
|
DialogManager.syncAlreadyExistsDialog(ui.getRemote(), remoteSyncInfo, ExchangeActivity.this, new DialogManager.IDialogFeedback() {
|
||||||
uploadInformationList.remove(ui);
|
@Override
|
||||||
preferenceManager.setUploadInformationList(uploadInformationList);
|
public void positive() {
|
||||||
}
|
// update remote info only
|
||||||
});
|
uploadInformation.setUuid(ui.getUuid());
|
||||||
|
uploadInformation.setDate();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
@Override
|
||||||
}
|
public void negative() {
|
||||||
|
// replace credentials too
|
||||||
|
uploadInformationList.remove(ui);
|
||||||
|
preferenceManager.setUploadInformationList(uploadInformationList);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadInformation.setRemote(remoteSyncInfo);
|
|
||||||
preferenceManager.addUploadInformation(uploadInformation);
|
|
||||||
setSyncState(SyncState.DATA_EXCHANGE_DONE);
|
|
||||||
} catch (JsonSyntaxException e) {
|
|
||||||
if (currentReadQrStatus == ReadQrStatus.PENDING) {
|
|
||||||
setReadQrStatus(ReadQrStatus.FAILURE);
|
|
||||||
Snackbar.make(rootLayout, "Sync information not parsable", Snackbar.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
cameraFragment.setReadQrEnabled(true);
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
uploadInformation.setRemote(remoteSyncInfo);
|
||||||
|
preferenceManager.addUploadInformation(uploadInformation);
|
||||||
|
setSyncState(SyncState.DATA_EXCHANGE_DONE);
|
||||||
|
} catch (JsonSyntaxException e) {
|
||||||
|
if (currentReadQrStatus == ReadQrStatus.PENDING) {
|
||||||
|
setReadQrStatus(ReadQrStatus.FAILURE);
|
||||||
|
Snackbar.make(rootLayout, "Sync information not parsable", Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
cameraFragment.setReadQrEnabled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener onPrevClicked() {
|
private View.OnClickListener onPrevClicked() {
|
||||||
return new View.OnClickListener() {
|
return v -> {
|
||||||
@Override
|
switch (currentSyncState) {
|
||||||
public void onClick(View v) {
|
case KEY_EXCHANGE:
|
||||||
switch (currentSyncState) {
|
case KEY_EXCHANGE_DONE:
|
||||||
case KEY_EXCHANGE:
|
// TODO warning that sync will be lost
|
||||||
case KEY_EXCHANGE_DONE:
|
finish();
|
||||||
// TODO warning that sync will be lost
|
break;
|
||||||
finish();
|
case DATA_EXCHANGE:
|
||||||
break;
|
case DATA_EXCHANGE_DONE:
|
||||||
case DATA_EXCHANGE:
|
setSyncState(SyncState.KEY_EXCHANGE_DONE);
|
||||||
case DATA_EXCHANGE_DONE:
|
break;
|
||||||
setSyncState(SyncState.KEY_EXCHANGE_DONE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener onNextClicked() {
|
private View.OnClickListener onNextClicked() {
|
||||||
return new View.OnClickListener() {
|
return v -> {
|
||||||
@Override
|
switch (currentSyncState) {
|
||||||
public void onClick(View v) {
|
case KEY_EXCHANGE_DONE:
|
||||||
switch (currentSyncState) {
|
setSyncState(SyncState.DATA_EXCHANGE);
|
||||||
case KEY_EXCHANGE_DONE:
|
break;
|
||||||
setSyncState(SyncState.DATA_EXCHANGE);
|
case DATA_EXCHANGE_DONE:
|
||||||
break;
|
uploadInformation.setCurrentSyncStatus(UploadInformation.SyncStatus.PENDING);
|
||||||
case DATA_EXCHANGE_DONE:
|
preferenceManager.addUploadInformation(uploadInformation);
|
||||||
uploadInformation.setCurrentSyncStatus(UploadInformation.SyncStatus.PENDING);
|
Intent i = new Intent(ExchangeActivity.this, UploadInfoActivity.class);
|
||||||
preferenceManager.addUploadInformation(uploadInformation);
|
i.putExtra(UploadInfoActivity.EXTRA_UPLOAD_INFO_UUID, uploadInformation.getUuid());
|
||||||
Intent i = new Intent(ExchangeActivity.this, UploadInfoActivity.class);
|
startActivity(i);
|
||||||
i.putExtra(UploadInfoActivity.EXTRA_UPLOAD_INFO_UUID, uploadInformation.getUuid());
|
finish();
|
||||||
startActivity(i);
|
break;
|
||||||
finish();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package lu.circl.mispbump.activities;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -11,6 +12,7 @@ import android.widget.TextView;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.app.ActivityOptionsCompat;
|
import androidx.core.app.ActivityOptionsCompat;
|
||||||
|
import androidx.core.util.Pair;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
@ -20,9 +22,12 @@ import java.util.List;
|
||||||
|
|
||||||
import lu.circl.mispbump.R;
|
import lu.circl.mispbump.R;
|
||||||
import lu.circl.mispbump.adapters.UploadInfoAdapter;
|
import lu.circl.mispbump.adapters.UploadInfoAdapter;
|
||||||
|
import lu.circl.mispbump.auxiliary.MispRestClient;
|
||||||
import lu.circl.mispbump.auxiliary.PreferenceManager;
|
import lu.circl.mispbump.auxiliary.PreferenceManager;
|
||||||
import lu.circl.mispbump.interfaces.OnRecyclerItemClickListener;
|
import lu.circl.mispbump.interfaces.OnRecyclerItemClickListener;
|
||||||
|
import lu.circl.mispbump.models.SyncModel;
|
||||||
import lu.circl.mispbump.models.UploadInformation;
|
import lu.circl.mispbump.models.UploadInformation;
|
||||||
|
import lu.circl.mispbump.models.restModels.Server;
|
||||||
|
|
||||||
|
|
||||||
public class HomeActivity extends AppCompatActivity {
|
public class HomeActivity extends AppCompatActivity {
|
||||||
|
@ -62,7 +67,6 @@ public class HomeActivity extends AppCompatActivity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// invoke superclass to handle unrecognized item (eg. homeAsUp)
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,12 +84,7 @@ public class HomeActivity extends AppCompatActivity {
|
||||||
setSupportActionBar(myToolbar);
|
setSupportActionBar(myToolbar);
|
||||||
|
|
||||||
FloatingActionButton syncFab = findViewById(R.id.home_fab);
|
FloatingActionButton syncFab = findViewById(R.id.home_fab);
|
||||||
syncFab.setOnClickListener(new View.OnClickListener() {
|
syncFab.setOnClickListener(v -> startActivity(new Intent(HomeActivity.this, ExchangeActivity.class)));
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
startActivity(new Intent(HomeActivity.this, ExchangeActivity.class));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initRecyclerView() {
|
private void initRecyclerView() {
|
||||||
|
@ -97,6 +96,32 @@ public class HomeActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshRecyclerView() {
|
private void refreshRecyclerView() {
|
||||||
|
|
||||||
|
Pair<String, String> credentials = preferenceManager.getUserCredentials();
|
||||||
|
MispRestClient mispRestClient = MispRestClient.getInstance(credentials.first, credentials.second);
|
||||||
|
|
||||||
|
mispRestClient.getAllServers(new MispRestClient.AllServersCallback() {
|
||||||
|
@Override
|
||||||
|
public void success(Server[] servers) {
|
||||||
|
SyncModel.createFromServer(mispRestClient, servers[0], new SyncModel.InitializeWithServerObject() {
|
||||||
|
@Override
|
||||||
|
public void success(SyncModel syncModel) {
|
||||||
|
Log.d("DEBUG", syncModel.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failure(String error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failure(String error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
uploadInformationList = preferenceManager.getUploadInformationList();
|
uploadInformationList = preferenceManager.getUploadInformationList();
|
||||||
|
|
||||||
if (uploadInformationList.isEmpty()) {
|
if (uploadInformationList.isEmpty()) {
|
||||||
|
@ -111,15 +136,12 @@ public class HomeActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
||||||
private OnRecyclerItemClickListener<Integer> onRecyclerItemClickListener() {
|
private OnRecyclerItemClickListener<Integer> onRecyclerItemClickListener() {
|
||||||
return new OnRecyclerItemClickListener<Integer>() {
|
return (v, index) -> {
|
||||||
@Override
|
Intent i = new Intent(HomeActivity.this, UploadInfoActivity.class);
|
||||||
public void onClick(View v, Integer index) {
|
i.putExtra(UploadInfoActivity.EXTRA_UPLOAD_INFO_UUID, uploadInformationList.get(index).getUuid());
|
||||||
Intent i = new Intent(HomeActivity.this, UploadInfoActivity.class);
|
|
||||||
i.putExtra(UploadInfoActivity.EXTRA_UPLOAD_INFO_UUID, uploadInformationList.get(index).getUuid());
|
|
||||||
|
|
||||||
ActivityOptionsCompat options = ActivityOptionsCompat.makeClipRevealAnimation(v.findViewById(R.id.rootLayout), (int) v.getX(), (int) v.getY(), v.getWidth(), v.getHeight());
|
ActivityOptionsCompat options = ActivityOptionsCompat.makeClipRevealAnimation(v.findViewById(R.id.rootLayout), (int) v.getX(), (int) v.getY(), v.getWidth(), v.getHeight());
|
||||||
startActivity(i, options.toBundle());
|
startActivity(i, options.toBundle());
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
public void success(final User user) {
|
public void success(final User user) {
|
||||||
preferenceManager.setUserInfo(user);
|
preferenceManager.setUserInfo(user);
|
||||||
for (Role role : roles) {
|
for (Role role : roles) {
|
||||||
if (role.getId().equals(user.role_id)) {
|
if (role.getId().equals(user.getRole_id())) {
|
||||||
if (!role.getPermAdmin()) {
|
if (!role.getPermAdmin()) {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
Snackbar.make(constraintLayout, "No admin is associated with this authkey.", Snackbar.LENGTH_LONG).show();
|
Snackbar.make(constraintLayout, "No admin is associated with this authkey.", Snackbar.LENGTH_LONG).show();
|
||||||
|
@ -142,7 +142,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mispRestClient.getOrganisation(user.org_id, new MispRestClient.OrganisationCallback() {
|
mispRestClient.getOrganisation(user.getRole_id(), new MispRestClient.OrganisationCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void success(Organisation organisation) {
|
public void success(Organisation organisation) {
|
||||||
preferenceManager.setUserOrgInfo(organisation);
|
preferenceManager.setUserOrgInfo(organisation);
|
||||||
|
|
|
@ -8,17 +8,24 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
|
||||||
import lu.circl.mispbump.R;
|
import lu.circl.mispbump.R;
|
||||||
|
import lu.circl.mispbump.auxiliary.PreferenceManager;
|
||||||
|
|
||||||
|
|
||||||
public class PreferenceActivity extends AppCompatActivity {
|
public class PreferenceActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private PreferenceManager preferenceManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_preference);
|
setContentView(R.layout.activity_preference);
|
||||||
|
|
||||||
|
preferenceManager = PreferenceManager.getInstance(PreferenceActivity.this);
|
||||||
|
|
||||||
initializeViews();
|
initializeViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,15 +39,27 @@ public class PreferenceActivity extends AppCompatActivity {
|
||||||
|
|
||||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||||
fragmentTransaction.add(R.id.fragmentContainer, new PreferencesFragment(), PreferencesFragment.class.getSimpleName());
|
PreferencesFragment preferencesFragment = new PreferencesFragment();
|
||||||
|
preferencesFragment.onDeleteAllSyncsListener = preference -> {
|
||||||
|
preferenceManager.clearUploadInformation();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
fragmentTransaction.add(R.id.fragmentContainer, preferencesFragment, PreferencesFragment.class.getSimpleName());
|
||||||
fragmentTransaction.commit();
|
fragmentTransaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PreferencesFragment extends PreferenceFragmentCompat {
|
public static class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
|
|
||||||
|
Preference.OnPreferenceClickListener onDeleteAllSyncsListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
setPreferencesFromResource(R.xml.preference_screen_main, rootKey);
|
setPreferencesFromResource(R.xml.preference_screen_main, rootKey);
|
||||||
findPreference("PREF_DELETE_ALL_SYNCS").setOnPreferenceClickListener(preference -> true);
|
|
||||||
|
Preference deleteAllSyncInfo = findPreference("PREF_DELETE_ALL_SYNCS");
|
||||||
|
assert deleteAllSyncInfo != null;
|
||||||
|
deleteAllSyncInfo.setOnPreferenceClickListener(onDeleteAllSyncsListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class ProfileActivity extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
public void success(final User user) {
|
public void success(final User user) {
|
||||||
preferenceManager.setUserInfo(user);
|
preferenceManager.setUserInfo(user);
|
||||||
mispRestClient.getOrganisation(user.org_id, new MispRestClient.OrganisationCallback() {
|
mispRestClient.getOrganisation(user.getRole_id(), new MispRestClient.OrganisationCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void success(Organisation organisation) {
|
public void success(Organisation organisation) {
|
||||||
fabLoadingDrawable.stop();
|
fabLoadingDrawable.stop();
|
||||||
|
|
|
@ -216,26 +216,26 @@ public class UploadActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private User generateSyncUser(Organisation organisation) {
|
private User generateSyncUser(Organisation organisation) {
|
||||||
User syncUser = new User();
|
User syncUser = new User();
|
||||||
syncUser.org_id = organisation.getId();
|
syncUser.setOrg_id(organisation.getId());
|
||||||
syncUser.role_id = User.ROLE_SYNC_USER;
|
// syncUser.role_id = User.ROLE_SYNC_USER;
|
||||||
syncUser.email = uploadInformation.getRemote().syncUserEmail;
|
syncUser.setEmail(uploadInformation.getRemote().syncUserEmail);
|
||||||
syncUser.password = uploadInformation.getRemote().syncUserPassword;
|
syncUser.setPassword(uploadInformation.getRemote().syncUserPassword);
|
||||||
syncUser.authkey = uploadInformation.getRemote().syncUserAuthkey;
|
syncUser.setAuthkey(uploadInformation.getRemote().syncUserAuthkey);
|
||||||
syncUser.termsaccepted = true;
|
syncUser.setTermsaccepted(true);
|
||||||
|
|
||||||
return syncUser;
|
return syncUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Server generateSyncServer() {
|
private Server generateSyncServer() {
|
||||||
Server server = new Server();
|
Server server = new Server();
|
||||||
server.name = uploadInformation.getRemote().organisation.getName() + "'s Sync Server";
|
server.setName(uploadInformation.getRemote().organisation.getName() + "'s Sync Server");
|
||||||
server.url = uploadInformation.getRemote().baseUrl;
|
server.setUrl(uploadInformation.getRemote().baseUrl);
|
||||||
server.remote_org_id = uploadInformation.getRemote().organisation.getId();
|
server.setRemote_org_id(uploadInformation.getRemote().organisation.getId());
|
||||||
server.authkey = uploadInformation.getLocal().syncUserAuthkey;
|
server.setAuthkey(uploadInformation.getLocal().syncUserAuthkey);
|
||||||
server.pull = uploadInformation.isPull();
|
server.setPull(uploadInformation.isPull());
|
||||||
server.push = uploadInformation.isPush();
|
server.setPush(uploadInformation.isPush());
|
||||||
server.caching_enabled = uploadInformation.isCached();
|
server.setCaching_enabled(uploadInformation.isCached());
|
||||||
server.self_signed = uploadInformation.isAllowSelfSigned();
|
server.setSelf_signed(uploadInformation.isAllowSelfSigned());
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,9 +302,9 @@ public class UploadActivity extends AppCompatActivity {
|
||||||
Server serverToUpload = generateSyncServer();
|
Server serverToUpload = generateSyncServer();
|
||||||
|
|
||||||
for (Server server : servers) {
|
for (Server server : servers) {
|
||||||
if (server.remote_org_id.equals(serverToUpload.remote_org_id)) {
|
if (server.getRemote_org_id().equals(serverToUpload.getRemote_org_id())) {
|
||||||
// server already exists: override id to update instead
|
// server already exists: override id to update instead
|
||||||
serverToUpload.id = server.id;
|
serverToUpload.setId(server.getId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ public class UploadInfoAdapter extends RecyclerView.Adapter<UploadInfoAdapter.Vi
|
||||||
private Context context;
|
private Context context;
|
||||||
private List<UploadInformation> items;
|
private List<UploadInformation> items;
|
||||||
|
|
||||||
private OnRecyclerItemClickListener<UploadInformation> onRecyclerItemClickListener;
|
|
||||||
private OnRecyclerItemClickListener<Integer> onRecyclerPositionClickListener;
|
private OnRecyclerItemClickListener<Integer> onRecyclerPositionClickListener;
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,19 +63,7 @@ public class UploadInfoAdapter extends RecyclerView.Adapter<UploadInfoAdapter.Vi
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.rootView.setOnClickListener(new View.OnClickListener() {
|
holder.rootView.setOnClickListener(view -> onRecyclerPositionClickListener.onClick(view, position));
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
onRecyclerItemClickListener.onClick(view, item);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
holder.rootView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
onRecyclerPositionClickListener.onClick(view, position);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,18 +77,10 @@ public class UploadInfoAdapter extends RecyclerView.Adapter<UploadInfoAdapter.Vi
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// callbacks
|
|
||||||
|
|
||||||
public void setOnRecyclerItemClickListener(OnRecyclerItemClickListener<UploadInformation> onRecyclerItemClickListener) {
|
|
||||||
this.onRecyclerItemClickListener = onRecyclerItemClickListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOnRecyclerPositionClickListener(OnRecyclerItemClickListener<Integer> onRecyclerPositionClickListener) {
|
public void setOnRecyclerPositionClickListener(OnRecyclerItemClickListener<Integer> onRecyclerPositionClickListener) {
|
||||||
this.onRecyclerPositionClickListener = onRecyclerPositionClickListener;
|
this.onRecyclerPositionClickListener = onRecyclerPositionClickListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
// viewHolder
|
|
||||||
|
|
||||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
View rootView;
|
View rootView;
|
||||||
|
|
|
@ -274,7 +274,7 @@ public class MispRestClient {
|
||||||
@Override
|
@Override
|
||||||
public void success(User[] users) {
|
public void success(User[] users) {
|
||||||
for (User user : users) {
|
for (User user : users) {
|
||||||
if (user.email.equals(emailAddress)) {
|
if (user.getEmail().equals(emailAddress)) {
|
||||||
callback.success(user);
|
callback.success(user);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -474,16 +474,14 @@ public class MispRestClient {
|
||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
callback.failure(extractError(response));
|
callback.failure(extractError(response));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
List<MispServer> mispServers = response.body();
|
List<MispServer> mispServers = response.body();
|
||||||
assert mispServers != null;
|
assert mispServers != null;
|
||||||
|
|
||||||
Server[] servers = new Server[mispServers.size()];
|
Server[] servers = new Server[mispServers.size()];
|
||||||
|
|
||||||
for (int i = 0; i < servers.length; i++) {
|
for (int i = 0; i < servers.length; i++) {
|
||||||
servers[i] = mispServers.get(i).server;
|
servers[i] = mispServers.get(i).getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.success(servers);
|
callback.success(servers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,6 +493,26 @@ public class MispRestClient {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getAllServers(final AllRawServersCallback callback) {
|
||||||
|
Call<List<MispServer>> call = mispRestInterface.getAllServers();
|
||||||
|
|
||||||
|
call.enqueue(new Callback<List<MispServer>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<List<MispServer>> call, @NonNull Response<List<MispServer>> response) {
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
callback.failure(extractError(response));
|
||||||
|
} else {
|
||||||
|
callback.success(response.body());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<List<MispServer>> call, @NonNull Throwable t) {
|
||||||
|
callback.failure(t.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a server to the MISP instance
|
* Add a server to the MISP instance
|
||||||
*
|
*
|
||||||
|
@ -631,6 +649,12 @@ public class MispRestClient {
|
||||||
void failure(String error);
|
void failure(String error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface AllRawServersCallback {
|
||||||
|
void success(List<MispServer> mispServers);
|
||||||
|
|
||||||
|
void failure(String error);
|
||||||
|
}
|
||||||
|
|
||||||
public interface AllRolesCallback {
|
public interface AllRolesCallback {
|
||||||
void success(Role[] roles);
|
void success(Role[] roles);
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package lu.circl.mispbump.models;
|
package lu.circl.mispbump.models;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import lu.circl.mispbump.models.restModels.Organisation;
|
import lu.circl.mispbump.models.restModels.Organisation;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Class that holds the information needed synchronize two misp instances.
|
* A Class that holds the information needed synchronize two misp instances.
|
||||||
* This class can be serialized and passed via QR code.
|
|
||||||
*/
|
*/
|
||||||
public class SyncInformation {
|
public class SyncInformation {
|
||||||
|
|
||||||
|
@ -16,9 +17,7 @@ public class SyncInformation {
|
||||||
public String syncUserAuthkey;
|
public String syncUserAuthkey;
|
||||||
public String baseUrl;
|
public String baseUrl;
|
||||||
|
|
||||||
public SyncInformation() {
|
@NonNull
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SyncInformation{" +
|
return "SyncInformation{" +
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
package lu.circl.mispbump.models;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import lu.circl.mispbump.auxiliary.MispRestClient;
|
||||||
|
import lu.circl.mispbump.models.restModels.Organisation;
|
||||||
|
import lu.circl.mispbump.models.restModels.Server;
|
||||||
|
|
||||||
|
|
||||||
|
public class SyncModel {
|
||||||
|
|
||||||
|
private UUID uuid;
|
||||||
|
|
||||||
|
private Server server;
|
||||||
|
private Organisation organisation;
|
||||||
|
private Organisation remoteOrganisation;
|
||||||
|
|
||||||
|
|
||||||
|
public Server getServer() {
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServer(Server server) {
|
||||||
|
this.server = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Organisation getOrganisation() {
|
||||||
|
return organisation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrganisation(Organisation organisation) {
|
||||||
|
this.organisation = organisation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Organisation getRemoteOrganisation() {
|
||||||
|
return remoteOrganisation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemoteOrganisation(Organisation remoteOrganisation) {
|
||||||
|
this.remoteOrganisation = remoteOrganisation;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void createFromServer(MispRestClient mispRestClient, Server server, InitializeWithServerObject callback) {
|
||||||
|
SyncModel syncModel = new SyncModel();
|
||||||
|
|
||||||
|
syncModel.server = server;
|
||||||
|
|
||||||
|
mispRestClient.getOrganisation(server.getOrg_id(), new MispRestClient.OrganisationCallback() {
|
||||||
|
@Override
|
||||||
|
public void success(Organisation organisation) {
|
||||||
|
syncModel.organisation = organisation;
|
||||||
|
|
||||||
|
mispRestClient.getOrganisation(server.getRemote_org_id(), new MispRestClient.OrganisationCallback() {
|
||||||
|
@Override
|
||||||
|
public void success(Organisation organisation) {
|
||||||
|
syncModel.remoteOrganisation = organisation;
|
||||||
|
|
||||||
|
callback.success(syncModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failure(String error) {
|
||||||
|
callback.failure(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failure(String error) {
|
||||||
|
callback.failure(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return server.toString() + "\n" + organisation.toString() + "\n" + remoteOrganisation.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface InitializeWithServerObject {
|
||||||
|
void success(SyncModel syncModel);
|
||||||
|
|
||||||
|
void failure(String error);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
package lu.circl.mispbump.models.restModels;
|
package lu.circl.mispbump.models.restModels;
|
||||||
|
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -9,26 +10,50 @@ import java.util.List;
|
||||||
|
|
||||||
public class MispServer {
|
public class MispServer {
|
||||||
|
|
||||||
public MispServer() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public MispServer(Server server, Organisation organisation, Organisation remoteOrganisation) {
|
|
||||||
this.server = server;
|
|
||||||
this.organisation = organisation;
|
|
||||||
this.remoteOrg = remoteOrganisation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SerializedName("Server")
|
@SerializedName("Server")
|
||||||
@Expose
|
private Server server;
|
||||||
public Server server;
|
|
||||||
@SerializedName("Organisation")
|
|
||||||
@Expose
|
|
||||||
public Organisation organisation;
|
|
||||||
@SerializedName("RemoteOrg")
|
|
||||||
@Expose
|
|
||||||
public Organisation remoteOrg;
|
|
||||||
@SerializedName("User")
|
|
||||||
@Expose
|
|
||||||
public List<User> user;
|
|
||||||
|
|
||||||
|
@SerializedName("Organisation")
|
||||||
|
private Organisation organisation;
|
||||||
|
|
||||||
|
@SerializedName("RemoteOrg")
|
||||||
|
private Organisation remoteOrganisation;
|
||||||
|
|
||||||
|
@SerializedName("User")
|
||||||
|
private List<User> user;
|
||||||
|
|
||||||
|
|
||||||
|
public Server getServer() {
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
public void setServer(Server server) {
|
||||||
|
this.server = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Organisation getOrganisation() {
|
||||||
|
return organisation;
|
||||||
|
}
|
||||||
|
public void setOrganisation(Organisation organisation) {
|
||||||
|
this.organisation = organisation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Organisation getRemoteOrganisation() {
|
||||||
|
return remoteOrganisation;
|
||||||
|
}
|
||||||
|
public void setRemoteOrganisation(Organisation remoteOrganisation) {
|
||||||
|
this.remoteOrganisation = remoteOrganisation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<User> getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
public void setUser(List<User> user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return server.toString() + "\n" + organisation.toString() + "\n" + remoteOrganisation.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package lu.circl.mispbump.models.restModels;
|
package lu.circl.mispbump.models.restModels;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information gathered from Misp API about a organisation.
|
* Information gathered from Misp API about a organisation.
|
||||||
*/
|
*/
|
||||||
|
@ -17,25 +20,16 @@ public class Organisation {
|
||||||
private String description;
|
private String description;
|
||||||
private Boolean local;
|
private Boolean local;
|
||||||
private String uuid;
|
private String uuid;
|
||||||
private String[] restricted_to_domain;
|
// private String[] restricted_to_domain;
|
||||||
private String created_by;
|
private String created_by;
|
||||||
private Integer user_count;
|
private Integer user_count;
|
||||||
|
|
||||||
public Organisation() {
|
public Organisation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Organisation(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Organisation(String name, String description) {
|
|
||||||
this.name = name;
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Organisation toSyncOrganisation() {
|
public Organisation toSyncOrganisation() {
|
||||||
Organisation organisation = new Organisation();
|
Organisation organisation = new Organisation();
|
||||||
organisation.local = true;
|
organisation.local = true; // TODO REMOVE FROME HERE!
|
||||||
organisation.name = name;
|
organisation.name = name;
|
||||||
organisation.uuid = uuid;
|
organisation.uuid = uuid;
|
||||||
organisation.description = description;
|
organisation.description = description;
|
||||||
|
@ -136,13 +130,13 @@ public class Organisation {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getRestricted_to_domain() {
|
// public String[] getRestricted_to_domain() {
|
||||||
return restricted_to_domain;
|
// return restricted_to_domain;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void setRestricted_to_domain(String[] restricted_to_domain) {
|
// public void setRestricted_to_domain(String[] restricted_to_domain) {
|
||||||
this.restricted_to_domain = restricted_to_domain;
|
// this.restricted_to_domain = restricted_to_domain;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public String getCreated_by() {
|
public String getCreated_by() {
|
||||||
return created_by;
|
return created_by;
|
||||||
|
@ -160,6 +154,7 @@ public class Organisation {
|
||||||
this.user_count = user_count;
|
this.user_count = user_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Organisation{" +
|
return "Organisation{" +
|
||||||
|
@ -174,7 +169,7 @@ public class Organisation {
|
||||||
", description='" + description + '\'' +
|
", description='" + description + '\'' +
|
||||||
", local=" + local +
|
", local=" + local +
|
||||||
", uuid='" + uuid + '\'' +
|
", uuid='" + uuid + '\'' +
|
||||||
", restricted_to_domain='" + restricted_to_domain + '\'' +
|
// ", restricted_to_domain='" + Arrays.toString(restricted_to_domain) + '\'' +
|
||||||
", created_by='" + created_by + '\'' +
|
", created_by='" + created_by + '\'' +
|
||||||
", user_count=" + user_count +
|
", user_count=" + user_count +
|
||||||
'}';
|
'}';
|
||||||
|
|
|
@ -1,87 +1,212 @@
|
||||||
package lu.circl.mispbump.models.restModels;
|
package lu.circl.mispbump.models.restModels;
|
||||||
|
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
|
||||||
public class Server {
|
public class Server {
|
||||||
|
|
||||||
public Server() {
|
private Integer id;
|
||||||
|
private String name;
|
||||||
|
private String url;
|
||||||
|
private String authkey;
|
||||||
|
private Integer org_id;
|
||||||
|
private Boolean push;
|
||||||
|
private Boolean pull;
|
||||||
|
private Object lastpulledid;
|
||||||
|
private Object lastpushedid;
|
||||||
|
private Object organization;
|
||||||
|
private Integer remote_org_id;
|
||||||
|
private Boolean publish_without_email;
|
||||||
|
private Boolean unpublish_event;
|
||||||
|
private Boolean self_signed;
|
||||||
|
private String pull_rules;
|
||||||
|
private String push_rules;
|
||||||
|
private Object cert_file;
|
||||||
|
private Object client_cert_file;
|
||||||
|
private Boolean internal;
|
||||||
|
private Boolean skip_proxy;
|
||||||
|
private Boolean caching_enabled;
|
||||||
|
private Boolean cache_timestamp;
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Server(String name, String url, String authkey, Integer remote_org_id) {
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthkey() {
|
||||||
|
return authkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthkey(String authkey) {
|
||||||
this.authkey = authkey;
|
this.authkey = authkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOrg_id() {
|
||||||
|
return org_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrg_id(Integer org_id) {
|
||||||
|
this.org_id = org_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getPush() {
|
||||||
|
return push;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPush(Boolean push) {
|
||||||
|
this.push = push;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getPull() {
|
||||||
|
return pull;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPull(Boolean pull) {
|
||||||
|
this.pull = pull;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getLastpulledid() {
|
||||||
|
return lastpulledid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastpulledid(Object lastpulledid) {
|
||||||
|
this.lastpulledid = lastpulledid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getLastpushedid() {
|
||||||
|
return lastpushedid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastpushedid(Object lastpushedid) {
|
||||||
|
this.lastpushedid = lastpushedid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getOrganization() {
|
||||||
|
return organization;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrganization(Object organization) {
|
||||||
|
this.organization = organization;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRemote_org_id() {
|
||||||
|
return remote_org_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemote_org_id(Integer remote_org_id) {
|
||||||
this.remote_org_id = remote_org_id;
|
this.remote_org_id = remote_org_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SerializedName("id")
|
public Boolean getPublish_without_email() {
|
||||||
public Integer id;
|
return publish_without_email;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("name")
|
public void setPublish_without_email(Boolean publish_without_email) {
|
||||||
public String name;
|
this.publish_without_email = publish_without_email;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("url")
|
public Boolean getUnpublish_event() {
|
||||||
public String url;
|
return unpublish_event;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("authkey")
|
public void setUnpublish_event(Boolean unpublish_event) {
|
||||||
public String authkey;
|
this.unpublish_event = unpublish_event;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("org_id")
|
public Boolean getSelf_signed() {
|
||||||
public Integer org_id;
|
return self_signed;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("push")
|
public void setSelf_signed(Boolean self_signed) {
|
||||||
public Boolean push;
|
this.self_signed = self_signed;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("pull")
|
public String getPull_rules() {
|
||||||
public Boolean pull;
|
return pull_rules;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("lastpulledid")
|
public void setPull_rules(String pull_rules) {
|
||||||
public Object lastpulledid;
|
this.pull_rules = pull_rules;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("lastpushedid")
|
public String getPush_rules() {
|
||||||
public Object lastpushedid;
|
return push_rules;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("organization")
|
public void setPush_rules(String push_rules) {
|
||||||
public Object organization;
|
this.push_rules = push_rules;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("remote_org_id")
|
public Object getCert_file() {
|
||||||
public Integer remote_org_id;
|
return cert_file;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("publish_without_email")
|
public void setCert_file(Object cert_file) {
|
||||||
public Boolean publish_without_email = false;
|
this.cert_file = cert_file;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("unpublish_event")
|
public Object getClient_cert_file() {
|
||||||
public Boolean unpublish_event;
|
return client_cert_file;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("self_signed")
|
public void setClient_cert_file(Object client_cert_file) {
|
||||||
public Boolean self_signed = false;
|
this.client_cert_file = client_cert_file;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("pull_rules")
|
public Boolean getInternal() {
|
||||||
public String pull_rules;
|
return internal;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("push_rules")
|
public void setInternal(Boolean internal) {
|
||||||
public String push_rules;
|
this.internal = internal;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("cert_file")
|
public Boolean getSkip_proxy() {
|
||||||
public Object cert_file;
|
return skip_proxy;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("client_cert_file")
|
public void setSkip_proxy(Boolean skip_proxy) {
|
||||||
public Object client_cert_file;
|
this.skip_proxy = skip_proxy;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("internal")
|
public Boolean getCaching_enabled() {
|
||||||
public Boolean internal;
|
return caching_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("skip_proxy")
|
public void setCaching_enabled(Boolean caching_enabled) {
|
||||||
public Boolean skip_proxy = false;
|
this.caching_enabled = caching_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("caching_enabled")
|
public Boolean getCache_timestamp() {
|
||||||
public Boolean caching_enabled;
|
return cache_timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("cache_timestamp")
|
public void setCache_timestamp(Boolean cache_timestamp) {
|
||||||
public Boolean cache_timestamp;
|
this.cache_timestamp = cache_timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Server{" +
|
return "Server{" +
|
||||||
|
|
|
@ -1,102 +1,213 @@
|
||||||
package lu.circl.mispbump.models.restModels;
|
package lu.circl.mispbump.models.restModels;
|
||||||
|
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
import androidx.annotation.NonNull;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
|
|
||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
public static final int ROLE_ADMIN = 1;
|
private Integer id;
|
||||||
public static final int ROLE_ORG_ADMIN = 2;
|
private String password;
|
||||||
public static final int ROLE_USER = 3;
|
private Integer org_id;
|
||||||
public static final int ROLE_PUBLISHER = 4;
|
private String email;
|
||||||
public static final int ROLE_SYNC_USER = 5;
|
private Boolean autoalert;
|
||||||
public static final int ROLE_READ_ONLY = 6;
|
private String authkey;
|
||||||
|
private String invited_by;
|
||||||
|
private Object gpgkey;
|
||||||
|
private String certif_public;
|
||||||
|
private String nids_sid;
|
||||||
|
private Boolean termsaccepted;
|
||||||
|
private String newsread;
|
||||||
|
private Integer role_id;
|
||||||
|
private String change_pw;
|
||||||
|
private Boolean contactalert;
|
||||||
|
private Boolean disabled;
|
||||||
|
private Object expiration;
|
||||||
|
private String current_login;
|
||||||
|
private String last_login;
|
||||||
|
private Boolean force_logout;
|
||||||
|
private Object date_created;
|
||||||
|
private String date_modified;
|
||||||
|
|
||||||
public User() {
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User(Integer org_id, String email, Integer role_id) {
|
public void setId(Integer id) {
|
||||||
this.org_id = org_id;
|
this.id = id;
|
||||||
this.email = email;
|
|
||||||
this.role_id = role_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public User(Integer org_id, String email, Integer role_id, String password) {
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOrg_id() {
|
||||||
|
return org_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrg_id(Integer org_id) {
|
||||||
this.org_id = org_id;
|
this.org_id = org_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
this.email = email;
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getAutoalert() {
|
||||||
|
return autoalert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAutoalert(Boolean autoalert) {
|
||||||
|
this.autoalert = autoalert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthkey() {
|
||||||
|
return authkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthkey(String authkey) {
|
||||||
|
this.authkey = authkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInvited_by() {
|
||||||
|
return invited_by;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvited_by(String invited_by) {
|
||||||
|
this.invited_by = invited_by;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getGpgkey() {
|
||||||
|
return gpgkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGpgkey(Object gpgkey) {
|
||||||
|
this.gpgkey = gpgkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCertif_public() {
|
||||||
|
return certif_public;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCertif_public(String certif_public) {
|
||||||
|
this.certif_public = certif_public;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNids_sid() {
|
||||||
|
return nids_sid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNids_sid(String nids_sid) {
|
||||||
|
this.nids_sid = nids_sid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getTermsaccepted() {
|
||||||
|
return termsaccepted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTermsaccepted(Boolean termsaccepted) {
|
||||||
|
this.termsaccepted = termsaccepted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNewsread() {
|
||||||
|
return newsread;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNewsread(String newsread) {
|
||||||
|
this.newsread = newsread;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRole_id() {
|
||||||
|
return role_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRole_id(Integer role_id) {
|
||||||
this.role_id = role_id;
|
this.role_id = role_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SerializedName("id")
|
public String getChange_pw() {
|
||||||
@Expose
|
return change_pw;
|
||||||
public Integer id;
|
}
|
||||||
@SerializedName("password")
|
|
||||||
@Expose
|
|
||||||
public String password;
|
|
||||||
@SerializedName("org_id")
|
|
||||||
@Expose
|
|
||||||
public Integer org_id;
|
|
||||||
@SerializedName("email")
|
|
||||||
@Expose
|
|
||||||
public String email;
|
|
||||||
@SerializedName("autoalert")
|
|
||||||
@Expose
|
|
||||||
public Boolean autoalert;
|
|
||||||
@SerializedName("authkey")
|
|
||||||
@Expose
|
|
||||||
public String authkey;
|
|
||||||
@SerializedName("invited_by")
|
|
||||||
@Expose
|
|
||||||
public String invited_by;
|
|
||||||
@SerializedName("gpgkey")
|
|
||||||
@Expose
|
|
||||||
public Object gpgkey;
|
|
||||||
@SerializedName("certif_public")
|
|
||||||
@Expose
|
|
||||||
public String certif_public;
|
|
||||||
@SerializedName("nids_sid")
|
|
||||||
@Expose
|
|
||||||
public String nids_sid;
|
|
||||||
@SerializedName("termsaccepted")
|
|
||||||
@Expose
|
|
||||||
public Boolean termsaccepted;
|
|
||||||
@SerializedName("newsread")
|
|
||||||
@Expose
|
|
||||||
public String newsread;
|
|
||||||
@SerializedName("role_id")
|
|
||||||
@Expose
|
|
||||||
public Integer role_id;
|
|
||||||
@SerializedName("change_pw")
|
|
||||||
@Expose
|
|
||||||
public String change_pw;
|
|
||||||
@SerializedName("contactalert")
|
|
||||||
@Expose
|
|
||||||
public Boolean contactalert;
|
|
||||||
@SerializedName("disabled")
|
|
||||||
@Expose
|
|
||||||
public Boolean disabled;
|
|
||||||
@SerializedName("expiration")
|
|
||||||
@Expose
|
|
||||||
public Object expiration;
|
|
||||||
@SerializedName("current_login")
|
|
||||||
@Expose
|
|
||||||
public String current_login;
|
|
||||||
@SerializedName("last_login")
|
|
||||||
@Expose
|
|
||||||
public String last_login;
|
|
||||||
@SerializedName("force_logout")
|
|
||||||
@Expose
|
|
||||||
public Boolean force_logout;
|
|
||||||
@SerializedName("date_created")
|
|
||||||
@Expose
|
|
||||||
public Object date_created;
|
|
||||||
@SerializedName("date_modified")
|
|
||||||
@Expose
|
|
||||||
public String date_modified;
|
|
||||||
|
|
||||||
|
public void setChange_pw(String change_pw) {
|
||||||
|
this.change_pw = change_pw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getContactalert() {
|
||||||
|
return contactalert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContactalert(Boolean contactalert) {
|
||||||
|
this.contactalert = contactalert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getDisabled() {
|
||||||
|
return disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisabled(Boolean disabled) {
|
||||||
|
this.disabled = disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getExpiration() {
|
||||||
|
return expiration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpiration(Object expiration) {
|
||||||
|
this.expiration = expiration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCurrent_login() {
|
||||||
|
return current_login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrent_login(String current_login) {
|
||||||
|
this.current_login = current_login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLast_login() {
|
||||||
|
return last_login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLast_login(String last_login) {
|
||||||
|
this.last_login = last_login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getForce_logout() {
|
||||||
|
return force_logout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setForce_logout(Boolean force_logout) {
|
||||||
|
this.force_logout = force_logout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getDate_created() {
|
||||||
|
return date_created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate_created(Object date_created) {
|
||||||
|
this.date_created = date_created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDate_modified() {
|
||||||
|
return date_modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate_modified(String date_modified) {
|
||||||
|
this.date_modified = date_modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "User{" +
|
return "User{" +
|
||||||
|
|
Loading…
Reference in New Issue