prepare model change

pull/4/head
Felix Prahl-Kamps 2019-07-24 20:32:13 +02:00
parent 9fbef90f91
commit 4a9d428266
14 changed files with 744 additions and 369 deletions

View File

@ -121,27 +121,22 @@ public class ExchangeActivity extends AppCompatActivity {
syncInformation.syncUserAuthkey = new RandomString(40).nextString();
syncInformation.baseUrl = preferenceManager.getUserCredentials().first;
syncInformation.syncUserPassword = new RandomString(16).nextString();
syncInformation.syncUserEmail = preferenceManager.getUserInfo().email;
syncInformation.syncUserEmail = preferenceManager.getUserInfo().getEmail();
return syncInformation;
}
private void showQrCode(final Bitmap bitmap) {
runOnUiThread(new Runnable() {
@Override
public void run() {
runOnUiThread(() -> {
qrCode.setImageBitmap(bitmap);
qrFrame.setVisibility(View.VISIBLE);
}
});
}
private void setSyncState(SyncState state) {
currentSyncState = state;
runOnUiThread(new Runnable() {
@Override
public void run() {
runOnUiThread(() -> {
switch (currentSyncState) {
case KEY_EXCHANGE:
prevButton.setImageDrawable(getDrawable(R.drawable.ic_close));
@ -194,7 +189,6 @@ public class ExchangeActivity extends AppCompatActivity {
qrContentInfo.setText(R.string.public_key);
break;
}
}
});
}
@ -261,9 +255,7 @@ public class ExchangeActivity extends AppCompatActivity {
private CameraFragment.QrScanCallback onQrScanned() {
return new CameraFragment.QrScanCallback() {
@Override
public void qrScanResult(String qrData) {
return qrData -> {
cameraFragment.setReadQrEnabled(false);
switch (currentSyncState) {
@ -322,14 +314,11 @@ public class ExchangeActivity extends AppCompatActivity {
}
break;
}
}
};
}
private View.OnClickListener onPrevClicked() {
return new View.OnClickListener() {
@Override
public void onClick(View v) {
return v -> {
switch (currentSyncState) {
case KEY_EXCHANGE:
case KEY_EXCHANGE_DONE:
@ -341,14 +330,11 @@ public class ExchangeActivity extends AppCompatActivity {
setSyncState(SyncState.KEY_EXCHANGE_DONE);
break;
}
}
};
}
private View.OnClickListener onNextClicked() {
return new View.OnClickListener() {
@Override
public void onClick(View v) {
return v -> {
switch (currentSyncState) {
case KEY_EXCHANGE_DONE:
setSyncState(SyncState.DATA_EXCHANGE);
@ -362,7 +348,6 @@ public class ExchangeActivity extends AppCompatActivity {
finish();
break;
}
}
};
}

View File

@ -3,6 +3,7 @@ package lu.circl.mispbump.activities;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -11,6 +12,7 @@ import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.util.Pair;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -20,9 +22,12 @@ import java.util.List;
import lu.circl.mispbump.R;
import lu.circl.mispbump.adapters.UploadInfoAdapter;
import lu.circl.mispbump.auxiliary.MispRestClient;
import lu.circl.mispbump.auxiliary.PreferenceManager;
import lu.circl.mispbump.interfaces.OnRecyclerItemClickListener;
import lu.circl.mispbump.models.SyncModel;
import lu.circl.mispbump.models.UploadInformation;
import lu.circl.mispbump.models.restModels.Server;
public class HomeActivity extends AppCompatActivity {
@ -62,7 +67,6 @@ public class HomeActivity extends AppCompatActivity {
return true;
}
// invoke superclass to handle unrecognized item (eg. homeAsUp)
return super.onOptionsItemSelected(item);
}
@ -80,12 +84,7 @@ public class HomeActivity extends AppCompatActivity {
setSupportActionBar(myToolbar);
FloatingActionButton syncFab = findViewById(R.id.home_fab);
syncFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(HomeActivity.this, ExchangeActivity.class));
}
});
syncFab.setOnClickListener(v -> startActivity(new Intent(HomeActivity.this, ExchangeActivity.class)));
}
private void initRecyclerView() {
@ -97,6 +96,32 @@ public class HomeActivity extends AppCompatActivity {
}
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();
if (uploadInformationList.isEmpty()) {
@ -111,15 +136,12 @@ public class HomeActivity extends AppCompatActivity {
private OnRecyclerItemClickListener<Integer> onRecyclerItemClickListener() {
return new OnRecyclerItemClickListener<Integer>() {
@Override
public void onClick(View v, Integer index) {
return (v, index) -> {
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());
startActivity(i, options.toBundle());
}
};
}
}

View File

@ -133,7 +133,7 @@ public class LoginActivity extends AppCompatActivity {
public void success(final User user) {
preferenceManager.setUserInfo(user);
for (Role role : roles) {
if (role.getId().equals(user.role_id)) {
if (role.getId().equals(user.getRole_id())) {
if (!role.getPermAdmin()) {
progressBar.setVisibility(View.GONE);
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
public void success(Organisation organisation) {
preferenceManager.setUserOrgInfo(organisation);

View File

@ -8,17 +8,24 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import lu.circl.mispbump.R;
import lu.circl.mispbump.auxiliary.PreferenceManager;
public class PreferenceActivity extends AppCompatActivity {
private PreferenceManager preferenceManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_preference);
preferenceManager = PreferenceManager.getInstance(PreferenceActivity.this);
initializeViews();
}
@ -32,15 +39,27 @@ public class PreferenceActivity extends AppCompatActivity {
FragmentManager fragmentManager = getSupportFragmentManager();
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();
}
public static class PreferencesFragment extends PreferenceFragmentCompat {
Preference.OnPreferenceClickListener onDeleteAllSyncsListener;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String 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);
}
}
}

View File

@ -152,7 +152,7 @@ public class ProfileActivity extends AppCompatActivity {
@Override
public void success(final User user) {
preferenceManager.setUserInfo(user);
mispRestClient.getOrganisation(user.org_id, new MispRestClient.OrganisationCallback() {
mispRestClient.getOrganisation(user.getRole_id(), new MispRestClient.OrganisationCallback() {
@Override
public void success(Organisation organisation) {
fabLoadingDrawable.stop();

View File

@ -216,26 +216,26 @@ public class UploadActivity extends AppCompatActivity {
private User generateSyncUser(Organisation organisation) {
User syncUser = new User();
syncUser.org_id = organisation.getId();
syncUser.role_id = User.ROLE_SYNC_USER;
syncUser.email = uploadInformation.getRemote().syncUserEmail;
syncUser.password = uploadInformation.getRemote().syncUserPassword;
syncUser.authkey = uploadInformation.getRemote().syncUserAuthkey;
syncUser.termsaccepted = true;
syncUser.setOrg_id(organisation.getId());
// syncUser.role_id = User.ROLE_SYNC_USER;
syncUser.setEmail(uploadInformation.getRemote().syncUserEmail);
syncUser.setPassword(uploadInformation.getRemote().syncUserPassword);
syncUser.setAuthkey(uploadInformation.getRemote().syncUserAuthkey);
syncUser.setTermsaccepted(true);
return syncUser;
}
private Server generateSyncServer() {
Server server = new Server();
server.name = uploadInformation.getRemote().organisation.getName() + "'s Sync Server";
server.url = uploadInformation.getRemote().baseUrl;
server.remote_org_id = uploadInformation.getRemote().organisation.getId();
server.authkey = uploadInformation.getLocal().syncUserAuthkey;
server.pull = uploadInformation.isPull();
server.push = uploadInformation.isPush();
server.caching_enabled = uploadInformation.isCached();
server.self_signed = uploadInformation.isAllowSelfSigned();
server.setName(uploadInformation.getRemote().organisation.getName() + "'s Sync Server");
server.setUrl(uploadInformation.getRemote().baseUrl);
server.setRemote_org_id(uploadInformation.getRemote().organisation.getId());
server.setAuthkey(uploadInformation.getLocal().syncUserAuthkey);
server.setPull(uploadInformation.isPull());
server.setPush(uploadInformation.isPush());
server.setCaching_enabled(uploadInformation.isCached());
server.setSelf_signed(uploadInformation.isAllowSelfSigned());
return server;
}
@ -302,9 +302,9 @@ public class UploadActivity extends AppCompatActivity {
Server serverToUpload = generateSyncServer();
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
serverToUpload.id = server.id;
serverToUpload.setId(server.getId());
break;
}
}

View File

@ -25,7 +25,6 @@ public class UploadInfoAdapter extends RecyclerView.Adapter<UploadInfoAdapter.Vi
private Context context;
private List<UploadInformation> items;
private OnRecyclerItemClickListener<UploadInformation> onRecyclerItemClickListener;
private OnRecyclerItemClickListener<Integer> onRecyclerPositionClickListener;
@ -64,19 +63,7 @@ public class UploadInfoAdapter extends RecyclerView.Adapter<UploadInfoAdapter.Vi
break;
}
holder.rootView.setOnClickListener(new View.OnClickListener() {
@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);
}
});
holder.rootView.setOnClickListener(view -> onRecyclerPositionClickListener.onClick(view, position));
}
@Override
@ -90,18 +77,10 @@ public class UploadInfoAdapter extends RecyclerView.Adapter<UploadInfoAdapter.Vi
notifyDataSetChanged();
}
// callbacks
public void setOnRecyclerItemClickListener(OnRecyclerItemClickListener<UploadInformation> onRecyclerItemClickListener) {
this.onRecyclerItemClickListener = onRecyclerItemClickListener;
}
public void setOnRecyclerPositionClickListener(OnRecyclerItemClickListener<Integer> onRecyclerPositionClickListener) {
this.onRecyclerPositionClickListener = onRecyclerPositionClickListener;
}
// viewHolder
static class ViewHolder extends RecyclerView.ViewHolder {
View rootView;

View File

@ -274,7 +274,7 @@ public class MispRestClient {
@Override
public void success(User[] users) {
for (User user : users) {
if (user.email.equals(emailAddress)) {
if (user.getEmail().equals(emailAddress)) {
callback.success(user);
return;
}
@ -474,17 +474,35 @@ public class MispRestClient {
if (!response.isSuccessful()) {
callback.failure(extractError(response));
} else {
List<MispServer> mispServers = response.body();
assert mispServers != null;
Server[] servers = new Server[mispServers.size()];
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);
@Override
public void onFailure(@NonNull Call<List<MispServer>> call, @NonNull Throwable t) {
callback.failure(t.getMessage());
}
});
}
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());
}
}
@ -631,6 +649,12 @@ public class MispRestClient {
void failure(String error);
}
public interface AllRawServersCallback {
void success(List<MispServer> mispServers);
void failure(String error);
}
public interface AllRolesCallback {
void success(Role[] roles);

View File

@ -1,12 +1,13 @@
package lu.circl.mispbump.models;
import androidx.annotation.NonNull;
import lu.circl.mispbump.models.restModels.Organisation;
/**
* A Class that holds the information needed synchronize two misp instances.
* This class can be serialized and passed via QR code.
*/
public class SyncInformation {
@ -16,9 +17,7 @@ public class SyncInformation {
public String syncUserAuthkey;
public String baseUrl;
public SyncInformation() {
}
@NonNull
@Override
public String toString() {
return "SyncInformation{" +

View File

@ -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);
}
}

View File

@ -1,7 +1,8 @@
package lu.circl.mispbump.models.restModels;
import com.google.gson.annotations.Expose;
import androidx.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
import java.util.List;
@ -9,26 +10,50 @@ import java.util.List;
public class MispServer {
public MispServer() {
}
public MispServer(Server server, Organisation organisation, Organisation remoteOrganisation) {
this.server = server;
this.organisation = organisation;
this.remoteOrg = remoteOrganisation;
}
@SerializedName("Server")
@Expose
public Server server;
@SerializedName("Organisation")
@Expose
public Organisation organisation;
@SerializedName("RemoteOrg")
@Expose
public Organisation remoteOrg;
@SerializedName("User")
@Expose
public List<User> user;
private Server server;
@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();
}
}

View File

@ -1,6 +1,9 @@
package lu.circl.mispbump.models.restModels;
import androidx.annotation.NonNull;
/**
* Information gathered from Misp API about a organisation.
*/
@ -17,25 +20,16 @@ public class Organisation {
private String description;
private Boolean local;
private String uuid;
private String[] restricted_to_domain;
// private String[] restricted_to_domain;
private String created_by;
private Integer user_count;
public Organisation() {
}
public Organisation(String name) {
this.name = name;
}
public Organisation(String name, String description) {
this.name = name;
this.description = description;
}
public Organisation toSyncOrganisation() {
Organisation organisation = new Organisation();
organisation.local = true;
organisation.local = true; // TODO REMOVE FROME HERE!
organisation.name = name;
organisation.uuid = uuid;
organisation.description = description;
@ -136,13 +130,13 @@ public class Organisation {
this.uuid = uuid;
}
public String[] getRestricted_to_domain() {
return restricted_to_domain;
}
// public String[] getRestricted_to_domain() {
// return restricted_to_domain;
// }
public void setRestricted_to_domain(String[] restricted_to_domain) {
this.restricted_to_domain = restricted_to_domain;
}
// public void setRestricted_to_domain(String[] restricted_to_domain) {
// this.restricted_to_domain = restricted_to_domain;
// }
public String getCreated_by() {
return created_by;
@ -160,6 +154,7 @@ public class Organisation {
this.user_count = user_count;
}
@NonNull
@Override
public String toString() {
return "Organisation{" +
@ -174,7 +169,7 @@ public class Organisation {
", description='" + description + '\'' +
", local=" + local +
", uuid='" + uuid + '\'' +
", restricted_to_domain='" + restricted_to_domain + '\'' +
// ", restricted_to_domain='" + Arrays.toString(restricted_to_domain) + '\'' +
", created_by='" + created_by + '\'' +
", user_count=" + user_count +
'}';

View File

@ -1,87 +1,212 @@
package lu.circl.mispbump.models.restModels;
import com.google.gson.annotations.SerializedName;
import androidx.annotation.NonNull;
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;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getAuthkey() {
return authkey;
}
public void setAuthkey(String 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;
}
@SerializedName("id")
public Integer id;
public Boolean getPublish_without_email() {
return publish_without_email;
}
@SerializedName("name")
public String name;
public void setPublish_without_email(Boolean publish_without_email) {
this.publish_without_email = publish_without_email;
}
@SerializedName("url")
public String url;
public Boolean getUnpublish_event() {
return unpublish_event;
}
@SerializedName("authkey")
public String authkey;
public void setUnpublish_event(Boolean unpublish_event) {
this.unpublish_event = unpublish_event;
}
@SerializedName("org_id")
public Integer org_id;
public Boolean getSelf_signed() {
return self_signed;
}
@SerializedName("push")
public Boolean push;
public void setSelf_signed(Boolean self_signed) {
this.self_signed = self_signed;
}
@SerializedName("pull")
public Boolean pull;
public String getPull_rules() {
return pull_rules;
}
@SerializedName("lastpulledid")
public Object lastpulledid;
public void setPull_rules(String pull_rules) {
this.pull_rules = pull_rules;
}
@SerializedName("lastpushedid")
public Object lastpushedid;
public String getPush_rules() {
return push_rules;
}
@SerializedName("organization")
public Object organization;
public void setPush_rules(String push_rules) {
this.push_rules = push_rules;
}
@SerializedName("remote_org_id")
public Integer remote_org_id;
public Object getCert_file() {
return cert_file;
}
@SerializedName("publish_without_email")
public Boolean publish_without_email = false;
public void setCert_file(Object cert_file) {
this.cert_file = cert_file;
}
@SerializedName("unpublish_event")
public Boolean unpublish_event;
public Object getClient_cert_file() {
return client_cert_file;
}
@SerializedName("self_signed")
public Boolean self_signed = false;
public void setClient_cert_file(Object client_cert_file) {
this.client_cert_file = client_cert_file;
}
@SerializedName("pull_rules")
public String pull_rules;
public Boolean getInternal() {
return internal;
}
@SerializedName("push_rules")
public String push_rules;
public void setInternal(Boolean internal) {
this.internal = internal;
}
@SerializedName("cert_file")
public Object cert_file;
public Boolean getSkip_proxy() {
return skip_proxy;
}
@SerializedName("client_cert_file")
public Object client_cert_file;
public void setSkip_proxy(Boolean skip_proxy) {
this.skip_proxy = skip_proxy;
}
@SerializedName("internal")
public Boolean internal;
public Boolean getCaching_enabled() {
return caching_enabled;
}
@SerializedName("skip_proxy")
public Boolean skip_proxy = false;
public void setCaching_enabled(Boolean caching_enabled) {
this.caching_enabled = caching_enabled;
}
@SerializedName("caching_enabled")
public Boolean caching_enabled;
public Boolean getCache_timestamp() {
return cache_timestamp;
}
@SerializedName("cache_timestamp")
public Boolean cache_timestamp;
public void setCache_timestamp(Boolean cache_timestamp) {
this.cache_timestamp = cache_timestamp;
}
@NonNull
@Override
public String toString() {
return "Server{" +

View File

@ -1,102 +1,213 @@
package lu.circl.mispbump.models.restModels;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import androidx.annotation.NonNull;
public class User {
public static final int ROLE_ADMIN = 1;
public static final int ROLE_ORG_ADMIN = 2;
public static final int ROLE_USER = 3;
public static final int ROLE_PUBLISHER = 4;
public static final int ROLE_SYNC_USER = 5;
public static final int ROLE_READ_ONLY = 6;
private Integer id;
private String password;
private Integer org_id;
private String email;
private Boolean autoalert;
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) {
this.org_id = org_id;
this.email = email;
this.role_id = role_id;
public void setId(Integer id) {
this.id = 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;
}
public Integer getOrg_id() {
return org_id;
}
public void setOrg_id(Integer org_id) {
this.org_id = org_id;
}
public String getEmail() {
return email;
}
public void setEmail(String 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;
}
@SerializedName("id")
@Expose
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 String getChange_pw() {
return change_pw;
}
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
public String toString() {
return "User{" +