To work with a digital signature, create the DssActivity application, which uses the methods implemented in the DssAPI unit.
Before creating the DssActivity application:
Set up digital signature:
Client DSS identifier: 1C996E7F-CC4C-4DFA-B3A3-5BDB5AF6028F.
DSS server URL: dss.cryptopro.ru.
Port: 80.
Protocol: HTTP.
Connection timeout: 30.
For the API user "ilm" set DSS login as "saprun".
The DssActivity application includes one screen, text input area and buttons:
GetCertificatesDss. Get a list of available certificates.
CreateSignDss. Cell signature.
GetSignatureListDss. Get a list of signed cells.
SignatureDeleteDss. Delete cell signature.
NOTE. Before clicking the button enter the 2 signature identifier into the text input area.
The text input area contains cell signature identifier.
To view application work results, use the interactive example:
Click the GetCertificatesDss button.
public class DssActivity extends AppCompatActivity {
private static final String MY_URL = "http://testmasterfmp.fsight.cloud/";
private static final VersionAPI MY_VERSION_API = VersionAPI.V_1;
private static final String MY_ENVIRONMENT = "Leonid_environment";
private static final String MY_PROJECT = "Leonid_project";
private static final String MY_VERSION = "v1";
private static final String MY_LOGIN = "Leonid";
private static final String MY_PASSWORD = "123123";
private static final String MY_RESOURCE = "GetBudgetPlanning";
public static final String MY_TABLE = "BudgetPlanning";
private static final String TAG = "TableStreamActivity";
public static final String DSS_PASSWORD = "Saprun123";
public static final String DSS_CERTIFICATE_ID = "12831";
public static final String DSS_CERTIFICATE_PIN = "123";
private HyperHive hyperHive;
private TextView textView;
private EditText editText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dss);
textView = findViewById(R.id.text_view_dss);
editText = findViewById(R.id.edit_text_dss);
editText.setText("1");
Handler uiHandler = new Handler();
hyperHive = new HyperHiveState(getApplicationContext())
.setHostWithSchema(MY_URL)
.setApiVersion(MY_VERSION_API)
.setEnvironmentSlug(MY_ENVIRONMENT)
.setProjectSlug(MY_PROJECT)
.setVersionProject(MY_VERSION)
.setHandler(uiHandler)
.buildHyperHive();
authentication();
}
public void authentication() {
boolean status = hyperHive.authAPI.auth(MY_LOGIN, MY_PASSWORD, true).execute().isOk();
showStatus(status);
}
public void showStatus(boolean status) {
Log.d(TAG, "auth: " + status);
Toast.makeText(this, "auth: " + status, Toast.LENGTH_LONG).show();
}
// Get list of available certificates
public void getCertificatesDss(View view){
String status = hyperHive.dssAPI
.certificates(DSS_PASSWORD)
.execute();
textView.setText(status);
}
// Sign cell
public void createSignDss(View view){
String status = hyperHive.dssAPI.sign(MY_RESOURCE,
MY_TABLE,
"{}",
"Number",
"1",
DSS_PASSWORD,
DSS_CERTIFICATE_ID,
DSS_CERTIFICATE_PIN).execute();
textView.setText(status);
}
// Get signatures list
public void getSignatureListDss(View view){
String status = hyperHive.dssAPI.signs().execute();
textView.setText(status);
}
// Delete signature
public void signatureDeleteDss(View view){
long id = Long.parseLong(editText.getText().toString());
String status = hyperHive.dssAPI.remove(id).execute();
textView.setText(status);
}
}
See also: