fix self signed flag not being pushed correctly to misp instance

development
Felix Prahl-Kamps 2019-10-11 17:41:49 +02:00
parent 6216543b7b
commit 6d5ea12a84
6 changed files with 70 additions and 29 deletions

View File

@ -6,6 +6,7 @@ import android.graphics.Shader;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -122,6 +123,11 @@ public class ProfileActivity extends AppCompatActivity {
MaterialPreferenceText description = findViewById(R.id.description);
description.setSubtitle(organisation.getDescription());
Role[] roles = preferenceManager.getRoles();
for (Role role : roles) {
Log.d("ROLES", role.toString());
}
}

View File

@ -16,7 +16,6 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import java.util.UUID;
@ -36,8 +35,17 @@ public class SyncInfoDetailActivity extends AppCompatActivity {
private SyncInformation syncInformation;
private boolean fabMenuExpanded;
private boolean dataLocallyChanged;
private View.OnClickListener onUploadClicked = v -> {
preferenceManager.addSyncInformation(syncInformation);
Intent upload = new Intent(SyncInfoDetailActivity.this, UploadActivity.class);
upload.putExtra(UploadActivity.EXTRA_SYNC_INFO_UUID, syncInformation.getUuid().toString());
startActivity(upload);
};
private View.OnClickListener onDownloadClicked = v -> {
};
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -59,11 +67,6 @@ public class SyncInfoDetailActivity extends AppCompatActivity {
@Override
protected void onPause() {
super.onPause();
if (dataLocallyChanged) {
syncInformation.setSyncedWithRemote(false);
}
preferenceManager.addSyncInformation(syncInformation);
}
@ -185,6 +188,7 @@ public class SyncInfoDetailActivity extends AppCompatActivity {
menuBackground.setClickable(false);
fab.setImageDrawable(close);
assert close != null;
close.start();
closeAnimation.start();
@ -193,6 +197,7 @@ public class SyncInfoDetailActivity extends AppCompatActivity {
menuBackground.setClickable(true);
fab.setImageDrawable(open);
assert open != null;
open.start();
openAnimation.start();
@ -204,17 +209,8 @@ public class SyncInfoDetailActivity extends AppCompatActivity {
menuBackground.setClickable(false);
fab.setOnClickListener(expandCollapseClick);
fabUpload.setOnClickListener(view -> {
preferenceManager.addSyncInformation(syncInformation);
Intent upload = new Intent(SyncInfoDetailActivity.this, UploadActivity.class);
upload.putExtra(UploadActivity.EXTRA_SYNC_INFO_UUID, syncInformation.getUuid().toString());
startActivity(upload);
});
fabDownload.setOnClickListener(view -> {
// TODO download content from MISP instance
Snackbar.make(view, "Not implemented yet", Snackbar.LENGTH_LONG).show();
});
fabUpload.setOnClickListener(onUploadClicked);
fabDownload.setOnClickListener(onDownloadClicked);
}
private void populateContent() {
@ -239,28 +235,28 @@ public class SyncInfoDetailActivity extends AppCompatActivity {
allowSelfSigned.setChecked(syncInformation.getRemote().getServer().getSelfSigned());
allowSelfSigned.setOnCheckedChangeListener((cb, b) -> {
syncInformation.getRemote().getServer().setSelfSigned(b);
dataLocallyChanged = true;
syncInformation.setHasUnpublishedChanges(true);
});
MaterialPreferenceSwitch allowPush = findViewById(R.id.switch_allow_push);
allowPush.setChecked(syncInformation.getRemote().getServer().getPush());
allowPush.setOnCheckedChangeListener((cb, b) -> {
syncInformation.getRemote().getServer().setPush(b);
dataLocallyChanged = true;
syncInformation.setHasUnpublishedChanges(true);
});
MaterialPreferenceSwitch allowPull = findViewById(R.id.switch_allow_pull);
allowPull.setChecked(syncInformation.getRemote().getServer().getPull());
allowPull.setOnCheckedChangeListener((cb, b) -> {
syncInformation.getRemote().getServer().setPull(b);
dataLocallyChanged = true;
syncInformation.setHasUnpublishedChanges(true);
});
MaterialPreferenceSwitch allowCache = findViewById(R.id.switch_allow_cache);
allowCache.setChecked(syncInformation.getRemote().getServer().getCachingEnabled());
allowCache.setOnCheckedChangeListener((cb, b) -> {
syncInformation.getRemote().getServer().setCachingEnabled(b);
dataLocallyChanged = true;
syncInformation.setHasUnpublishedChanges(true);
});
// credentials

View File

@ -172,7 +172,7 @@ public class UploadActivity extends AppCompatActivity {
server.setPull(syncInformation.getRemote().getServer().getPull());
server.setPush(syncInformation.getRemote().getServer().getPush());
server.setCachingEnabled(syncInformation.getRemote().getServer().getCachingEnabled());
server.setSelfSigned(syncInformation.getRemote().getServer().getCachingEnabled());
server.setSelfSigned(syncInformation.getRemote().getServer().getSelfSigned());
return server;
}
@ -259,6 +259,7 @@ public class UploadActivity extends AppCompatActivity {
private void serverAdded(Server server) {
if (server != null) {
serverAction.done();
syncInformation.setHasUnpublishedChanges(false);
preferenceManager.addSyncInformation(syncInformation);
} else {
serverAction.error("Could not create Sync Server");

View File

@ -53,7 +53,7 @@ public class SyncInfoAdapter extends RecyclerView.Adapter<SyncInfoAdapter.ViewHo
holder.orgName.setText(item.getRemote().getOrganisation().getName());
if (item.isSyncedWithRemote()) {
if (item.getHasUnpublishedChanges()) {
ImageViewCompat.setImageTintList(holder.syncStatus, ColorStateList.valueOf(context.getColor(R.color.status_green)));
holder.syncStatus.setImageResource(R.drawable.ic_check_outline);
} else {

View File

@ -21,7 +21,7 @@ public class SyncInformation {
private ExchangeInformation remote;
private ExchangeInformation local;
private boolean syncedWithRemote;
private boolean hasUnpublishedChanges;
public SyncInformation() {
@ -62,11 +62,11 @@ public class SyncInformation {
return df.format(date);
}
public void setSyncedWithRemote(boolean syncedWithRemote) {
this.syncedWithRemote = syncedWithRemote;
public void setHasUnpublishedChanges(boolean hasUnpublishedChanges) {
this.hasUnpublishedChanges = hasUnpublishedChanges;
}
public boolean isSyncedWithRemote() {
return syncedWithRemote;
public boolean getHasUnpublishedChanges() {
return hasUnpublishedChanges;
}
public ExchangeInformation getRemote() {

View File

@ -1,6 +1,8 @@
package lu.circl.mispbump.models.restModels;
import androidx.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
@ -302,4 +304,40 @@ public class Role {
public void setPermissionDescription(String permissionDescription) {
this.permissionDescription = permissionDescription;
}
@NonNull
@Override
public String toString() {
return "Role{" +
"id=" + id +
", name='" + name + '\'' +
", created='" + created + '\'' +
", modified='" + modified + '\'' +
", permAdd=" + permAdd +
", permModify=" + permModify +
", permModifyOrg=" + permModifyOrg +
", permPublish=" + permPublish +
", permDelegate=" + permDelegate +
", permSync=" + permSync +
", permAdmin=" + permAdmin +
", permAudit=" + permAudit +
", permAuth=" + permAuth +
", permSiteAdmin=" + permSiteAdmin +
", permRegexpAccess=" + permRegexpAccess +
", permTagger=" + permTagger +
", permTemplate=" + permTemplate +
", permSharingGroup=" + permSharingGroup +
", permTagEditor=" + permTagEditor +
", permSighting=" + permSighting +
", permObjectTemplate=" + permObjectTemplate +
", defaultRole=" + defaultRole +
", memoryLimit='" + memoryLimit + '\'' +
", maxExecutionTime='" + maxExecutionTime + '\'' +
", restrictedToSiteAdmin=" + restrictedToSiteAdmin +
", permPublishZmq=" + permPublishZmq +
", permPublishKafka=" + permPublishKafka +
", permission='" + permission + '\'' +
", permissionDescription='" + permissionDescription + '\'' +
'}';
}
}