Commit 694b0b1e authored by jonasled's avatar jonasled

Merge branch 'develop'

parents 36ceb4cf 41f6a001
......@@ -51,18 +51,18 @@ play {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.material:material:1.2.1'
implementation group: 'com.google.guava', name: 'guava', version: '29.0-android'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.jjoe64:graphview:4.2.2'
implementation "com.google.android.material:material:1.3.0-alpha02"
implementation "com.google.android.material:material:1.3.0-alpha03"
implementation 'commons-codec:commons-codec:1.14'
implementation 'de.taimos:totp:1.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.3.1'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
......
......@@ -20,8 +20,9 @@
<activity
android:name=".backupCreateActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".backupActivity"
android:theme="@style/AppTheme.NoActionBar"/>
<activity
android:name=".backupActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".debugActivity" />
<activity
android:name=".StorageControlActivity"
......
......@@ -21,18 +21,25 @@ public class DBHelper extends SQLiteOpenHelper {
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(
"create table servers " + //initialize the database on first start
"(id integer primary key, name text,url text,realm text, username text,password text, requiresTOTP boolean, totpToken text)"
"create table servers (id integer primary key, name text,url text,realm text, username text,password text, requiresTOTP boolean, totpToken text, loginType INTEGER DEFAULT 0 )"
);
}
public void appUpdate(){
SQLiteDatabase db = this.getWritableDatabase();
try{
db.execSQL("ALTER TABLE servers ADD COLUMN loginType INTEGER DEFAULT 0");
} catch (Exception e) {}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS servers");
onCreate(db);
}
public boolean insertServer (String name, String url, String realm, String username,String password, Boolean requiresTOTP, String totpToken) { //insert a new Server into the Database
public boolean insertServer (String name, String url, String realm, String username,String password, Boolean requiresTOTP, String totpToken, int loginType) { //insert a new Server into the Database
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("name", name);
......@@ -42,6 +49,7 @@ public class DBHelper extends SQLiteOpenHelper {
contentValues.put("password", password);
contentValues.put("requiresTOTP", requiresTOTP);
contentValues.put("totpToken", totpToken);
contentValues.put("loginType", loginType);
db.insert("servers", null, contentValues);
return true;
}
......@@ -68,7 +76,7 @@ public class DBHelper extends SQLiteOpenHelper {
res = db.rawQuery( "select * from servers", null );
res.moveToFirst();
while(res.isAfterLast() == false){
while(!res.isAfterLast()){
array_list.add(res.getInt(res.getColumnIndex("id")));
res.moveToNext();
}
......
......@@ -5,6 +5,8 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import androidx.preference.PreferenceManager;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.series.LineGraphSeries;
......@@ -98,6 +100,16 @@ public class HelperFunctions {
return TOTP.getOTP(hexKey);//caclculate the TOTP key and return it as String
}
public static int getFirstTimeRun(Context context) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
int result, currentVersionCode = BuildConfig.VERSION_CODE;
int lastVersionCode = sp.getInt("FIRSTTIMERUN", -1);
if (lastVersionCode == -1) result = 0; else
result = (lastVersionCode == currentVersionCode) ? 2 : 1;
sp.edit().putInt("FIRSTTIMERUN", currentVersionCode).apply();
return result;
}
public static void buildKeystore (){ //build the own keystore to verify selfSigned certificates
try {
hostnameVerifier = new HostnameVerifier() {
......
......@@ -9,6 +9,7 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.widget.*;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.appcompat.app.AppCompatActivity;
......@@ -16,12 +17,8 @@ import androidx.appcompat.widget.Toolbar;
import android.text.TextUtils;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -43,7 +40,11 @@ public class NewServer extends AppCompatActivity {
TextView inputPassword;
TextView inputTOTP;
TextView inputRealm;
TextView labelRealm;
TextView labelUsername;
TextView labelPassword;
CheckBox checkBoxRequiresTOTP;
Spinner spinnerLoginType;
de.jonasled.proxdroid.DBHelper mydb;
FloatingActionButton fab;
Button buttonTestLogin;
......@@ -67,8 +68,12 @@ public class NewServer extends AppCompatActivity {
inputPassword = findViewById(R.id.inputPassword);
buttonTestLogin = findViewById(R.id.buttonTestLogin);
checkBoxRequiresTOTP = findViewById(R.id.checkBoxTOTP);
labelRealm = findViewById(R.id.textViewRealm);
labelUsername = findViewById(R.id.textViewUsername);
labelPassword = findViewById(R.id.textViewPassword);
fab = findViewById(R.id.fab);
inputTOTP = findViewById(R.id.inputTOTP);
spinnerLoginType =findViewById(R.id.spinnerLoginType);
mydb = new de.jonasled.proxdroid.DBHelper(this);
databaseID = getIntent().getIntExtra("databaseID", -1);//try to get the databaseID from activityStart, if not found set it to -1
......@@ -80,6 +85,7 @@ public class NewServer extends AppCompatActivity {
dbEntry.moveToFirst();
try {
inputName.setText(dbEntry.getString(1));
spinnerLoginType.setSelection(dbEntry.getInt(8));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
inputURL.setText(HelperFunctions.decryptMsg(Base64.getDecoder().decode(dbEntry.getString(2))));
inputUser.setText(HelperFunctions.decryptMsg(Base64.getDecoder().decode(dbEntry.getString(4))));
......@@ -105,6 +111,42 @@ public class NewServer extends AppCompatActivity {
}
spinnerLoginType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int pos, long id) {
System.out.println("pos: " + pos + " id: " + id);
switch (pos){
case 0:
inputRealm.setVisibility(View.VISIBLE);
labelRealm.setVisibility(View.VISIBLE);
checkBoxRequiresTOTP.setVisibility(View.VISIBLE);
inputTOTP.setVisibility(View.VISIBLE);
labelUsername.setText(R.string.username);
inputUser.setHint(R.string.username);
labelPassword.setText(R.string.password);
inputPassword.setHint(R.string.password);
break;
case 1:
inputRealm.setVisibility(View.GONE);
labelRealm.setVisibility(View.GONE);
checkBoxRequiresTOTP.setVisibility(View.GONE);
inputTOTP.setVisibility(View.GONE);
labelUsername.setText(R.string.tokenID);
inputUser.setHint(R.string.tokenID);
labelPassword.setText(R.string.secret);
inputPassword.setHint(R.string.secret);
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
inputURL.setOnFocusChangeListener((View v, boolean hasFocus) ->{//on leave focus of the url input, replace https with HTTPS and add / at the end if missing (to fix some problems with android URL handling)
try {
if (!inputURL.getText().toString().substring(0, 4).toLowerCase().equals("http")) {
......@@ -182,13 +224,15 @@ public class NewServer extends AppCompatActivity {
String url = Base64.getEncoder().encodeToString(HelperFunctions.encryptMsg(inputURL.getText().toString()));
String username = Base64.getEncoder().encodeToString(HelperFunctions.encryptMsg(inputUser.getText().toString()));
String password = Base64.getEncoder().encodeToString(HelperFunctions.encryptMsg(inputPassword.getText().toString()));
mydb.insertServer(inputName.getText().toString(), url, inputRealm.getText().toString(), username, password, checkBoxRequiresTOTP.isChecked(), totpToken); //make the new Database entry
int loginType = spinnerLoginType.getSelectedItemPosition();
mydb.insertServer(inputName.getText().toString(), url, inputRealm.getText().toString(), username, password, checkBoxRequiresTOTP.isChecked(), totpToken, loginType); //make the new Database entry
} else {
totpToken = android.util.Base64.encodeToString(HelperFunctions.encryptMsg(totpToken), android.util.Base64.DEFAULT);
String url = android.util.Base64.encodeToString(HelperFunctions.encryptMsg(inputURL.getText().toString()), android.util.Base64.DEFAULT);
String username = android.util.Base64.encodeToString(HelperFunctions.encryptMsg(inputUser.getText().toString()), android.util.Base64.DEFAULT);
String password = android.util.Base64.encodeToString(HelperFunctions.encryptMsg(inputPassword.getText().toString()), android.util.Base64.DEFAULT);
mydb.insertServer(inputName.getText().toString(), url, inputRealm.getText().toString(), username, password, checkBoxRequiresTOTP.isChecked(), totpToken); //make the new Database entry
int loginType = spinnerLoginType.getSelectedItemPosition();
mydb.insertServer(inputName.getText().toString(), url, inputRealm.getText().toString(), username, password, checkBoxRequiresTOTP.isChecked(), totpToken, loginType); //make the new Database entry
}
} catch (Exception e) {
e.printStackTrace();}
......@@ -240,14 +284,18 @@ public class NewServer extends AppCompatActivity {
if(HelperFunctions.hostname.contains(":")){
HelperFunctions.hostname = HelperFunctions.hostname.split(":")[0];
}
String totpToken2 = "";
if(checkBoxRequiresTOTP.isChecked())totpToken2 = inputTOTP.getText().toString();
new testLogin().execute(inputURL.getText().toString(), "username=" + inputUser.getText().toString() + "@" + inputRealm.getText().toString() + "&password=" + inputPassword.getText().toString(), totpToken2);
new testLogin().execute();
});
}
private class testLogin extends AsyncTask<String, String, String> {
private ProgressDialog pd;
String baseurl;
String login;
String user;
String password;
String realm;
String totpToken = "";
int loginMethod;
@Override
protected void onPreExecute() {
......@@ -255,63 +303,87 @@ public class NewServer extends AppCompatActivity {
pd = ProgressDialog.show(NewServer.this, "", getResources().getString(R.string.login), true,
false); // Create and show Progress dialog
HelperFunctions.buildKeystore();
baseurl = inputURL.getText().toString();
user = inputUser.getText().toString();
realm = inputRealm.getText().toString();
password = inputPassword.getText().toString();
if(checkBoxRequiresTOTP.isChecked())totpToken = inputTOTP.getText().toString();
loginMethod = spinnerLoginType.getSelectedItemPosition();
}
@Override
protected String doInBackground(String... strings){
try{
URL url = new URL(strings[0] + "api2/json/access/ticket"); //prepare the URL
//open the connection and send POST data
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());//our custom SSL handler
conn.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn.setDoOutput(true);//enable write data to POST
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(strings[1]);//write the POST data
wr.flush();//flush the output buffer
//get the response from the server
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
// Append server response in string
sb.append(line + "\n");
}
JSONObject login = (JSONObject) (new JSONObject(sb.toString())).get("data");//Parse the response as JSON
String ticket = login.getString("ticket");//get the login ticket
String CSRFPreventionToken = login.getString("CSRFPreventionToken");//get the CSRFPreventionToken (needed for post requests)
if(sb.toString().contains("NeedTFA")){ //check if the account needs 2Fa authentication
url = new URL(strings[0] + "/api2/extjs/access/tfa");//if yes prepare the 2FA url
//open the connection and send POST data
conn = (HttpsURLConnection) url.openConnection();
conn.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());
conn.setRequestProperty("CSRFPreventionToken", CSRFPreventionToken);//send our token and ticket to authenticate
conn.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);
conn.setDoOutput(true);
wr = new OutputStreamWriter(conn.getOutputStream());//write the output
wr.write("response=" + HelperFunctions.totpGenerator(strings[2]));//generate the token with the helper function
wr.flush();
//get the response from the server
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
sb = new StringBuilder();
while ((line = reader.readLine()) != null) {
// Append server response in string
sb.append(line + "\n");
}
login = (JSONObject) (new JSONObject(sb.toString())).get("data");//parse the response json
ticket = login.getString("ticket"); //overwrite the ticket
switch(loginMethod) {
case 0:
URL url = new URL(baseurl + "api2/json/access/ticket"); //prepare the URL
//open the connection and send POST data
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());//our custom SSL handler
conn.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn.setDoOutput(true);//enable write data to POST
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write("username=" + inputUser.getText().toString() + "@" + inputRealm.getText().toString() + "&password=" + inputPassword.getText().toString());//write the POST data
wr.flush();//flush the output buffer
//get the response from the server
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
// Append server response in string
sb.append(line + "\n");
}
JSONObject login = (JSONObject) (new JSONObject(sb.toString())).get("data");//Parse the response as JSON
String ticket = login.getString("ticket");//get the login ticket
String CSRFPreventionToken = login.getString("CSRFPreventionToken");//get the CSRFPreventionToken (needed for post requests)
if (sb.toString().contains("NeedTFA")) { //check if the account needs 2Fa authentication
url = new URL(baseurl + "/api2/extjs/access/tfa");//if yes prepare the 2FA url
//open the connection and send POST data
conn = (HttpsURLConnection) url.openConnection();
conn.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());
conn.setRequestProperty("CSRFPreventionToken", CSRFPreventionToken);//send our token and ticket to authenticate
conn.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);
conn.setDoOutput(true);
wr = new OutputStreamWriter(conn.getOutputStream());//write the output
wr.write("response=" + HelperFunctions.totpGenerator(totpToken));//generate the token with the helper function
wr.flush();
//get the response from the server
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
sb = new StringBuilder();
while ((line = reader.readLine()) != null) {
// Append server response in string
sb.append(line + "\n");
}
login = (JSONObject) (new JSONObject(sb.toString())).get("data");//parse the response json
ticket = login.getString("ticket"); //overwrite the ticket
}
return ticket;
case 1:
url = new URL(baseurl + "api2/json/nodes");//parse the URL
HttpsURLConnection conn2 = (HttpsURLConnection) url.openConnection(); //open the URL with our custom SSL handler
conn2.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn2.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());
conn2.addRequestProperty("Authorization", "PVEAPIToken=" + user + "=" + password);
reader = new BufferedReader(new InputStreamReader(conn2.getInputStream()));//download and parse the Response
sb = new StringBuilder();
while ((line = reader.readLine()) != null) {
// Append server response in string
sb.append(line + "\n");
}
JSONArray nodesJSON = (JSONArray) (new JSONObject(sb.toString())).get("data");//parse the response as JSON
return "";
}
return ticket;
} catch (SSLHandshakeException e){//catch some errors
HelperFunctions.trustCert(NewServer.this, strings[0] + "/");//ask to trust the cert
HelperFunctions.trustCert(NewServer.this, baseurl + "/");//ask to trust the cert
return "failedSSL";
} catch (IOException e){
e.printStackTrace();
......@@ -322,6 +394,7 @@ public class NewServer extends AppCompatActivity {
}
return "";
}
......
......@@ -49,6 +49,8 @@ public class NodeControlActivity extends AppCompatActivity {
String type;
String name;
String CSRFPreventionToken;
String authString;
int loginMethod;
boolean showLoading = true;
Button consoleButton;
Button shutdownButton;
......@@ -119,12 +121,22 @@ public class NodeControlActivity extends AppCompatActivity {
squareNetworkIn.setBackgroundColor(networkInGraphSeries.getColor());
squareNetworkOut.setBackgroundColor(networkOutGraphSeries.getColor());
ticket = getIntent().getStringExtra("ticket");
loginMethod = getIntent().getIntExtra("loginMethod", 0);
switch (loginMethod){
case 0:
ticket = getIntent().getStringExtra("ticket");
CSRFPreventionToken = getIntent().getStringExtra("CSRFPreventionToken");
consoleButton.setVisibility(View.VISIBLE);
break;
case 1:
authString = getIntent().getStringExtra("authString");
consoleButton.setVisibility(View.GONE);
break;
}
id = getIntent().getStringExtra("id");
node = getIntent().getStringExtra("node");
urlString = getIntent().getStringExtra("url");
type = getIntent().getStringExtra("type");
CSRFPreventionToken = getIntent().getStringExtra("CSRFPreventionToken");
setTitle(node);
timer = new Timer();
......@@ -264,7 +276,14 @@ public class NodeControlActivity extends AppCompatActivity {
HttpsURLConnection conn2 = (HttpsURLConnection) url.openConnection();
conn2.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());
conn2.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);
switch (loginMethod){
case 0:
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);//set the auth cookie
break;
case 1:
conn2.addRequestProperty("Authorization", authString);
break;
}
BufferedReader reader = new BufferedReader(new InputStreamReader(conn2.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
......@@ -339,7 +358,15 @@ public class NodeControlActivity extends AppCompatActivity {
conn.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());
conn.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn.setRequestProperty("CSRFPreventionToken", CSRFPreventionToken);
conn.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);
switch (loginMethod){
case 0:
conn.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);//set the auth cookie
conn.setRequestProperty("CSRFPreventionToken", CSRFPreventionToken);
break;
case 1:
conn.addRequestProperty("Authorization", authString);
break;
}
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write("command=" + action);
......@@ -431,7 +458,14 @@ public class NodeControlActivity extends AppCompatActivity {
HttpsURLConnection conn2 = (HttpsURLConnection) url.openConnection();
conn2.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());
conn2.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);
switch (loginMethod){
case 0:
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);//set the auth cookie
break;
case 1:
conn2.addRequestProperty("Authorization", authString);
break;
}
BufferedReader reader = new BufferedReader(new InputStreamReader(conn2.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
......@@ -445,7 +479,14 @@ public class NodeControlActivity extends AppCompatActivity {
conn2 = (HttpsURLConnection) url.openConnection();
conn2.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());
conn2.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);
switch (loginMethod){
case 0:
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);//set the auth cookie
break;
case 1:
conn2.addRequestProperty("Authorization", authString);
break;
}
reader = new BufferedReader(new InputStreamReader(conn2.getInputStream()));
sb = new StringBuilder();
while ((line = reader.readLine()) != null) {
......@@ -498,7 +539,14 @@ public class NodeControlActivity extends AppCompatActivity {
conn2 = (HttpsURLConnection) url.openConnection();
conn2.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());
conn2.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);
switch (loginMethod){
case 0:
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);//set the auth cookie
break;
case 1:
conn2.addRequestProperty("Authorization", authString);
break;
}
reader = new BufferedReader(new InputStreamReader(conn2.getInputStream()));
sb = new StringBuilder();
while ((line = reader.readLine()) != null) {
......
......@@ -56,6 +56,8 @@ public class ServerControlActivity extends AppCompatActivity {
String type;
String name;
String CSRFPreventionToken;
String authString;
int loginMethod;
boolean showLoading = true;
Button consoleButton;
Button startButton;
......@@ -158,12 +160,22 @@ public class ServerControlActivity extends AppCompatActivity {
squareNetworkIn.setBackgroundColor(networkInGraphSeries.getColor());
squareNetworkOut.setBackgroundColor(networkOutGraphSeries.getColor());
ticket = getIntent().getStringExtra("ticket");
loginMethod = getIntent().getIntExtra("loginMethod", 0);
switch (loginMethod){
case 0:
ticket = getIntent().getStringExtra("ticket");
CSRFPreventionToken = getIntent().getStringExtra("CSRFPreventionToken");
consoleButton.setVisibility(View.VISIBLE);
break;
case 1:
authString = getIntent().getStringExtra("authString");
consoleButton.setVisibility(View.GONE);
break;
}
id = getIntent().getStringExtra("id");
node = getIntent().getStringExtra("node");
urlString = getIntent().getStringExtra("url");
type = getIntent().getStringExtra("type");
CSRFPreventionToken = getIntent().getStringExtra("CSRFPreventionToken");
setTitle(node + " - " + id);
......@@ -344,7 +356,14 @@ public class ServerControlActivity extends AppCompatActivity {
HttpsURLConnection conn2 = (HttpsURLConnection) url.openConnection();
conn2.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());
conn2.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);
switch (loginMethod){
case 0:
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);//set the auth cookie
break;
case 1:
conn2.addRequestProperty("Authorization", authString);
break;
}
BufferedReader reader = new BufferedReader(new InputStreamReader(conn2.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
......@@ -418,8 +437,15 @@ public class ServerControlActivity extends AppCompatActivity {
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());
conn.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn.setRequestProperty("CSRFPreventionToken", CSRFPreventionToken);
conn.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);
switch (loginMethod){
case 0:
conn.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);//set the auth cookie
conn.setRequestProperty("CSRFPreventionToken", CSRFPreventionToken);
break;
case 1:
conn.addRequestProperty("Authorization", authString);
break;
}
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write("");
......@@ -511,7 +537,14 @@ public class ServerControlActivity extends AppCompatActivity {
HttpsURLConnection conn2 = (HttpsURLConnection) url.openConnection();
conn2.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());
conn2.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);
switch (loginMethod){
case 0:
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);//set the auth cookie
break;
case 1:
conn2.addRequestProperty("Authorization", authString);
break;
}
BufferedReader reader = new BufferedReader(new InputStreamReader(conn2.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
......@@ -533,7 +566,14 @@ public class ServerControlActivity extends AppCompatActivity {
conn2 = (HttpsURLConnection) url.openConnection();
conn2.setSSLSocketFactory(HelperFunctions.context.getSocketFactory());
conn2.setHostnameVerifier(HelperFunctions.hostnameVerifier);
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);
switch (loginMethod){
case 0:
conn2.setRequestProperty("Cookie", "PVEAuthCookie=" + ticket);//set the auth cookie
break;