From 0d4d15d82d686555647cac278c0ffa783ca866af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit=20=C3=87olako=C4=9Flu?= Date: Sun, 24 Mar 2019 13:34:59 +0300 Subject: [PATCH] SSL Encryption started --- .../java/gq/yigit/mycity/MainActivity.java | 44 ++++++- .../AdditionalKeyStoresSSLSocketFactory.java | 113 ++++++++++++++++++ .../gq/yigit/mycity/tools/WebRequest.java | 43 ++++++- .../mycity/voteFragment/VoteFragment.java | 4 +- .../mycity/votesFragment/VotesFragment.java | 2 +- MyCity/app/src/main/res/raw/mystore.bks | Bin 0 -> 1037 bytes MyCity/app/src/main/res/values/strings.xml | 1 + server_side/api/app.py | 9 +- .../api/encryption/mycity-decrypted.key | 27 +++++ server_side/api/encryption/mycity.crt | 22 ++++ server_side/api/encryption/mycity.csr | 18 +++ server_side/api/encryption/mycity.key | 30 +++++ server_side/api/encryption/mycity.pem | 22 ++++ server_side/api/login/__init__.py | 0 .../login/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 159 bytes .../login/__pycache__/login.cpython-37.pyc | Bin 0 -> 884 bytes server_side/api/login/login.py | 28 +++++ server_side/api/login/userdata.json | 3 + .../__pycache__/voting_system.cpython-37.pyc | Bin 3078 -> 3087 bytes .../api/voting_system/voting_system.py | 2 +- server_side/api/voting_system/votings.json | 12 +- 21 files changed, 359 insertions(+), 21 deletions(-) create mode 100644 MyCity/app/src/main/java/gq/yigit/mycity/tools/AdditionalKeyStoresSSLSocketFactory.java create mode 100644 MyCity/app/src/main/res/raw/mystore.bks create mode 100644 server_side/api/encryption/mycity-decrypted.key create mode 100644 server_side/api/encryption/mycity.crt create mode 100644 server_side/api/encryption/mycity.csr create mode 100644 server_side/api/encryption/mycity.key create mode 100644 server_side/api/encryption/mycity.pem create mode 100644 server_side/api/login/__init__.py create mode 100644 server_side/api/login/__pycache__/__init__.cpython-37.pyc create mode 100644 server_side/api/login/__pycache__/login.cpython-37.pyc create mode 100644 server_side/api/login/login.py create mode 100644 server_side/api/login/userdata.json diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java b/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java index e8842e3..03782af 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java @@ -9,6 +9,7 @@ import android.support.design.widget.Snackbar; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.AlertDialog; +import android.util.Log; import android.view.*; import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; @@ -17,16 +18,30 @@ import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.widget.EditText; +import android.widget.Toast; import gq.yigit.mycity.tools.FileActions; +import gq.yigit.mycity.tools.WebRequest; +import gq.yigit.mycity.tools.responseListener; import gq.yigit.mycity.voteFragment.VoteFragment; import gq.yigit.mycity.votesFragment.VotesContent; import gq.yigit.mycity.votesFragment.VotesFragment; +import org.json.JSONArray; +import org.json.JSONObject; -public class MainActivity extends AppCompatActivity - implements NavigationView.OnNavigationItemSelectedListener, VotesFragment.OnListFragmentInteractionListener, MainFragment.OnFragmentInteractionListener, VoteFragment.OnFragmentInteractionListener { +import java.util.HashMap; - public Context cntxt; +import static java.security.AccessController.getContext; +public class MainActivity extends AppCompatActivity + implements + NavigationView.OnNavigationItemSelectedListener, + VotesFragment.OnListFragmentInteractionListener, + MainFragment.OnFragmentInteractionListener, + VoteFragment.OnFragmentInteractionListener, + responseListener{ + + public static Context cntxt; + public static JSONArray userData; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -48,7 +63,13 @@ public class MainActivity extends AppCompatActivity this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); - + FileActions file_manager = new FileActions(); + String url = file_manager.readFromFile(cntxt,"server.config").trim(); + HashMap request = new HashMap<>(); + request.put("a","b"); + WebRequest login_manager = new WebRequest(url + "/login/",false,request); + login_manager.addListener(this); + login_manager.execute(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); MainFragment fragment = new MainFragment(); @@ -91,7 +112,7 @@ public class MainActivity extends AppCompatActivity alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { FileActions file_manager = new FileActions(); - file_manager.writeToFile("http://" + input.getText().toString()+":5000",cntxt,"server.config"); + file_manager.writeToFile("https://" + input.getText().toString()+":5000",cntxt,"server.config"); } }); @@ -151,4 +172,17 @@ public class MainActivity extends AppCompatActivity } + public void receivedResponse(boolean success,String response){ + if(success) { + try { + userData = new JSONArray(response); + if(!(boolean)userData.get(0)){ + Toast.makeText(cntxt,"Please login again!",Toast.LENGTH_LONG).show(); + } + }catch (Exception e){ + Log.e("[ERROR]","Cannot receive userdata"); + } + } + } + } diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/tools/AdditionalKeyStoresSSLSocketFactory.java b/MyCity/app/src/main/java/gq/yigit/mycity/tools/AdditionalKeyStoresSSLSocketFactory.java new file mode 100644 index 0000000..e1aadb7 --- /dev/null +++ b/MyCity/app/src/main/java/gq/yigit/mycity/tools/AdditionalKeyStoresSSLSocketFactory.java @@ -0,0 +1,113 @@ +package gq.yigit.mycity.tools; + +import cz.msebera.android.httpclient.conn.scheme.HostNameResolver; +import cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; +import java.io.IOException; +import java.net.Socket; +import java.security.*; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.Arrays; + +public class AdditionalKeyStoresSSLSocketFactory extends SSLSocketFactory { + protected SSLContext sslContext = SSLContext.getInstance("TLS"); + + public AdditionalKeyStoresSSLSocketFactory(KeyStore keyStore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { + super(null, null, null, null, null, (HostNameResolver) null); + sslContext.init(null, new TrustManager[]{new AdditionalKeyStoresTrustManager(keyStore)}, null); + } + + @Override + public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException { + return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose); + } + + @Override + public Socket createSocket() throws IOException { + return sslContext.getSocketFactory().createSocket(); + } + + + + /** + * Based on http://download.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#X509TrustManager + */ + public static class AdditionalKeyStoresTrustManager implements X509TrustManager { + + protected ArrayList x509TrustManagers = new ArrayList(); + + + protected AdditionalKeyStoresTrustManager(KeyStore... additionalkeyStores) { + final ArrayList factories = new ArrayList(); + + try { + // The default Trustmanager with default keystore + final TrustManagerFactory original = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + original.init((KeyStore) null); + factories.add(original); + + for( KeyStore keyStore : additionalkeyStores ) { + final TrustManagerFactory additionalCerts = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + additionalCerts.init(keyStore); + factories.add(additionalCerts); + } + + } catch (Exception e) { + throw new RuntimeException(e); + } + + + + /* + * Iterate over the returned trustmanagers, and hold on + * to any that are X509TrustManagers + */ + for (TrustManagerFactory tmf : factories) + for( TrustManager tm : tmf.getTrustManagers() ) + if (tm instanceof X509TrustManager) + x509TrustManagers.add( (X509TrustManager)tm ); + + + if( x509TrustManagers.size()==0 ) + throw new RuntimeException("Couldn't find any X509TrustManagers"); + + } + + /* + * Delegate to the default trust manager. + */ + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + final X509TrustManager defaultX509TrustManager = x509TrustManagers.get(0); + defaultX509TrustManager.checkClientTrusted(chain, authType); + } + + /* + * Loop over the trustmanagers until we find one that accepts our server + */ + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + for( X509TrustManager tm : x509TrustManagers ) { + try { + tm.checkServerTrusted(chain,authType); + return; + } catch( CertificateException e ) { + // ignore + } + } + throw new CertificateException(); + } + + public X509Certificate[] getAcceptedIssuers() { + final ArrayList list = new ArrayList(); + for( X509TrustManager tm : x509TrustManagers ) + list.addAll(Arrays.asList(tm.getAcceptedIssuers())); + return list.toArray(new X509Certificate[list.size()]); + } + } + +} \ No newline at end of file diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/tools/WebRequest.java b/MyCity/app/src/main/java/gq/yigit/mycity/tools/WebRequest.java index bcee042..9cdc9a5 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/tools/WebRequest.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/tools/WebRequest.java @@ -8,11 +8,21 @@ import cz.msebera.android.httpclient.client.HttpClient; import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; import cz.msebera.android.httpclient.client.methods.HttpGet; import cz.msebera.android.httpclient.client.methods.HttpPost; + +import cz.msebera.android.httpclient.conn.scheme.PlainSocketFactory; +import cz.msebera.android.httpclient.conn.scheme.Scheme; +import cz.msebera.android.httpclient.conn.scheme.SchemeRegistry; import cz.msebera.android.httpclient.impl.client.HttpClientBuilder; +import cz.msebera.android.httpclient.impl.conn.tsccm.ThreadSafeClientConnManager; import cz.msebera.android.httpclient.message.BasicNameValuePair; +import cz.msebera.android.httpclient.params.BasicHttpParams; +import cz.msebera.android.httpclient.params.HttpParams; +import gq.yigit.mycity.MainActivity; +import gq.yigit.mycity.R; -import java.io.BufferedReader; -import java.io.InputStreamReader; +import javax.net.ssl.*; +import java.io.*; +import java.security.KeyStore; import java.util.*; public class WebRequest extends AsyncTask { @@ -20,15 +30,37 @@ public class WebRequest extends AsyncTask { private HashMap request_content; private boolean request_type;//True = GET, False = POST - private HttpClient client = HttpClientBuilder.create().build(); + private HttpClient client; private HttpGet get_request; private HttpPost post_request; private HttpResponse response; private List listeners = new ArrayList<>(); + protected cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory createAdditionalCertsSSLSocketFactory() { + try { + final KeyStore ks = KeyStore.getInstance("BKS"); + + // the bks file we generated above + final InputStream in = MainActivity.cntxt.getResources().openRawResource( R.raw.mystore); + try { + // don't forget to put the password used above in strings.xml/mystore_password + ks.load(in, MainActivity.cntxt.getString( R.string.mystore_password ).toCharArray()); + } finally { + in.close(); + } + + return new AdditionalKeyStoresSSLSocketFactory(ks); + } catch( Exception e ) { + throw new RuntimeException(e); + } + } public WebRequest(String url, boolean request_type, HashMap request_content){ - //request_type=true:get else post + + final SchemeRegistry schemeRegistry = new SchemeRegistry(); + schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 5000)); + schemeRegistry.register(new Scheme("https", createAdditionalCertsSSLSocketFactory(), 5000)); + client = HttpClientBuilder.create().setSSLSocketFactory(createAdditionalCertsSSLSocketFactory()).build(); this.url = url; this.request_content = request_content; @@ -98,5 +130,6 @@ public class WebRequest extends AsyncTask { public void addListener(responseListener toAdd) { listeners.add(toAdd); } +} + -} \ No newline at end of file diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/voteFragment/VoteFragment.java b/MyCity/app/src/main/java/gq/yigit/mycity/voteFragment/VoteFragment.java index 432b3a0..a86916c 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/voteFragment/VoteFragment.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/voteFragment/VoteFragment.java @@ -157,14 +157,14 @@ public class VoteFragment extends Fragment implements responseListener, imageLis submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if(!user_vote.isEmpty()){ + if(!user_vote.isEmpty() && Integer.parseInt(user_vote) > 0){ HashMap params = new HashMap<>(); params.put("voting_id",vote_id); params.put("vote_id",user_vote); WebRequest vote_request = new WebRequest(url+"/vote",true, params); vote_request.execute(); }else{ - Toast.makeText(cntxt,"Please selet a vote!",Toast.LENGTH_SHORT); + Toast.makeText(cntxt,"Please selet a vote!",Toast.LENGTH_SHORT).show(); } } }); diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java b/MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java index 699415c..0ad932e 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java @@ -66,7 +66,7 @@ public class VotesFragment extends Fragment implements responseListener, imageLi } FileActions file_manager = new FileActions(); url = (file_manager.readFromFile(context,"server.config")).trim(); - WebRequest web_manager = new WebRequest(url + "/votings",true,new HashMap()); + WebRequest web_manager = new WebRequest(url + "/votings/",true,new HashMap()); web_manager.addListener(this); web_manager.execute(); } diff --git a/MyCity/app/src/main/res/raw/mystore.bks b/MyCity/app/src/main/res/raw/mystore.bks new file mode 100644 index 0000000000000000000000000000000000000000..dfbb2ba64eff7ca3f8b02a4379751a4e494ca967 GIT binary patch literal 1037 zcmZQzU|?ckU=X=18vpvn%i#YvyyP3&y=Kql4-5=sU|`i@WMDL4U|`H#_qS;dP#sVx zLeJE|l7WGFuR#;@PJ^v;VnI)Bm0tS2_ zE*B4bNNP$@ep0@njDZwLgque=D782>u_#&BCABOyC%+&!HLt{w&wvLc%gniBSnTpcz>in41{+84Q{jxtN+585tI>{U^PQyS4SE_5`D+O8zCf zEoY|1h03`*ADy-N)6BeJS)ntIM>2jfw#X>T)-YK%eEm01K4Zq&%~>8D4>XupE?m?7 zYrF1}E}5p)0yXC!c$KFm$rVMrPSvhb|9dTM|F`B4q0fTt0UZxnx0+1+a@nzE%G_ex zHw;QuQiu&#MTe9hTy4|sm z83w1*yNh?-cHXr=a`Cc;_eSdbTPYr5RhDm1bnQ?G!x_nq72lbdK?xW&DFQ=? zk)d*x@{u!==|`GGX0%3oO;Kz0thEi!ZQPw+cJkH1iF>C`;=6Ac;>#S;{fqgR`hoZB z-S(?}ay9E&k-UKWG}oyc2~`&l2C}o3RqbB0<=)ny@E>=(CyRGKR!q|olc_Z8nq+uE zz-Dq?uqW?fpD8bY6uy+2?N_s6yT#9&FO>F7-mSmGWsCS0!M?3k4WE2+or@>)mA+-0 z^P*QaP%)VQ$U7GA?vS@<58K^+_|z>*BkP-T^IgNa^B*iosw|qh^4RqPbSettings Transport For you + yigit007 Hello blank fragment diff --git a/server_side/api/app.py b/server_side/api/app.py index 8c32dd7..dcebc8d 100644 --- a/server_side/api/app.py +++ b/server_side/api/app.py @@ -3,15 +3,20 @@ from flask_restful import Resource, Api from voting_system import voting_system from rating_system import rating_system +from login import login app = Flask(__name__) api = Api(app) + + @app.route('/img/') def send_img(path): return send_from_directory('images', path) if __name__ == '__main__': + + context = ('encryption/mycity.crt','encryption/mycity-decrypted.key') api.add_resource(voting_system.Votings, '/votings', '/votings/') api.add_resource(voting_system.Voting, '/votings/') api.add_resource(voting_system.Vote, '/vote', '/vote/') @@ -20,4 +25,6 @@ if __name__ == '__main__': api.add_resource(rating_system.Rating, '/ratings/', '/ratings//') api.add_resource(rating_system.Rate, '/rate', '/rate/') - app.run(host='0.0.0.0', port=5000) \ No newline at end of file + api.add_resource(login.Login, '/login', '/login/') + + app.run(host='0.0.0.0', port=5000, ssl_context=context) diff --git a/server_side/api/encryption/mycity-decrypted.key b/server_side/api/encryption/mycity-decrypted.key new file mode 100644 index 0000000..4e5f8c0 --- /dev/null +++ b/server_side/api/encryption/mycity-decrypted.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAoq3+G6YLhYXZK5Ay5SJPdC2EzJZeVR5HQ8Was/KZblMdEsxB +xGj6AYQcIR18AjmA9f6eH2iYzbNqSIjgKAOpoayL+rctpIocgqsQfM/gSndmYh5y +W0WVK3on/dZmv/aDVBLzEYdQiOEFtTSR9NNBhJSdcz3sACJ6GmFnNgsczgC4FgsR +wTiHbXpSw8oSWjIgVVHj6vSwARgJR4inJEyynNaMouS8K4NTLfLnXTgdTSmCWinm +Ac1ViHKOenTwe7ws+wmJvX8dZU95WC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vd5OO1fl +SqDGGBmXkwOGn44MH2m7c4XM9s06bawK1kf3f2utXRGPEXEzEEWvzQJ8/ZpicNl/ +oRRW/QKBgGNtRTr4+Hv2lqx4iApAbITPeBY+Y/ZA02w5iYUgWV6cpOiBKwivbFp5 +KcLwPpeRq8Cp5eOs97n01mxxTSYaxok2BHvJDF3sJy2XjvP4on8209FNmn+0FKSy +apfPSsWHlunD6MXrK13mofjwRS2CqDhZRomynIeeQ+kvnt74TBt3 +-----END RSA PRIVATE KEY----- diff --git a/server_side/api/encryption/mycity.crt b/server_side/api/encryption/mycity.crt new file mode 100644 index 0000000..d209a17 --- /dev/null +++ b/server_side/api/encryption/mycity.crt @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDuTCCAqECFB4w/WXumGEKLcUlhWqZCNDVXtzgMA0GCSqGSIb3DQEBCwUAMIGY +MQswCQYDVQQGEwJUUjEPMA0GA1UECAwGQW5rYXJhMQ0wCwYDVQQHDARjaXR5MRAw +DgYDVQQKDAdUZWRSb2JvMRwwGgYDVQQLDBNSZXNlYXJjLURldmVsb3BtZW50MQ4w +DAYDVQQDDAVZaWdpdDEpMCcGCSqGSIb3DQEJARYaeWlnaXRjb2xha29nbHVAaG90 +bWFpbC5jb20wHhcNMTkwMzIzMjIxNzI4WhcNMjAwMzIyMjIxNzI4WjCBmDELMAkG +A1UEBhMCVFIxDzANBgNVBAgMBkFua2FyYTENMAsGA1UEBwwEY2l0eTEQMA4GA1UE +CgwHVGVkUm9ibzEcMBoGA1UECwwTUmVzZWFyYy1EZXZlbG9wbWVudDEOMAwGA1UE +AwwFWWlnaXQxKTAnBgkqhkiG9w0BCQEWGnlpZ2l0Y29sYWtvZ2x1QGhvdG1haWwu +Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoq3+G6YLhYXZK5Ay +5SJPdC2EzJZeVR5HQ8Was/KZblMdEsxBxGj6AYQcIR18AjmA9f6eH2iYzbNqSIjg +KAOpoayL+rctpIocgqsQfM/gSndmYh5yW0WVK3on/dZmv/aDVBLzEYdQiOEFtTSR +9NNBhJSdcz3sACJ6GmFnNgsczgC4FgsRwTiHbXpSw8oSWjIgVVHj6vSwARgJR4in +JEyynNaMouS8K4NTLfLnXTgdTSmCWinmAc1ViHKOenTwe7ws+wmJvX8dZU95WC/8 +IX7b+wakstdnPsZUmDDLZ4tzuttDur9Zo6aA7zKv4nipF1apF1Q6dm8wctbCVADM +GbF49wIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQB5qiPEzBlnxIIUmIVbSpQmhUl9 +PVNtgbtndsnqwZG9lZIO3zFUTQNUi/oD+ifA769GvybyRTaMqGOgC8sKythgetHB +UQcFdnq7rLTetVJX+N2LkxeL4yFmLBYceTaKkjHQEDyTflNJDcNMlOn4cekam058 +qLc4+dnoIryTuy+4RLQXtBGOtXqA8kxtQ3OTDnXtBpzojR1RIVMPxO4ES4tU7c3D +Pt3h5UZaKGr2I4PdMZ2f4KBieXKZqcbXcCcp/XuRqxcQBk6hM2U9IesZZGH2Q4yd +VQBFWd0u0Ghre2M8sFURjq6tfqdAkAV+XMTVjHwwtkCi061h8++56y47YAy3 +-----END CERTIFICATE----- diff --git a/server_side/api/encryption/mycity.csr b/server_side/api/encryption/mycity.csr new file mode 100644 index 0000000..3ac041a --- /dev/null +++ b/server_side/api/encryption/mycity.csr @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIC3jCCAcYCAQAwgZgxCzAJBgNVBAYTAlRSMQ8wDQYDVQQIDAZBbmthcmExDTAL +BgNVBAcMBGNpdHkxEDAOBgNVBAoMB1RlZFJvYm8xHDAaBgNVBAsME1Jlc2VhcmMt +RGV2ZWxvcG1lbnQxDjAMBgNVBAMMBVlpZ2l0MSkwJwYJKoZIhvcNAQkBFhp5aWdp +dGNvbGFrb2dsdUBob3RtYWlsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAKKt/humC4WF2SuQMuUiT3QthMyWXlUeR0PFmrPymW5THRLMQcRo+gGE +HCEdfAI5gPX+nh9omM2zakiI4CgDqaGsi/q3LaSKHIKrEHzP4Ep3ZmIecltFlSt6 +J/3WZr/2g1QS8xGHUIjhBbU0kfTTQYSUnXM97AAiehphZzYLHM4AuBYLEcE4h216 +UsPKEloyIFVR4+r0sAEYCUeIpyRMspzWjKLkvCuDUy3y5104HU0pglop5gHNVYhy +jnp08Hu8LPsJib1/HWVPeVgv/CF+2/sGpLLXZz7GVJgwy2eLc7rbQ7q/WaOmgO8y +r+J4qRdWqRdUOnZvMHLWwlQAzBmxePcCAwEAAaAAMA0GCSqGSIb3DQEBCwUAA4IB +AQBa8CzIRznPZBo2nNxRscBArKOcGoJw4GK5hjAeqnlXEgkUkPoDu7xyVi6W6zAY +XkApJ0gIHm3dPe7M/PWZV95yndD3VzzgyCD25/J2ITlDHEklBse6//giO0I2CdoF +xZVCGUsFdBloqL+z67dJB2BSzAa1m7jjSP9451/Mxi58rkJ/jB+UKF/gA5YCsBw0 +SPfLMojdWXFwfWw21reG7z4JGxe6w8CxqpLtqYvI4etO8Jm18j6OSd/KtIcOpSqw +pkAJcIUXyPG4HzWR4UGlm+mzWtfxcn40BiS2gfO+bvVOR12Wp6KBoc581mzKDEnS +ZkoE888GmvDy5Fxi7WHkq8eS +-----END CERTIFICATE REQUEST----- diff --git a/server_side/api/encryption/mycity.key b/server_side/api/encryption/mycity.key new file mode 100644 index 0000000..c81e8b4 --- /dev/null +++ b/server_side/api/encryption/mycity.key @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,7F4B0128759DB527 + +kPMg2ciG0ja/s8+wmk41ypIjI+F6lQdRfKxs4byXIeRiy+tPKtreD9AK53sDKv3L +pmWQ/qAoCZZLXmgZj5Wzk7yi1h5z5OdU7kBBNMUasReGtK003Zztfvk0rO5Taa0L +wmsHao53a/efTWj344Fq7YAqWbusYRnD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Y +9LX/IVKNCx6EZ70IPlYogUr3w7Wml/QvpXT7WKDCnJy/9qejANYLfON1t4y/5ZWs +jo0yWFUycXVEjUyANYzkgUDN1AOaRI6zTrWcR58cV3+pxjnQBQBtZBxJzYkUVJDG +gO/KWpSAoeRR1OdVbUlilzM+PquJPsUyhsiAOFq7jkblYEasF5vTA9OFx4Fka99b +iHc+FLHhpH1Glpg82PZEfO7A2Ef+P6mufm0jm1Q9tl3qGf3OiOgXQLqcFDXb0ggV +V5clnJ0HVqtPulUDQzzEW9F2NFuhSE0XyY5BhpXQ0GWAwxlVAGqRl4k/krk8cnK8 +O3+TfXoVnch1qS5X3gM/XKEu+UZnUtYtvDykFOCPeXQKCOKfra+fbw== +-----END RSA PRIVATE KEY----- diff --git a/server_side/api/encryption/mycity.pem b/server_side/api/encryption/mycity.pem new file mode 100644 index 0000000..d209a17 --- /dev/null +++ b/server_side/api/encryption/mycity.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDuTCCAqECFB4w/WXumGEKLcUlhWqZCNDVXtzgMA0GCSqGSIb3DQEBCwUAMIGY +MQswCQYDVQQGEwJUUjEPMA0GA1UECAwGQW5rYXJhMQ0wCwYDVQQHDARjaXR5MRAw +DgYDVQQKDAdUZWRSb2JvMRwwGgYDVQQLDBNSZXNlYXJjLURldmVsb3BtZW50MQ4w +DAYDVQQDDAVZaWdpdDEpMCcGCSqGSIb3DQEJARYaeWlnaXRjb2xha29nbHVAaG90 +bWFpbC5jb20wHhcNMTkwMzIzMjIxNzI4WhcNMjAwMzIyMjIxNzI4WjCBmDELMAkG +A1UEBhMCVFIxDzANBgNVBAgMBkFua2FyYTENMAsGA1UEBwwEY2l0eTEQMA4GA1UE +CgwHVGVkUm9ibzEcMBoGA1UECwwTUmVzZWFyYy1EZXZlbG9wbWVudDEOMAwGA1UE +AwwFWWlnaXQxKTAnBgkqhkiG9w0BCQEWGnlpZ2l0Y29sYWtvZ2x1QGhvdG1haWwu +Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoq3+G6YLhYXZK5Ay +5SJPdC2EzJZeVR5HQ8Was/KZblMdEsxBxGj6AYQcIR18AjmA9f6eH2iYzbNqSIjg +KAOpoayL+rctpIocgqsQfM/gSndmYh5yW0WVK3on/dZmv/aDVBLzEYdQiOEFtTSR +9NNBhJSdcz3sACJ6GmFnNgsczgC4FgsRwTiHbXpSw8oSWjIgVVHj6vSwARgJR4in +JEyynNaMouS8K4NTLfLnXTgdTSmCWinmAc1ViHKOenTwe7ws+wmJvX8dZU95WC/8 +IX7b+wakstdnPsZUmDDLZ4tzuttDur9Zo6aA7zKv4nipF1apF1Q6dm8wctbCVADM +GbF49wIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQB5qiPEzBlnxIIUmIVbSpQmhUl9 +PVNtgbtndsnqwZG9lZIO3zFUTQNUi/oD+ifA769GvybyRTaMqGOgC8sKythgetHB +UQcFdnq7rLTetVJX+N2LkxeL4yFmLBYceTaKkjHQEDyTflNJDcNMlOn4cekam058 +qLc4+dnoIryTuy+4RLQXtBGOtXqA8kxtQ3OTDnXtBpzojR1RIVMPxO4ES4tU7c3D +Pt3h5UZaKGr2I4PdMZ2f4KBieXKZqcbXcCcp/XuRqxcQBk6hM2U9IesZZGH2Q4yd +VQBFWd0u0Ghre2M8sFURjq6tfqdAkAV+XMTVjHwwtkCi061h8++56y47YAy3 +-----END CERTIFICATE----- diff --git a/server_side/api/login/__init__.py b/server_side/api/login/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server_side/api/login/__pycache__/__init__.cpython-37.pyc b/server_side/api/login/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0d4eb0bf03def46829c6b685d4b68284e3f7ca76 GIT binary patch literal 159 zcmZ?b<>g`kf+)MmF(CReh=2h`Aj1KOi&=m~3PUi1CZpd~vm6}{qtRI}4SX2`4o0ylFo|>DQSE65>T2z)=6knW~lB%Crkg1=OpPreg gA0MBYmst`YuUAlci^C>2KczG$)edCCXCP((00%56dH?_b literal 0 HcmV?d00001 diff --git a/server_side/api/login/__pycache__/login.cpython-37.pyc b/server_side/api/login/__pycache__/login.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b9c987d77651e4be1f22c7e7a88204e7638597c0 GIT binary patch literal 884 zcmYjP&2H2%5VoCUll|?sU7)Y9mkkeqPyqoFf=aXpP=sW;>)G8bNu1gVQde-=9=ITG zoZBN32P7mO##c_f0w=~vE7j3_V|(K9_s#h6aM&X_Ui|v@?l&dmk6YY~E=~^7%ufVK zB+W?DdYaH?%@T&5WnS(lejX$Nb#X82Rnf?KT%R4ZU zUD>_20QdDBLHma~x&s~O_!EkbjW+n(gTm?`)mF$8fp7iiW-v%$$GA-s<$Y!`B z&Yqx|J%oy^=_gvTk9132sqhdzntIy9nDvET8XJ^4Eh=Q~8^{*cL(<=g9^w!Gp2jPc zLwuetQ>o%ot2N9k6QATlSNxSI#1e8Ssu)##0L@J*Ar@sCXO2{hv+~^fr81RcV|)a{ zI&{-(c+Xtm2xUZ^7a|AFZIAO@$vSiM0q1A6$l8eB!J`eWTQG8a5yCE-ampjwtX;-j zqy^`jPD^AHUenry_h-$Qe%>d<>0TiVM^abQdzL9<{iYq^N|;rap4wpH+NoXows6B{ zgKO;VqRzBar2_{Y2V(^5iL!K%T3?k=V0uxlFtJJt+to@{yxE`&>t{+x>$_*rQXdE@ sUGD4mqU++8V%Hb#WZURLTd0Sw`Q`v2qWG~fo%qfl(1|yWB06IK0r&pkfB*mh literal 0 HcmV?d00001 diff --git a/server_side/api/login/login.py b/server_side/api/login/login.py new file mode 100644 index 0000000..7ca16de --- /dev/null +++ b/server_side/api/login/login.py @@ -0,0 +1,28 @@ +import os +import json +import hashlib + +from flask import Flask, request +from flask_restful import Resource, Api, abort + + + +app = Flask(__name__) +api = Api(app) + +with open(os.path.join(app.root_path, 'userdata.json'), 'r') as f: + data = json.load(f) + + +class Login( Resource ): + def post(self): + + req = request.args + print(req) + + + +if __name__ == '__main__': + api.add_resource(Login, '/login', '/login/') + + app.run(host='0.0.0.0', port=5000) \ No newline at end of file diff --git a/server_side/api/login/userdata.json b/server_side/api/login/userdata.json new file mode 100644 index 0000000..0e0dcd2 --- /dev/null +++ b/server_side/api/login/userdata.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/server_side/api/voting_system/__pycache__/voting_system.cpython-37.pyc b/server_side/api/voting_system/__pycache__/voting_system.cpython-37.pyc index 5f144a41515582f3130aaabb2e3c3c6fdb5a9b32..81618b12e8fa40101635de7bdb5d13b1f159ab7b 100644 GIT binary patch delta 137 zcmZpZ=$GJi;^pOH0D_Hf(_{8+VJ%_HVqd^f!kNXD!n%+tg{_&XU#yn7ggc98vN7jQDc)PmnRz8e e%s?B8G(m(AkhsNMTv9Zdkt>l=V{