diff --git a/app/build.gradle b/app/build.gradle index c1ab0b5..5072aa0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,8 +2,9 @@ apply plugin: 'com.android.application' android { compileSdkVersion 27 + buildToolsVersion "27.0.3" defaultConfig { - applicationId "de.overview.wg.its.misp_authentificator" + applicationId "de.overview.wg.its.mispauth" minSdkVersion 21 targetSdkVersion 27 versionCode 1 @@ -21,7 +22,7 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support.constraint:constraint-layout:1.1.0' + implementation 'com.android.support.constraint:constraint-layout:1.1.1' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' diff --git a/app/src/androidTest/java/de/overview/wg/its/misp_authentificator/ExampleInstrumentedTest.java b/app/src/androidTest/java/de/overview/wg/its/mispauth/ExampleInstrumentedTest.java similarity index 76% rename from app/src/androidTest/java/de/overview/wg/its/misp_authentificator/ExampleInstrumentedTest.java rename to app/src/androidTest/java/de/overview/wg/its/mispauth/ExampleInstrumentedTest.java index b44b544..4435194 100644 --- a/app/src/androidTest/java/de/overview/wg/its/misp_authentificator/ExampleInstrumentedTest.java +++ b/app/src/androidTest/java/de/overview/wg/its/mispauth/ExampleInstrumentedTest.java @@ -1,4 +1,4 @@ -package de.overview.wg.its.misp_authentificator; +package de.overview.wg.its.mispauth; import android.content.Context; import android.support.test.InstrumentationRegistry; @@ -17,10 +17,10 @@ import static org.junit.Assert.*; @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test - public void useAppContext() { + public void useAppContext() throws Exception { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); - assertEquals("de.overview.wg.its.misp_authentificator", appContext.getPackageName()); + assertEquals("de.overview.wg.its.mispauth", appContext.getPackageName()); } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b226a9c..b80b394 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,33 +1,34 @@ + package="de.overview.wg.its.mispauth"> - + - - - - + - - - + + + - - - + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/de/overview/wg/its/misp_authentificator/PreferenceManager.java b/app/src/main/java/de/overview/wg/its/misp_authentificator/PreferenceManager.java deleted file mode 100644 index e03ae07..0000000 --- a/app/src/main/java/de/overview/wg/its/misp_authentificator/PreferenceManager.java +++ /dev/null @@ -1,54 +0,0 @@ -package de.overview.wg.its.misp_authentificator; - -import android.content.Context; -import android.content.SharedPreferences; - -public class PreferenceManager { - - private static PreferenceManager instance; - private Context context; - private SharedPreferences sharedPreferences; - - private String PREF_KEY_SERVER_URL; - private String PREF_KEY_SERVER_API_KEY; - - private PreferenceManager(Context context) { - this.context = context; - sharedPreferences = android.preference.PreferenceManager.getDefaultSharedPreferences(context); - - PREF_KEY_SERVER_URL = context.getResources().getString(R.string.key_server_url); - PREF_KEY_SERVER_API_KEY = context.getResources().getString(R.string.key_server_api_key); - } - - public String getMyServerUrl() { - return sharedPreferences.getString(PREF_KEY_SERVER_URL, ""); - } - public void setMyServerUrl(String serverUrl) { - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putString(PREF_KEY_SERVER_URL, serverUrl); - editor.apply(); - } - - public String getMyServerApiKey() { - return sharedPreferences.getString(PREF_KEY_SERVER_API_KEY, ""); - } - public void setMyServerApiKey(String apiKey) { - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putString(PREF_KEY_SERVER_API_KEY, apiKey); - editor.apply(); - } - - public void deleteAllLocalData() { - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.clear(); - editor.apply(); - } - - public static PreferenceManager Instance(Context context) { - if(instance == null) { - instance = new PreferenceManager(context); - } - - return instance; - } -} diff --git a/app/src/main/java/de/overview/wg/its/misp_authentificator/activity/SyncActivity.java b/app/src/main/java/de/overview/wg/its/misp_authentificator/activity/SyncActivity.java deleted file mode 100644 index 0c6607e..0000000 --- a/app/src/main/java/de/overview/wg/its/misp_authentificator/activity/SyncActivity.java +++ /dev/null @@ -1,48 +0,0 @@ -package de.overview.wg.its.misp_authentificator.activity; - -import android.graphics.Bitmap; -import android.os.Bundle; -import android.support.design.widget.FloatingActionButton; -import android.support.design.widget.Snackbar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.View; -import android.view.ViewTreeObserver; -import android.widget.Button; -import android.widget.ImageView; -import android.widget.ProgressBar; -import android.widget.TextView; - -import net.glxn.qrgen.android.QRCode; - -import java.lang.reflect.Field; - -import de.overview.wg.its.misp_authentificator.R; - -public class SyncActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_sync); - - Toolbar toolbar = findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setDisplayShowHomeEnabled(true); - - generateMyQR(); - } - - private void generateMyQR() { -// ImageView qrImageView = findViewById(R.id.sync_my_qr); - - Bitmap myBitmap = QRCode.from("This is my organisation information!") - .withColor(0xFF000000, 0x00000000) - .withSize(512,512) - .bitmap(); - -// qrImageView.setImageBitmap(myBitmap); - } -} diff --git a/app/src/main/java/de/overview/wg/its/misp_authentificator/adapter/ExtOrgAdapter.java b/app/src/main/java/de/overview/wg/its/misp_authentificator/adapter/ExtOrgAdapter.java deleted file mode 100644 index ba95915..0000000 --- a/app/src/main/java/de/overview/wg/its/misp_authentificator/adapter/ExtOrgAdapter.java +++ /dev/null @@ -1,48 +0,0 @@ -package de.overview.wg.its.misp_authentificator.adapter; - -import android.support.annotation.NonNull; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import de.overview.wg.its.misp_authentificator.R; - -public class ExtOrgAdapter extends RecyclerView.Adapter { - - private String[] dataSet; - - public ExtOrgAdapter(String[] dataSet) { - this.dataSet = dataSet; - } - - @Override - public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - - View extOrgView = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.view_holder_ext_org, parent, false); - - return new ViewHolder(extOrgView); - } - - @Override - public void onBindViewHolder(@NonNull ViewHolder holder, int position) { - holder.orgTitle.setText(dataSet[position]); - } - - @Override - public int getItemCount() { - return dataSet.length; - } - - public static class ViewHolder extends RecyclerView.ViewHolder { - - public TextView orgTitle; - - public ViewHolder(View v) { - super(v); - orgTitle = v.findViewById(R.id.ext_org_title); - } - } -} diff --git a/app/src/main/java/de/overview/wg/its/misp_authentificator/activity/MainActivity.java b/app/src/main/java/de/overview/wg/its/mispauth/activity/MainActivity.java similarity index 51% rename from app/src/main/java/de/overview/wg/its/misp_authentificator/activity/MainActivity.java rename to app/src/main/java/de/overview/wg/its/mispauth/activity/MainActivity.java index f84cbf3..23703c1 100644 --- a/app/src/main/java/de/overview/wg/its/misp_authentificator/activity/MainActivity.java +++ b/app/src/main/java/de/overview/wg/its/mispauth/activity/MainActivity.java @@ -1,9 +1,10 @@ -package de.overview.wg.its.misp_authentificator.activity; +package de.overview.wg.its.mispauth.activity; import android.content.Intent; -import android.support.design.widget.FloatingActionButton; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.v4.widget.SwipeRefreshLayout; +import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; @@ -11,47 +12,25 @@ import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.widget.ImageView; - -import de.overview.wg.its.misp_authentificator.PreferenceManager; -import de.overview.wg.its.misp_authentificator.R; -import de.overview.wg.its.misp_authentificator.adapter.ExtOrgAdapter; +import de.overview.wg.its.mispauth.R; +import de.overview.wg.its.mispauth.adapter.ExtOrgAdapter; +import de.overview.wg.its.mispauth.auxiliary.PreferenceManager; +import de.overview.wg.its.mispauth.model.Organisation; public class MainActivity extends AppCompatActivity { - PreferenceManager preferenceManager; + private Organisation[] externalOrganisations; @Override protected void onCreate(Bundle savedInstanceState) { - - preferenceManager = PreferenceManager.Instance(this); - super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); - RecyclerView orgRecyclerView = findViewById(R.id.orgRecyclerView); - orgRecyclerView.setHasFixedSize(true); - - RecyclerView.LayoutManager orgLayoutManager = new LinearLayoutManager(this); - orgRecyclerView.setLayoutManager(orgLayoutManager); - - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(orgRecyclerView.getContext(), 1); - orgRecyclerView.addItemDecoration(dividerItemDecoration); - - String[] dataSet = {}; - RecyclerView.Adapter orgAdapter = new ExtOrgAdapter(dataSet); - orgRecyclerView.setAdapter(orgAdapter); - - if(dataSet.length == 0){ - orgRecyclerView.setVisibility(View.GONE); - findViewById(R.id.empty_view).setVisibility(View.VISIBLE); - } else { - orgRecyclerView.setVisibility(View.VISIBLE); - findViewById(R.id.empty_view).setVisibility(View.GONE); - } + getExternalOrganisations(); + setUpRecyclerView(); FloatingActionButton fabAdd = findViewById(R.id.fab_add); final FloatingActionButton fabSync = findViewById(R.id.fab_sync); @@ -80,7 +59,6 @@ public class MainActivity extends AppCompatActivity { getMenuInflater().inflate(R.menu.menu_main, menu); return true; } - @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); @@ -93,6 +71,47 @@ public class MainActivity extends AppCompatActivity { return super.onOptionsItemSelected(item); } + private void setUpRecyclerView() { + RecyclerView orgRecyclerView = findViewById(R.id.orgRecyclerView); + orgRecyclerView.setHasFixedSize(true); + + RecyclerView.LayoutManager orgLayoutManager = new LinearLayoutManager(this); + orgRecyclerView.setLayoutManager(orgLayoutManager); + + DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(orgRecyclerView.getContext(), 1); + orgRecyclerView.addItemDecoration(dividerItemDecoration); + + RecyclerView.Adapter orgAdapter = new ExtOrgAdapter(this, externalOrganisations); + orgRecyclerView.setAdapter(orgAdapter); + + if(externalOrganisations.length == 0){ + orgRecyclerView.setVisibility(View.GONE); + findViewById(R.id.empty_view).setVisibility(View.VISIBLE); + } else { + orgRecyclerView.setVisibility(View.VISIBLE); + findViewById(R.id.empty_view).setVisibility(View.GONE); + } + + final SwipeRefreshLayout refreshLayout = findViewById(R.id.recycler_refresh); + refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + // TODO do stuff + // refreshLayout.setRefreshing(false); + } + }); + } + + private void getExternalOrganisations(){ + Organisation a = new Organisation(); + a.setName("Ferrari"); + a.setDescription("Ferrari has nothing to share"); + a.setSector("Fast cars"); + a.setNationality("Italy"); + a.setUserCount(67); + + externalOrganisations = new Organisation[] {a}; + } private void startSyncActivity(){ startActivity(new Intent(this, SyncActivity.class)); diff --git a/app/src/main/java/de/overview/wg/its/misp_authentificator/activity/SettingsActivity.java b/app/src/main/java/de/overview/wg/its/mispauth/activity/SettingsActivity.java similarity index 54% rename from app/src/main/java/de/overview/wg/its/misp_authentificator/activity/SettingsActivity.java rename to app/src/main/java/de/overview/wg/its/mispauth/activity/SettingsActivity.java index 5524def..b4ac54b 100644 --- a/app/src/main/java/de/overview/wg/its/misp_authentificator/activity/SettingsActivity.java +++ b/app/src/main/java/de/overview/wg/its/mispauth/activity/SettingsActivity.java @@ -1,38 +1,40 @@ -package de.overview.wg.its.misp_authentificator.activity; +package de.overview.wg.its.mispauth.activity; import android.os.Bundle; -import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.design.widget.TextInputLayout; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; +import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.ProgressBar; - -import com.android.volley.AuthFailureError; -import com.android.volley.NoConnectionError; +import android.widget.TextView; import com.android.volley.VolleyError; - -import org.json.JSONException; +import de.overview.wg.its.mispauth.R; +import de.overview.wg.its.mispauth.auxiliary.PreferenceManager; +import de.overview.wg.its.mispauth.auxiliary.ReadableError; +import de.overview.wg.its.mispauth.model.Organisation; +import de.overview.wg.its.mispauth.model.User; +import de.overview.wg.its.mispauth.network.MispRequest; import org.json.JSONObject; -import de.overview.wg.its.misp_authentificator.PreferenceManager; -import de.overview.wg.its.misp_authentificator.R; -import de.overview.wg.its.misp_authentificator.network.MispRequest; - public class SettingsActivity extends AppCompatActivity { - private static final String TAG = "MISP-TAG"; + private static final String TAG = "DEBUG"; private PreferenceManager preferenceManager; private ProgressBar progressBar; private TextInputLayout serverUrlLayout, apiKeyLayout; private EditText serverUrlText, apiKeyText; + private Organisation org; + private User user; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -48,18 +50,26 @@ public class SettingsActivity extends AppCompatActivity { apiKeyLayout = findViewById(R.id.input_layout_api_key); serverUrlText = findViewById(R.id.edit_server_url); apiKeyText = findViewById(R.id.edit_api_key); - progressBar = findViewById(R.id.progressBar); - FloatingActionButton fabDlOrgInfo = findViewById(R.id.fab_download_own_org_info); - - fabDlOrgInfo.setOnClickListener(new View.OnClickListener() { + findViewById(R.id.fab_download_own_org_info).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { downloadMyOrgInfo(); } }); + apiKeyText.setOnKeyListener(new View.OnKeyListener() { + public boolean onKey(View v, int keyCode, KeyEvent event) { + if (keyCode == 66) { + hideKeyboard(v); + apiKeyText.clearFocus(); + return true; + } + return false; + } + }); + restoreSavedValues(); } @@ -68,7 +78,6 @@ public class SettingsActivity extends AppCompatActivity { getMenuInflater().inflate(R.menu.menu_settings, menu); return true; } - @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); @@ -83,15 +92,39 @@ public class SettingsActivity extends AppCompatActivity { return super.onOptionsItemSelected(item); } + private void setOrganisation(Organisation org) { + + if(org == null) { + return; + } + + TextView title = findViewById(R.id.organisation_title); + TextView uuid = findViewById(R.id.organisation_uuid); + TextView description = findViewById(R.id.organisation_description); + TextView nationality = findViewById(R.id.organisation_nationality); + TextView sector = findViewById(R.id.organisation_sector); + TextView userCount = findViewById(R.id.organisation_user_count); + + title.setText(org.getName()); + uuid.setText(org.getUuid()); + description.setText(org.getDescription()); + nationality.setText(org.getNationality()); + sector.setText(org.getSector()); + userCount.setText("" + org.getUserCount()); + } private void restoreSavedValues() { preferenceManager = PreferenceManager.Instance(this); serverUrlText.setText(preferenceManager.getMyServerUrl()); apiKeyText.setText(preferenceManager.getMyServerApiKey()); + + setOrganisation(preferenceManager.getMyOrganisation()); } private void downloadMyOrgInfo(){ + user = new User(); + org = new Organisation(); boolean failed = false; @@ -110,70 +143,69 @@ public class SettingsActivity extends AppCompatActivity { if(failed) { return; + } else { + serverUrlLayout.setError(null); + apiKeyLayout.setError(null); } final MispRequest request = MispRequest.Instance(this); - request.setServerCredentials(tmpServerUrl, tmpApiKey); progressBar.setVisibility(View.VISIBLE); request.myUserInformation(new MispRequest.UserInformationCallback() { + @Override public void onResult(JSONObject myUserInformation) { - int orgID; + user.fromJSON(myUserInformation); + preferenceManager.setMyUser(user); - try { - orgID = myUserInformation.getInt("org_id"); + int orgID = user.getOrgId(); - request.OrganisationInformation(orgID, new MispRequest.OrganisationInformationCallback() { - @Override - public void onResult(JSONObject organisationInformation) { - progressBar.setVisibility(View.GONE); - Log.i(TAG, "onResult: " + organisationInformation.toString()); - } + request.OrganisationInformation(orgID, new MispRequest.OrganisationInformationCallback() { - @Override - public void onError(VolleyError volleyError) { - progressBar.setVisibility(View.GONE); - Log.e(TAG, "onError: " + volleyError.toString()); - } - }); + @Override + public void onResult(JSONObject organisationInformation) { + progressBar.setVisibility(View.GONE); - } catch (JSONException e) { - e.printStackTrace(); - } + org.fromJSON(organisationInformation); + + preferenceManager.setMyOrganisation(org); + + setOrganisation(org); + } + + @Override + public void onError(VolleyError volleyError) { + progressBar.setVisibility(View.GONE); + MakeSnackbar(ReadableError.toReadable(volleyError)); + Log.e(TAG, "onError: " + volleyError.toString()); + } + }); } @Override public void onError(VolleyError volleyError) { progressBar.setVisibility(View.GONE); - - if(volleyError instanceof NoConnectionError) { - MakeAlert("No connection to server"); - } else if(volleyError instanceof AuthFailureError) { - MakeAlert("Wrong API key"); - } + MakeSnackbar(ReadableError.toReadable(volleyError)); } }); // If auth was successful: save new credentials preferenceManager.setMyServerUrl(tmpServerUrl); preferenceManager.setMyServerApiKey(tmpApiKey); - } - private void MakeAlert(String msg){ - + private void MakeSnackbar(String msg){ View contextView = findViewById(R.id.coordinator); - - Snackbar.make(contextView, msg, Snackbar.LENGTH_LONG) - .addCallback(new Snackbar.Callback(){ - @Override - public void onShown(Snackbar sb) { - progressBar.setVisibility(View.GONE); - } - }).show(); + Snackbar.make(contextView, msg, Snackbar.LENGTH_LONG).show(); } + + private void hideKeyboard(View view) { + InputMethodManager manager = (InputMethodManager) view.getContext().getSystemService(INPUT_METHOD_SERVICE); + if (manager != null) { + manager.hideSoftInputFromWindow(view.getWindowToken(), 0); + } + } } diff --git a/app/src/main/java/de/overview/wg/its/mispauth/activity/SyncActivity.java b/app/src/main/java/de/overview/wg/its/mispauth/activity/SyncActivity.java new file mode 100644 index 0000000..4f7477c --- /dev/null +++ b/app/src/main/java/de/overview/wg/its/mispauth/activity/SyncActivity.java @@ -0,0 +1,14 @@ +package de.overview.wg.its.mispauth.activity; + +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import de.overview.wg.its.mispauth.R; + +public class SyncActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_sync); + } +} diff --git a/app/src/main/java/de/overview/wg/its/mispauth/adapter/ExtOrgAdapter.java b/app/src/main/java/de/overview/wg/its/mispauth/adapter/ExtOrgAdapter.java new file mode 100644 index 0000000..4c623ec --- /dev/null +++ b/app/src/main/java/de/overview/wg/its/mispauth/adapter/ExtOrgAdapter.java @@ -0,0 +1,65 @@ +package de.overview.wg.its.mispauth.adapter; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.v7.app.AlertDialog; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.RelativeLayout; +import android.widget.TextView; +import de.overview.wg.its.mispauth.R; +import de.overview.wg.its.mispauth.auxiliary.OrganisationDialog; +import de.overview.wg.its.mispauth.model.Organisation; + +public class ExtOrgAdapter extends RecyclerView.Adapter { + + private Context context; + private Organisation[] dataSet; + + public ExtOrgAdapter(Context context, Organisation[] dataSet) { + this.context = context; + this.dataSet = dataSet; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View extOrgView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_holder_ext_org, parent, false); + return new ViewHolder(extOrgView); + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, final int position) { + holder.orgTitle.setText(dataSet[position].getName()); + holder.subTitle.setText(dataSet[position].getDescription()); + + holder.parentLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + OrganisationDialog d = new OrganisationDialog(context); + d.createDialog(dataSet[position]); + } + }); + } + + @Override + public int getItemCount() { + return dataSet.length; + } + + public static class ViewHolder extends RecyclerView.ViewHolder{ + + RelativeLayout parentLayout; + TextView orgTitle; + TextView subTitle; + + public ViewHolder(View v) { + super(v); + parentLayout = v.findViewById(R.id.parent_layout); + orgTitle = v.findViewById(R.id.ext_org_title); + subTitle = v.findViewById(R.id.ext_org_sub_title); + } + } +} diff --git a/app/src/main/java/de/overview/wg/its/mispauth/auxiliary/OrganisationDialog.java b/app/src/main/java/de/overview/wg/its/mispauth/auxiliary/OrganisationDialog.java new file mode 100644 index 0000000..5c340eb --- /dev/null +++ b/app/src/main/java/de/overview/wg/its/mispauth/auxiliary/OrganisationDialog.java @@ -0,0 +1,45 @@ +package de.overview.wg.its.mispauth.auxiliary; + +import android.app.Activity; +import android.content.Context; +import android.support.v7.app.AlertDialog; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; +import de.overview.wg.its.mispauth.R; +import de.overview.wg.its.mispauth.model.Organisation; + +public class OrganisationDialog { + + private AlertDialog.Builder dialogBuilder; + private LayoutInflater inflater; + + public OrganisationDialog(Context context) { + dialogBuilder = new AlertDialog.Builder(context); + inflater = ((Activity)context).getLayoutInflater(); + } + + public void createDialog(Organisation org) { + + View dialogContent = inflater.inflate(R.layout.view_holder_organisation, null); + dialogBuilder.setView(dialogContent); + + TextView title = dialogContent.findViewById(R.id.organisation_title); + title.setText(org.getName()); + + TextView description = dialogContent.findViewById(R.id.organisation_description); + description.setText(org.getDescription()); + + TextView sector = dialogContent.findViewById(R.id.organisation_sector); + sector.setText(org.getSector()); + + TextView nationality = dialogContent.findViewById(R.id.organisation_nationality); + nationality.setText(org.getNationality()); + + TextView userCount = dialogContent.findViewById(R.id.organisation_user_count); + userCount.setText("" + org.getUserCount()); + + dialogBuilder.setPositiveButton("OK", null); + dialogBuilder.show(); + } +} diff --git a/app/src/main/java/de/overview/wg/its/mispauth/auxiliary/PreferenceManager.java b/app/src/main/java/de/overview/wg/its/mispauth/auxiliary/PreferenceManager.java new file mode 100644 index 0000000..9efd6b2 --- /dev/null +++ b/app/src/main/java/de/overview/wg/its/mispauth/auxiliary/PreferenceManager.java @@ -0,0 +1,95 @@ +package de.overview.wg.its.mispauth.auxiliary; + +import android.content.Context; +import android.content.SharedPreferences; +import de.overview.wg.its.mispauth.model.Organisation; +import de.overview.wg.its.mispauth.model.User; +import org.json.JSONException; +import org.json.JSONObject; + +public class PreferenceManager { + + private static PreferenceManager instance; + private SharedPreferences sharedPreferences; + + private static String PREF_KEY_SERVER_URL = "key_server_url"; + private static String PREF_KEY_SERVER_API_KEY = "key_server_api_key"; + private static String PREF_KEY_MY_ORGANISATION = "key_my_organisation"; + private static String PREF_KEY_MY_USER = "key_my_user"; + + private PreferenceManager(Context context) { + sharedPreferences = android.preference.PreferenceManager.getDefaultSharedPreferences(context); + } + + /** + * @return own Organisation if available, else null + */ + public Organisation getMyOrganisation() { + try { + JSONObject jsonObject = new JSONObject(sharedPreferences.getString(PREF_KEY_MY_ORGANISATION, "")); + Organisation org = new Organisation(); + org.fromJSON(jsonObject); + return org; + } catch (JSONException e) { + e.printStackTrace(); + } + + return null; + } + public void setMyOrganisation(Organisation org) { + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString(PREF_KEY_MY_ORGANISATION, org.toJSON().toString()); + editor.apply(); + } + + public User getMyUser() { + try { + JSONObject jsonObject = new JSONObject(sharedPreferences.getString(PREF_KEY_MY_USER, "")); + User user = new User(); + user.fromJSON(jsonObject); + return user; + } catch (JSONException e) { + e.printStackTrace(); + } + + return null; + } + public void setMyUser(User user) { + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString(PREF_KEY_MY_USER, user.toJSON().toString()); + editor.apply(); + } + + public String getMyServerUrl() { + return sharedPreferences.getString(PREF_KEY_SERVER_URL, ""); + } + public void setMyServerUrl(String serverUrl) { + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString(PREF_KEY_SERVER_URL, serverUrl); + editor.apply(); + } + + public String getMyServerApiKey() { + return sharedPreferences.getString(PREF_KEY_SERVER_API_KEY, ""); + } + public void setMyServerApiKey(String apiKey) { + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString(PREF_KEY_SERVER_API_KEY, apiKey); + editor.apply(); + } + + public void deleteAllLocalData() { + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.clear(); + editor.apply(); + } + + public static PreferenceManager Instance(Context context) { + if(instance == null) { + instance = new PreferenceManager(context); + } + + return instance; + } +} + diff --git a/app/src/main/java/de/overview/wg/its/mispauth/auxiliary/ReadableError.java b/app/src/main/java/de/overview/wg/its/mispauth/auxiliary/ReadableError.java new file mode 100644 index 0000000..9484723 --- /dev/null +++ b/app/src/main/java/de/overview/wg/its/mispauth/auxiliary/ReadableError.java @@ -0,0 +1,19 @@ +package de.overview.wg.its.mispauth.auxiliary; + +import com.android.volley.AuthFailureError; +import com.android.volley.NoConnectionError; +import com.android.volley.VolleyError; + +public class ReadableError { + + public static String toReadable(VolleyError volleyError) { + + if(volleyError instanceof NoConnectionError) { + return "Connection failed"; + } else if(volleyError instanceof AuthFailureError) { + return "Authentication failed"; + } + + return "Unknown error"; + } +} diff --git a/app/src/main/java/de/overview/wg/its/mispauth/model/Organisation.java b/app/src/main/java/de/overview/wg/its/mispauth/model/Organisation.java new file mode 100644 index 0000000..aaa4fa5 --- /dev/null +++ b/app/src/main/java/de/overview/wg/its/mispauth/model/Organisation.java @@ -0,0 +1,186 @@ +package de.overview.wg.its.mispauth.model; + +import org.json.JSONException; +import org.json.JSONObject; + +public class Organisation { + + private static String ID_KEY = "id"; + private static String NAME_KEY = "name"; + private static String DATE_CREATED_KEY = "date_created"; + private static String DATE_MODIFIED_KEY = "date_modified"; + private static String TYPE_KEY = "type"; + private static String NATIONALITY_KEY = "nationality"; + private static String SECTOR_KEY = "sector"; + private static String CONTACTS_KEY = "contacts"; + private static String DESCRIPTION_KEY = "description"; + private static String LOCAL_KEY = "local"; + private static String UUID_KEY = "uuid"; + private static String RESTRICTED_TO_DOMAIN_KEY = "restricted_to_domain"; + private static String CREATED_BY_KEY = "created_by"; + private static String USER_COUNT_KEY = "user_count"; + + private int id; + private String name; + private String dateCreated, dateModified; + private String type; + private String nationality; + private String sector; + private String contacts; + private String description; + private boolean local; + private String uuid; + private String restrictedToDomain; + private int createdBy; + private int userCount; + + public Organisation() {} + + public void fromJSON(JSONObject org) { + + try { + id = org.getInt(ID_KEY); + dateCreated = org.getString(DATE_CREATED_KEY); + dateModified = org.getString(DATE_MODIFIED_KEY); + name = org.getString(NAME_KEY); + type = org.getString(TYPE_KEY); + nationality = org.getString(NATIONALITY_KEY); + sector = org.getString(SECTOR_KEY); + contacts = org.getString(CONTACTS_KEY); + description = org.getString(DESCRIPTION_KEY); + local = org.getBoolean(LOCAL_KEY); + uuid = org.getString(UUID_KEY); + restrictedToDomain = org.getString(RESTRICTED_TO_DOMAIN_KEY); + createdBy = org.getInt(CREATED_BY_KEY); + userCount = org.getInt(USER_COUNT_KEY); + + } catch (JSONException e) { + e.printStackTrace(); + } + } + + public JSONObject toJSON() { + JSONObject org = new JSONObject(); + + try { + org.put(ID_KEY, id); + org.put(NAME_KEY, name); + org.put(DATE_CREATED_KEY, dateCreated); + org.put(DATE_MODIFIED_KEY, dateModified); + org.put(TYPE_KEY, type); + org.put(NATIONALITY_KEY, nationality); + org.put(SECTOR_KEY, sector); + org.put(CONTACTS_KEY, contacts); + org.put(DESCRIPTION_KEY, description); + org.put(LOCAL_KEY, local); + org.put(UUID_KEY, uuid); + org.put(RESTRICTED_TO_DOMAIN_KEY, restrictedToDomain); + org.put(CREATED_BY_KEY, createdBy); + org.put(USER_COUNT_KEY, userCount); + + } catch (JSONException e) { + e.printStackTrace(); + } + + return org; + } + + + public void setName(String name) { + this.name = name; + } + public String getName(){ + return name; + } + + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + public String getSector() { + return sector; + } + public void setSector(String sector) { + this.sector = sector; + } + + public String getNationality() { + return nationality; + } + public void setNationality(String nationality) { + this.nationality = nationality; + } + + public int getId() { + return id; + } + public void setId(int id) { + this.id = id; + } + + public String getDateCreated() { + return dateCreated; + } + public void setDateCreated(String dateCreated) { + this.dateCreated = dateCreated; + } + + public String getDateModified() { + return dateModified; + } + public void setDateModified(String dateModified) { + this.dateModified = dateModified; + } + + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + public String getContacts() { + return contacts; + } + public void setContacts(String contacts) { + this.contacts = contacts; + } + + public boolean isLocal() { + return local; + } + public void setLocal(boolean local) { + this.local = local; + } + + public String getUuid() { + return uuid; + } + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getRestrictedToDomain() { + return restrictedToDomain; + } + public void setRestrictedToDomain(String restrictedToDomain) { + this.restrictedToDomain = restrictedToDomain; + } + + public int getCreatedBy() { + return createdBy; + } + public void setCreatedBy(int createdBy) { + this.createdBy = createdBy; + } + + public int getUserCount() { + return userCount; + } + public void setUserCount(int userCount) { + this.userCount = userCount; + } +} diff --git a/app/src/main/java/de/overview/wg/its/mispauth/model/User.java b/app/src/main/java/de/overview/wg/its/mispauth/model/User.java new file mode 100644 index 0000000..bb06663 --- /dev/null +++ b/app/src/main/java/de/overview/wg/its/mispauth/model/User.java @@ -0,0 +1,298 @@ +package de.overview.wg.its.mispauth.model; + +import org.json.JSONException; +import org.json.JSONObject; + +public class User { + + private static String ID_KEY = "id"; + private static String PASSWORD_KEY = "password"; + private static String ORG_ID_KEY = "org_id"; + private static String EMAIL_KEY = "email"; + private static String AUTOALERT_KEY = "autoalert"; + private static String AUTHKEY_KEY = "authkey"; + private static String INVITED_BY_KEY = "invited_by"; + private static String GPGKEY_KEY = "gpgkey"; + private static String CERTIF_PUBLIC = "certif_public"; + private static String NIDS_SID = "nids_sid"; + private static String TERMS_ACCEPTED_KEY = "termsaccepted"; + private static String NEWSREAD_KEY = "newsread"; + private static String ROLE_ID_KEY = "role_id"; + private static String CHANGE_PW_KEY = "change_pw"; + private static String CONTACT_ALERT_KEY = "contactalert"; + private static String DISABLED_KEY = "disabled"; + private static String EXPIRATION_KEY = "expiration"; + private static String CURRENT_LOGIN_KEY = "current_login"; + private static String LAST_LOGIN_KEY = "last_login"; + private static String FORCE_LOGOUT_KEY = "force_logout"; + private static String DATE_CREATED_KEY = "date_created"; + private static String DATE_MODIFIED_KEY = "date_modified"; + + private int id; + private String password; + private int orgId; + private String email; + private boolean autoAlert; + private String authkey; + private int invitedBy; + private String gpgKey; + private String certifPublic; + private int nidsSid; + private boolean termsAccepted; + private int newsRead; // Integer?? + private int roleId; + private String changePw; + private boolean contactAlert; + private boolean disabled; + private String expiration; + private String currentLogin; + private String lastLogin; + private boolean forceLogout; + private String dateCreated; + private String dateModified; + + public User() {} + + public void fromJSON(JSONObject user) { + try { + + id = user.getInt(ID_KEY); + password = user.getString(PASSWORD_KEY); + orgId = user.getInt(ORG_ID_KEY); + email = user.getString(EMAIL_KEY); + autoAlert = user.getBoolean(AUTOALERT_KEY); + authkey = user.getString(AUTHKEY_KEY); + invitedBy = user.getInt(INVITED_BY_KEY); + gpgKey = user.getString(GPGKEY_KEY); + certifPublic = user.getString(CERTIF_PUBLIC); + nidsSid = user.getInt(NIDS_SID); + termsAccepted = user.getBoolean(TERMS_ACCEPTED_KEY); + newsRead = user.getInt(NEWSREAD_KEY); + roleId = user.getInt(ROLE_ID_KEY); + changePw = user.getString(CHANGE_PW_KEY); + contactAlert = user.getBoolean(CONTACT_ALERT_KEY); + disabled = user.getBoolean(DISABLED_KEY); + expiration = user.getString(EXPIRATION_KEY); + currentLogin = user.getString(CURRENT_LOGIN_KEY); + lastLogin = user.getString(LAST_LOGIN_KEY); + forceLogout = user.getBoolean(FORCE_LOGOUT_KEY); + dateCreated = user.getString(DATE_CREATED_KEY); + dateModified = user.getString(DATE_MODIFIED_KEY); + + } catch (JSONException e) { + e.printStackTrace(); + } + + } + + public JSONObject toJSON() { + JSONObject user = new JSONObject(); + + try { + + user.put(ID_KEY, id); + user.put(PASSWORD_KEY, password); + user.put(ORG_ID_KEY, orgId); + user.put(EMAIL_KEY, email); + user.put(AUTOALERT_KEY, autoAlert); + user.put(AUTHKEY_KEY, authkey); + user.put(INVITED_BY_KEY, invitedBy); + user.put(GPGKEY_KEY, gpgKey); + user.put(CERTIF_PUBLIC, certifPublic); + user.put(NIDS_SID, nidsSid); + user.put(TERMS_ACCEPTED_KEY, termsAccepted); + user.put(NEWSREAD_KEY, newsRead); + user.put(ROLE_ID_KEY, roleId); + user.put(CHANGE_PW_KEY, changePw); + user.put(CONTACT_ALERT_KEY, contactAlert); + user.put(DISABLED_KEY, disabled); + user.put(EXPIRATION_KEY, expiration); + user.put(CURRENT_LOGIN_KEY, currentLogin); + user.put(LAST_LOGIN_KEY, lastLogin); + user.put(FORCE_LOGOUT_KEY, forceLogout); + user.put(DATE_CREATED_KEY, dateCreated); + user.put(DATE_MODIFIED_KEY, dateModified); + + } catch (JSONException e) { + e.printStackTrace(); + } + + return user; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public int getOrgId() { + return orgId; + } + + public void setOrgId(int orgId) { + this.orgId = orgId; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public boolean isAutoAlert() { + return autoAlert; + } + + public void setAutoAlert(boolean autoAlert) { + this.autoAlert = autoAlert; + } + + public String getAuthkey() { + return authkey; + } + + public void setAuthkey(String authkey) { + this.authkey = authkey; + } + + public int getInvitedBy() { + return invitedBy; + } + + public void setInvitedBy(int invitedBy) { + this.invitedBy = invitedBy; + } + + public String getGpgKey() { + return gpgKey; + } + + public void setGpgKey(String gpgKey) { + this.gpgKey = gpgKey; + } + + public String getCertifPublic() { + return certifPublic; + } + + public void setCertifPublic(String certifPublic) { + this.certifPublic = certifPublic; + } + + public int getNidsSid() { + return nidsSid; + } + + public void setNidsSid(int nidsSid) { + this.nidsSid = nidsSid; + } + + public boolean isTermsAccepted() { + return termsAccepted; + } + + public void setTermsAccepted(boolean termsAccepted) { + this.termsAccepted = termsAccepted; + } + + public int getNewsRead() { + return newsRead; + } + + public void setNewsRead(int newsRead) { + this.newsRead = newsRead; + } + + public int getRoleId() { + return roleId; + } + + public void setRoleId(int roleId) { + this.roleId = roleId; + } + + public String getChangePw() { + return changePw; + } + + public void setChangePw(String changePw) { + this.changePw = changePw; + } + + public boolean isContactAlert() { + return contactAlert; + } + + public void setContactAlert(boolean contactAlert) { + this.contactAlert = contactAlert; + } + + public boolean isDisabled() { + return disabled; + } + + public void setDisabled(boolean disabled) { + this.disabled = disabled; + } + + public String getExpiration() { + return expiration; + } + + public void setExpiration(String expiration) { + this.expiration = expiration; + } + + public String getCurrentLogin() { + return currentLogin; + } + + public void setCurrentLogin(String currentLogin) { + this.currentLogin = currentLogin; + } + + public String getLastLogin() { + return lastLogin; + } + + public void setLastLogin(String lastLogin) { + this.lastLogin = lastLogin; + } + + public boolean isForceLogout() { + return forceLogout; + } + + public void setForceLogout(boolean forceLogout) { + this.forceLogout = forceLogout; + } + + public String getDateCreated() { + return dateCreated; + } + + public void setDateCreated(String dateCreated) { + this.dateCreated = dateCreated; + } + + public String getDateModified() { + return dateModified; + } + + public void setDateModified(String dateModified) { + this.dateModified = dateModified; + } +} diff --git a/app/src/main/java/de/overview/wg/its/misp_authentificator/network/MispRequest.java b/app/src/main/java/de/overview/wg/its/mispauth/network/MispRequest.java similarity index 97% rename from app/src/main/java/de/overview/wg/its/misp_authentificator/network/MispRequest.java rename to app/src/main/java/de/overview/wg/its/mispauth/network/MispRequest.java index 55dd79a..2005fcb 100644 --- a/app/src/main/java/de/overview/wg/its/misp_authentificator/network/MispRequest.java +++ b/app/src/main/java/de/overview/wg/its/mispauth/network/MispRequest.java @@ -1,24 +1,21 @@ -package de.overview.wg.its.misp_authentificator.network; +package de.overview.wg.its.mispauth.network; import android.content.Context; import android.support.annotation.Nullable; import android.util.Log; - import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; - +import de.overview.wg.its.mispauth.auxiliary.PreferenceManager; import org.json.JSONException; import org.json.JSONObject; import java.util.HashMap; import java.util.Map; -import de.overview.wg.its.misp_authentificator.PreferenceManager; - /** * Simple JSON based API to communicate with MISP-Instances */ @@ -33,7 +30,6 @@ public class MispRequest { private String serverUrl, apiKey; /** - * * @param context for Volley and PreferenceManager */ private MispRequest(Context context) { @@ -42,7 +38,6 @@ public class MispRequest { } /** - * * @param orgId organisation ID on the MISP-Instance * @param callback returns a single Organisation-JSON */ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 6cf2f56..c446141 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,81 +1,92 @@ + tools:context=".activity.SettingsActivity" + android:background="@color/colorPrimary"> + android:id="@+id/settings.appbar" + app:elevation="0dp" + android:background="@color/colorPrimaryDark" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:theme="@style/AppTheme.AppBarOverlay"> + android:id="@+id/toolbar" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize" + android:backgroundTint="@color/colorPrimary" + android:background="@drawable/background_rounded_main" + app:popupTheme="@style/AppTheme.PopupOverlay"/> - - + android:layout_height="match_parent" + android:background="@drawable/background_rounded_main" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + android:id="@+id/empty_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="16dp" + android:layout_marginEnd="16dp" + android:layout_marginStart="16dp" + android:layout_marginTop="16dp" + android:text="@string/empty_ext_org_dataset" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"/> + + + + + + + + android:id="@+id/fab_add" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_margin="@dimen/fab_margin" + app:fabSize="normal" + app:layout_anchor="@+id/constraintLayout" + app:layout_anchorGravity="right|bottom" + app:srcCompat="@drawable/ic_add_white"/> + android:id="@+id/fab_sync" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="100dp" + android:visibility="gone" + app:fabSize="mini" + app:layout_anchor="@+id/fab_add" + app:layout_anchorGravity="top|center_horizontal" + app:srcCompat="@drawable/ic_sync_white"/> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 3e99ae2..aa439e7 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -77,7 +77,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background_rounded_main" - android:padding="16dp" app:layout_behavior="@string/appbar_scrolling_view_behavior"> - - - - - - - - - - - - - - - + diff --git a/app/src/main/res/layout/view_holder_ext_org.xml b/app/src/main/res/layout/view_holder_ext_org.xml index 1006af7..b9d507a 100644 --- a/app/src/main/res/layout/view_holder_ext_org.xml +++ b/app/src/main/res/layout/view_holder_ext_org.xml @@ -1,33 +1,29 @@ - - + android:padding="16dp" + android:clickable="true" + android:focusable="true"> + android:id="@+id/ext_org_title" + android:layout_marginEnd="40dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:text="Title" + android:textSize="20sp" + android:textStyle="bold"/> - + \ No newline at end of file diff --git a/app/src/main/res/layout/view_holder_organisation.xml b/app/src/main/res/layout/view_holder_organisation.xml new file mode 100644 index 0000000..b975fa5 --- /dev/null +++ b/app/src/main/res/layout/view_holder_organisation.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 834fd0e..792af37 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,19 +1,14 @@ - MISPauth + MISPauth - No External Organisations available - No Local Information Available + No External Organisations available + No Local Information Available - // Settings + // Settings - Server URL - API Key - Settings - Synchronise - - // Preferences - - key_server_url - key_server_api_key + Server URL + API Key + Settings + Synchronise diff --git a/app/src/test/java/de/overview/wg/its/misp_authentificator/ExampleUnitTest.java b/app/src/test/java/de/overview/wg/its/mispauth/ExampleUnitTest.java similarity index 76% rename from app/src/test/java/de/overview/wg/its/misp_authentificator/ExampleUnitTest.java rename to app/src/test/java/de/overview/wg/its/mispauth/ExampleUnitTest.java index 6914031..fc9a8ef 100644 --- a/app/src/test/java/de/overview/wg/its/misp_authentificator/ExampleUnitTest.java +++ b/app/src/test/java/de/overview/wg/its/mispauth/ExampleUnitTest.java @@ -1,4 +1,4 @@ -package de.overview.wg.its.misp_authentificator; +package de.overview.wg.its.mispauth; import org.junit.Test; @@ -11,7 +11,7 @@ import static org.junit.Assert.*; */ public class ExampleUnitTest { @Test - public void addition_isCorrect() { + public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265e..13372ae 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c19dc09..704f671 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -#Tue May 22 17:01:34 CEST 2018 +#Thu Jun 07 17:33:27 CEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index cccdd3d..9d82f78 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash ############################################################################## ## @@ -6,6 +6,42 @@ ## ############################################################################## +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" @@ -24,46 +60,6 @@ cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -89,7 +85,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -154,19 +150,11 @@ if $cygwin ; then esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") } -APP_ARGS=$(save "$@") +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat index e95643d..aec9973 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,9 +46,10 @@ echo location of your Java installation. goto fail :init -@rem Get command-line arguments, handling Windows variants +@rem Get command-line arguments, handling Windowz variants if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. @@ -59,6 +60,11 @@ set _SKIP=2 if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ :execute @rem Setup the command line