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();
|
||||
}
|
||||
|
||||
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
|
||||
public void performManualFileSelect(boolean isForSave, final int requestCode,
|
||||
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 SftpStorage sftpStorage = (SftpStorage)storageToTest;
|
||||
|
||||
populateCsvMockValues(view);
|
||||
|
||||
view.findViewById(R.id.send_public_key).setOnClickListener(v -> {
|
||||
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)
|
||||
.setView(view)
|
||||
.setTitle("Enter SFTP credentials")
|
||||
@@ -823,11 +847,14 @@ public class MainActivity extends Activity implements JavaFileStorage.FileStorag
|
||||
String keyName = etKeyName.getText().toString();
|
||||
EditText etKeyPassphrase = view.findViewById(R.id.private_key_passphrase);
|
||||
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(
|
||||
host, port, initialDir, user, pwd, connectTimeout,
|
||||
keyName, keyPassphrase, null, null));
|
||||
keyName, keyPassphrase, kex, shk));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -3,133 +3,217 @@
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_margin="12dip"
|
||||
>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<EditText
|
||||
android:layout_margin="12dip">
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<EditText
|
||||
android:id="@+id/sftp_host"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_weight="10"
|
||||
android:singleLine="true"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:text=""
|
||||
android:hint="@string/hint_sftp_host" />
|
||||
<TextView
|
||||
android:hint="@string/hint_sftp_host" />
|
||||
<TextView
|
||||
android:id="@+id/portsep"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=":" />
|
||||
<EditText
|
||||
<EditText
|
||||
android:id="@+id/sftp_port"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="4"
|
||||
android:layout_weight="15"
|
||||
android:singleLine="true"
|
||||
android:inputType="number"
|
||||
android:text="22"
|
||||
android:hint="@string/hint_sftp_port" />
|
||||
</LinearLayout>
|
||||
<EditText
|
||||
android:inputType="number"
|
||||
android:text="22"
|
||||
android:hint="@string/hint_sftp_port" />
|
||||
<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:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:singleLine="true"
|
||||
android:text=""
|
||||
android:hint="@string/hint_username" />
|
||||
|
||||
<EditText
|
||||
android:hint="@string/hint_username" />
|
||||
<EditText
|
||||
android:id="@+id/sftp_password"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:text=""
|
||||
android:hint="@string/hint_pass"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<TextView android:id="@+id/initial_dir"
|
||||
android:hint="@string/hint_pass"
|
||||
android:importantForAccessibility="no" />
|
||||
</LinearLayout>
|
||||
<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_height="wrap_content"
|
||||
android:layout_marginLeft="4dip"
|
||||
android:layout_marginTop="4dip"
|
||||
|
||||
android:text="@string/initial_directory" />
|
||||
<EditText
|
||||
<EditText
|
||||
android:id="@+id/sftp_initial_dir"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dip"
|
||||
android:singleLine="true"
|
||||
android:text="/home/philipp"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/sftp_connect_timeout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:inputType="number"
|
||||
android:text=""
|
||||
android:hint="@string/hint_sftp_connect_timeout" />
|
||||
<Button android:id="@+id/send_public_key"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="send public key" />
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_marginTop="20dp"
|
||||
android:textStyle="bold"
|
||||
android:text="Private Keys Functions" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<Button android:id="@+id/list_private_keys"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="List" />
|
||||
<Button android:id="@+id/add_private_key"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Add" />
|
||||
<Button android:id="@+id/delete_private_key"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Delete" />
|
||||
<Button android:id="@+id/validate_private_key"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Validate" />
|
||||
</LinearLayout>
|
||||
<EditText android:id="@+id/private_key_name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:text=""
|
||||
android:hint="key name" />
|
||||
<EditText android:id="@+id/private_key_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textMultiLine"
|
||||
android:lines="5"
|
||||
android:text=""
|
||||
android:hint="key content" />
|
||||
<EditText android:id="@+id/private_key_passphrase"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:text=""
|
||||
android:hint="key passphrase (optional)" />
|
||||
|
||||
android:text="/home/philipp"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<EditText android:id="@+id/kex"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:singleLine="true"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:text=""
|
||||
android:hint="KEX Algs" />
|
||||
<EditText android:id="@+id/shk"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:singleLine="true"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:text=""
|
||||
android:hint="Server Host Key Algs" />
|
||||
</LinearLayout>
|
||||
<Button android:id="@+id/send_public_key"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="send public key" />
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_marginTop="15dp"
|
||||
android:textStyle="bold"
|
||||
android:text="Private Keys Functions" />
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<Button android:id="@+id/list_private_keys"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="List" />
|
||||
<Button android:id="@+id/add_private_key"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Add" />
|
||||
<Button android:id="@+id/delete_private_key"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Delete" />
|
||||
<Button android:id="@+id/validate_private_key"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Validate" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<EditText android:id="@+id/private_key_name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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>
|
||||
@@ -333,7 +333,7 @@
|
||||
|
||||
<string name="hint_sftp_host">host</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>
|
||||
|
||||
@@ -525,6 +525,6 @@ Initial public release
|
||||
<item>Do not accept invalid certificates</item>
|
||||
</string-array>
|
||||
|
||||
<string name="initial_directory">Initial directory (optional):</string>
|
||||
<string name="initial_directory">Initial dir (optional):</string>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user