Integrate KEx/SHK functionality into JavaFileStorageTest-AS
-Re-organize SFTP Credentials dialog to be more space-efficient -Add KEX and SHK algorithm spec fields (these get used to build the SFTP URI when connecting) -Add CSV test fields/buttons for standalone testing of spec/config resolution
This commit is contained in:
@@ -690,6 +690,13 @@ public class MainActivity extends Activity implements JavaFileStorage.FileStorag
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void populateCsvMockValues(View view) {
|
||||||
|
EditText etSpecs = view.findViewById(R.id.mock_csv_specs);
|
||||||
|
etSpecs.setText("-bar,+first,-*d*");
|
||||||
|
EditText etCfgs = view.findViewById(R.id.mock_csv_cfg);
|
||||||
|
etCfgs.setText("foo,del1,bar,del2");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void performManualFileSelect(boolean isForSave, final int requestCode,
|
public void performManualFileSelect(boolean isForSave, final int requestCode,
|
||||||
String protocolId)
|
String protocolId)
|
||||||
@@ -699,6 +706,8 @@ public class MainActivity extends Activity implements JavaFileStorage.FileStorag
|
|||||||
final View view = getLayoutInflater().inflate(R.layout.sftp_credentials, null);
|
final View view = getLayoutInflater().inflate(R.layout.sftp_credentials, null);
|
||||||
final SftpStorage sftpStorage = (SftpStorage)storageToTest;
|
final SftpStorage sftpStorage = (SftpStorage)storageToTest;
|
||||||
|
|
||||||
|
populateCsvMockValues(view);
|
||||||
|
|
||||||
view.findViewById(R.id.send_public_key).setOnClickListener(v -> {
|
view.findViewById(R.id.send_public_key).setOnClickListener(v -> {
|
||||||
Intent sendIntent = new Intent();
|
Intent sendIntent = new Intent();
|
||||||
|
|
||||||
@@ -788,6 +797,21 @@ public class MainActivity extends Activity implements JavaFileStorage.FileStorag
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
view.findViewById(R.id.resolve_mock_csv).setOnClickListener(v -> {
|
||||||
|
EditText etSpecs = view.findViewById(R.id.mock_csv_specs);
|
||||||
|
String specs = etSpecs.getText().toString();
|
||||||
|
EditText etCfg = view.findViewById(R.id.mock_csv_cfg);
|
||||||
|
String cfg = etCfg.getText().toString();
|
||||||
|
if (!specs.isBlank() && !cfg.isBlank()) {
|
||||||
|
String result = sftpStorage.resolveCsvValues(cfg, specs);
|
||||||
|
Toast.makeText(this, result, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
view.findViewById(R.id.reset_mock_csv).setOnClickListener(v -> {
|
||||||
|
populateCsvMockValues(view);
|
||||||
|
});
|
||||||
|
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setView(view)
|
.setView(view)
|
||||||
.setTitle("Enter SFTP credentials")
|
.setTitle("Enter SFTP credentials")
|
||||||
@@ -823,11 +847,14 @@ public class MainActivity extends Activity implements JavaFileStorage.FileStorag
|
|||||||
String keyName = etKeyName.getText().toString();
|
String keyName = etKeyName.getText().toString();
|
||||||
EditText etKeyPassphrase = view.findViewById(R.id.private_key_passphrase);
|
EditText etKeyPassphrase = view.findViewById(R.id.private_key_passphrase);
|
||||||
String keyPassphrase = etKeyPassphrase.getText().toString();
|
String keyPassphrase = etKeyPassphrase.getText().toString();
|
||||||
|
EditText etKex = view.findViewById(R.id.kex);
|
||||||
|
String kex = etKex.getText().toString();
|
||||||
|
EditText etShk = view.findViewById(R.id.shk);
|
||||||
|
String shk = etShk.getText().toString();
|
||||||
|
|
||||||
// TODO: Add kex and shk configurability to SFTP dialog
|
|
||||||
onReceivePathForFileSelect(requestCode, sftpStorage1.buildFullPath(
|
onReceivePathForFileSelect(requestCode, sftpStorage1.buildFullPath(
|
||||||
host, port, initialDir, user, pwd, connectTimeout,
|
host, port, initialDir, user, pwd, connectTimeout,
|
||||||
keyName, keyPassphrase, null, null));
|
keyName, keyPassphrase, kex, shk));
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,133 +3,217 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_margin="12dip"
|
android:layout_margin="12dip">
|
||||||
>
|
<LinearLayout
|
||||||
<LinearLayout
|
android:orientation="horizontal"
|
||||||
android:orientation="horizontal"
|
android:layout_width="fill_parent"
|
||||||
android:layout_width="fill_parent"
|
android:layout_height="wrap_content">
|
||||||
android:layout_height="wrap_content">
|
<EditText
|
||||||
<EditText
|
|
||||||
android:id="@+id/sftp_host"
|
android:id="@+id/sftp_host"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="10"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:inputType="textNoSuggestions"
|
android:inputType="textNoSuggestions"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:hint="@string/hint_sftp_host" />
|
android:hint="@string/hint_sftp_host" />
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/portsep"
|
android:id="@+id/portsep"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text=":" />
|
android:text=":" />
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/sftp_port"
|
android:id="@+id/sftp_port"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="4"
|
android:layout_weight="15"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
android:text="22"
|
android:text="22"
|
||||||
android:hint="@string/hint_sftp_port" />
|
android:hint="@string/hint_sftp_port" />
|
||||||
</LinearLayout>
|
<EditText
|
||||||
<EditText
|
android:id="@+id/sftp_connect_timeout"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="14"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:inputType="number"
|
||||||
|
android:text=""
|
||||||
|
android:hint="@string/hint_sftp_connect_timeout" />
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<EditText
|
||||||
android:id="@+id/sftp_user"
|
android:id="@+id/sftp_user"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:hint="@string/hint_username" />
|
android:hint="@string/hint_username" />
|
||||||
|
<EditText
|
||||||
<EditText
|
|
||||||
android:id="@+id/sftp_password"
|
android:id="@+id/sftp_password"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:hint="@string/hint_pass"
|
android:hint="@string/hint_pass"
|
||||||
android:importantForAccessibility="no" />
|
android:importantForAccessibility="no" />
|
||||||
|
</LinearLayout>
|
||||||
<TextView android:id="@+id/initial_dir"
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView android:id="@+id/initial_dir"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="4dip"
|
android:layout_marginLeft="4dip"
|
||||||
android:layout_marginTop="4dip"
|
android:layout_marginTop="4dip"
|
||||||
|
|
||||||
android:text="@string/initial_directory" />
|
android:text="@string/initial_directory" />
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/sftp_initial_dir"
|
android:id="@+id/sftp_initial_dir"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="8dip"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="/home/philipp"
|
android:text="/home/philipp"
|
||||||
/>
|
/>
|
||||||
<EditText
|
</LinearLayout>
|
||||||
android:id="@+id/sftp_connect_timeout"
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:orientation="horizontal"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="fill_parent"
|
||||||
android:singleLine="true"
|
android:layout_height="wrap_content">
|
||||||
android:inputType="number"
|
<EditText android:id="@+id/kex"
|
||||||
android:text=""
|
android:layout_width="fill_parent"
|
||||||
android:hint="@string/hint_sftp_connect_timeout" />
|
android:layout_height="wrap_content"
|
||||||
<Button android:id="@+id/send_public_key"
|
android:layout_weight="1"
|
||||||
android:layout_width="fill_parent"
|
android:singleLine="true"
|
||||||
android:layout_height="wrap_content"
|
android:inputType="textNoSuggestions"
|
||||||
android:text="send public key" />
|
android:text=""
|
||||||
<TextView
|
android:hint="KEX Algs" />
|
||||||
android:layout_width="fill_parent"
|
<EditText android:id="@+id/shk"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="fill_parent"
|
||||||
android:gravity="center_horizontal"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_weight="1"
|
||||||
android:textStyle="bold"
|
android:singleLine="true"
|
||||||
android:text="Private Keys Functions" />
|
android:inputType="textNoSuggestions"
|
||||||
|
android:text=""
|
||||||
<LinearLayout
|
android:hint="Server Host Key Algs" />
|
||||||
android:orientation="horizontal"
|
</LinearLayout>
|
||||||
android:layout_width="fill_parent"
|
<Button android:id="@+id/send_public_key"
|
||||||
android:layout_height="wrap_content">
|
android:layout_width="fill_parent"
|
||||||
<Button android:id="@+id/list_private_keys"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent"
|
android:text="send public key" />
|
||||||
android:layout_height="wrap_content"
|
<TextView
|
||||||
android:layout_weight="1"
|
android:layout_width="fill_parent"
|
||||||
android:text="List" />
|
android:layout_height="wrap_content"
|
||||||
<Button android:id="@+id/add_private_key"
|
android:gravity="center_horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_marginTop="15dp"
|
||||||
android:layout_height="wrap_content"
|
android:textStyle="bold"
|
||||||
android:layout_weight="1"
|
android:text="Private Keys Functions" />
|
||||||
android:text="Add" />
|
<LinearLayout
|
||||||
<Button android:id="@+id/delete_private_key"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:layout_weight="1"
|
<Button android:id="@+id/list_private_keys"
|
||||||
android:text="Delete" />
|
android:layout_width="fill_parent"
|
||||||
<Button android:id="@+id/validate_private_key"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent"
|
android:layout_weight="1"
|
||||||
android:layout_height="wrap_content"
|
android:text="List" />
|
||||||
android:layout_weight="1"
|
<Button android:id="@+id/add_private_key"
|
||||||
android:text="Validate" />
|
android:layout_width="fill_parent"
|
||||||
</LinearLayout>
|
android:layout_height="wrap_content"
|
||||||
<EditText android:id="@+id/private_key_name"
|
android:layout_weight="1"
|
||||||
android:layout_width="fill_parent"
|
android:text="Add" />
|
||||||
android:layout_height="wrap_content"
|
<Button android:id="@+id/delete_private_key"
|
||||||
android:singleLine="true"
|
android:layout_width="fill_parent"
|
||||||
android:inputType="textNoSuggestions"
|
android:layout_height="wrap_content"
|
||||||
android:text=""
|
android:layout_weight="1"
|
||||||
android:hint="key name" />
|
android:text="Delete" />
|
||||||
<EditText android:id="@+id/private_key_content"
|
<Button android:id="@+id/validate_private_key"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="textMultiLine"
|
android:layout_weight="1"
|
||||||
android:lines="5"
|
android:text="Validate" />
|
||||||
android:text=""
|
</LinearLayout>
|
||||||
android:hint="key content" />
|
<LinearLayout
|
||||||
<EditText android:id="@+id/private_key_passphrase"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:singleLine="true"
|
<EditText android:id="@+id/private_key_name"
|
||||||
android:inputType="textNoSuggestions"
|
android:layout_width="fill_parent"
|
||||||
android:text=""
|
android:layout_height="wrap_content"
|
||||||
android:hint="key passphrase (optional)" />
|
android:layout_weight="1"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:inputType="textNoSuggestions"
|
||||||
|
android:text=""
|
||||||
|
android:hint="key name" />
|
||||||
|
<EditText android:id="@+id/private_key_passphrase"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:inputType="textNoSuggestions"
|
||||||
|
android:text=""
|
||||||
|
android:hint="passphrase (optional)" />
|
||||||
|
</LinearLayout>
|
||||||
|
<EditText android:id="@+id/private_key_content"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textMultiLine"
|
||||||
|
android:lines="4"
|
||||||
|
android:text=""
|
||||||
|
android:hint="key content" />
|
||||||
|
<TextView
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="CSV Resolver Functions" />
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<EditText android:id="@+id/mock_csv_specs"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:inputType="textNoSuggestions"
|
||||||
|
android:text=""
|
||||||
|
android:hint="Test specs" />
|
||||||
|
<EditText android:id="@+id/mock_csv_cfg"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:inputType="textNoSuggestions"
|
||||||
|
android:text=""
|
||||||
|
android:hint="Test config" />
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<Button android:id="@+id/reset_mock_csv"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginLeft="50dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:text="Reset" />
|
||||||
|
<Button android:id="@+id/resolve_mock_csv"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginRight="50dp"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:text="Resolve" />
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -333,7 +333,7 @@
|
|||||||
|
|
||||||
<string name="hint_sftp_host">host</string>
|
<string name="hint_sftp_host">host</string>
|
||||||
<string name="hint_sftp_port">port</string>
|
<string name="hint_sftp_port">port</string>
|
||||||
<string name="hint_sftp_connect_timeout">connection timeout seconds</string>
|
<string name="hint_sftp_connect_timeout">timeout sec</string>
|
||||||
|
|
||||||
<string name="select_storage_type">Select the storage type:</string>
|
<string name="select_storage_type">Select the storage type:</string>
|
||||||
|
|
||||||
@@ -525,6 +525,6 @@ Initial public release
|
|||||||
<item>Do not accept invalid certificates</item>
|
<item>Do not accept invalid certificates</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string name="initial_directory">Initial directory (optional):</string>
|
<string name="initial_directory">Initial dir (optional):</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user