Commit a551d6cf authored by Nastuzzi Samy's avatar Nastuzzi Samy
Browse files

Session preparation

parent d04a2180
......@@ -14,6 +14,8 @@ import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.io.IOException;
import fr.utc.simde.payutc.tools.NFCActivity;
import fr.utc.simde.payutc.tools.CASConnexion;
import fr.utc.simde.payutc.tools.Dialog;
......@@ -102,11 +104,15 @@ public class MainActivity extends NFCActivity {
public void run() {
loading.dismiss();
if (!casConnexion.isServiceAdded()) {
dialog.errorDialog(getResources().getString(R.string.cas_connection), getResources().getString(R.string.cas_error_service_adding));
if (casConnexion.isServiceAdded()) {
try {
nemopaySession.loginCas(casConnexion.getTicket(), casConnexion.getService());
} catch (IOException e) {
e.printStackTrace();
}
}
else
Toast.makeText(MainActivity.this, "Connexion à réaliser avec Nemopay", Toast.LENGTH_SHORT).show(); // https://api.nemopay.net/services/POSS3/loginCas2?system_id=payutc
dialog.errorDialog(getResources().getString(R.string.cas_connection), getResources().getString(R.string.cas_error_service_adding));
}
});
}
......
......@@ -36,6 +36,10 @@ public class CASConnexion {
public void setUsername(final String username) { this.username = username; }
public String getUsername() { return this.username; }
public String getTicket() { return this.ticket; }
public String getService() { return this.service; }
public String getUrl() { return this.url; }
public void connect(final String username, final String password) throws Exception {
......
......@@ -107,6 +107,7 @@ public class HTTPRequest {
in.close();
this.response = builder.toString();
Log.d(LOG_TAG, this.response);
}
public String getResponse() throws IOException { return response; }
......
......@@ -41,6 +41,7 @@ public class NemopaySession {
public HTTPRequest construct(final String method, final String service) throws IOException { return construct(method, service, new HashMap<String, String>()); }
public HTTPRequest construct(final String method, final String service, final Map<String, String> args) throws IOException {
HTTPRequest request = new HTTPRequest(url + method + "/" + service);
Log.d(LOG_TAG, "url: " + url + method + "/" + service);
request.setArgs(defaultArgs);
for (String arg : args.keySet())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment