mirror of https://github.com/MISP/misp-bump
cleanup
parent
3a167bc8ba
commit
b002032374
|
@ -28,10 +28,6 @@ import lu.circl.mispbump.models.restModels.Organisation;
|
||||||
import lu.circl.mispbump.models.restModels.Role;
|
import lu.circl.mispbump.models.restModels.Role;
|
||||||
import lu.circl.mispbump.models.restModels.User;
|
import lu.circl.mispbump.models.restModels.User;
|
||||||
|
|
||||||
/**
|
|
||||||
* This activity is shown when the current device has no misp user and organisation associated with it.
|
|
||||||
* It takes care of downloading all information necessary for a sync with other misp instances.
|
|
||||||
*/
|
|
||||||
public class LoginActivity extends AppCompatActivity {
|
public class LoginActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private PreferenceManager preferenceManager;
|
private PreferenceManager preferenceManager;
|
||||||
|
@ -66,7 +62,6 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// invoke superclass to handle unrecognized item (eg. homeAsUp)
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +69,6 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
private void initializeViews() {
|
private void initializeViews() {
|
||||||
constraintLayout = findViewById(R.id.rootLayout);
|
constraintLayout = findViewById(R.id.rootLayout);
|
||||||
|
|
||||||
// populate Toolbar (Actionbar)
|
|
||||||
Toolbar myToolbar = findViewById(R.id.appbar);
|
Toolbar myToolbar = findViewById(R.id.appbar);
|
||||||
setSupportActionBar(myToolbar);
|
setSupportActionBar(myToolbar);
|
||||||
ActionBar ab = getSupportActionBar();
|
ActionBar ab = getSupportActionBar();
|
||||||
|
@ -84,7 +78,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
Button downloadInfoButton = findViewById(R.id.login_download_button);
|
Button downloadInfoButton = findViewById(R.id.login_download_button);
|
||||||
downloadInfoButton.setOnClickListener(onClickDownload);
|
downloadInfoButton.setOnClickListener(onLogin);
|
||||||
|
|
||||||
serverUrl = findViewById(R.id.login_server_url);
|
serverUrl = findViewById(R.id.login_server_url);
|
||||||
serverAutomationKey = findViewById(R.id.login_automation_key);
|
serverAutomationKey = findViewById(R.id.login_automation_key);
|
||||||
|
@ -92,9 +86,9 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is called when the user clicks on the login button.
|
* Called when the user clicks on the login button.
|
||||||
*/
|
*/
|
||||||
private View.OnClickListener onClickDownload = new View.OnClickListener() {
|
private View.OnClickListener onLogin = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final String url = Objects.requireNonNull(serverUrl.getEditText()).getText().toString();
|
final String url = Objects.requireNonNull(serverUrl.getEditText()).getText().toString();
|
||||||
|
@ -131,18 +125,17 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
mispRestClient.getRoles(new MispRestClient.AllRolesCallback() {
|
mispRestClient.getRoles(new MispRestClient.AllRolesCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void success(final Role[] roles) {
|
public void success(final Role[] roles) {
|
||||||
|
|
||||||
preferenceManager.setRoles(roles);
|
preferenceManager.setRoles(roles);
|
||||||
|
|
||||||
mispRestClient.getMyUser(new MispRestClient.UserCallback() {
|
mispRestClient.getMyUser(new MispRestClient.UserCallback() {
|
||||||
@Override
|
@Override
|
||||||
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.role_id)) {
|
||||||
if (!role.getPermAdmin()) {
|
if (!role.getPermAdmin()) {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
Snackbar.make(constraintLayout, "You have no admin rights", Snackbar.LENGTH_LONG).show();
|
Snackbar.make(constraintLayout, "No admin is associated with this authkey.", Snackbar.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue