Discuss this help topic in SecureBlackbox Forum

Using Java classes in Java and Android applications

To use SecureBlackbox functionality in your Java/Android application, add the corresponding classes to the project. All necessary JAR files are located in <SecureBlackbox>\Classes\Java or <SecureBlackbox>\Classes\Android folders accordingly. The naming of Java JAR files in SecureBlackbox is the same as the naming of .NET assemblies. The naming of Java classes in SecureBlackbox is the same as the naming of .NET components and classes.

Be sure to include all indirectly used JAR files to your project, as described in "Deployment of Java classes" topic.

Java Native Interface

Java Native Interface (JNI) is used to let Java application access system-specific features such as Windows Crypto API and PKCS#11 drivers (DLLs).

JNI layer consists of the native libraries for Windows, Linux, MacOS and Android: sbbjni32.dll and sbbjni64.dll (for 32-bit and x64 systems respectively). JNI should be turned on if you need PKCS #11 or Win32 CryptoAPI / CNG support. CryptUI utility methods also require JNI.

JNI can be turned on using SecureBlackbox.Base.JNI.initialize() method. You can put both DLL/.so to java.library.path and call this method without parameters or pass a full path to a library as a parameter.

Java Cryptography Extensions

SecureBlackbox implementations of cryptographic algorithms can be used by Java application via the common Java Cryptography Extensions interface. See Using SecureBlackbox as Java Cryptography Extension topic for details.

Using Java classes

Method names in Java are the same as in VCL/.NET, however, the signatures may differ slightly, e.g.:

.NET:

		
TElSymmetricCrypto c = new TElSymmetricCrypto();
int OutSize = 100;
...
c.Encrypt(InBuffer, 0, InBuffer.Length, OutBuffer, 0, ref OutSize);
		
		

Java:

		
TElSymmetricCrypto c = new TElSymmetricCrypto();
int  OutSize  = c.Encrypt(InBuffer, 0, InBuffer.length, OutBuffer, 0, 100);
		
		

Java doesn't support properties, and the corresponding getter/setter methods must be used instead:

	
TElSimpleSSHClient ssh = new TElSimpleSSHClient();
ssh.SetAddress("test.com");
ssh.SetPort(22);
ssh.Open();
boolean isActive = ssh.GetActive();
	
	

Event handler example:

	
TElSimpleSFTPClient client = new TElSimpleSFTPClient();
TSSHKeyValidateEvent.Callback onKeyValidate = new TSSHKeyValidateEvent.Callback() {
    public boolean TSSHKeyValidateEventCallback(TObject sender, TElSSHKey serverKey) {
        System.out.println("Server key received");
        return true;
    }
}
client.SetOnKeyValidate(new TSSHKeyValidateEvent(onKeyValidate));

	
	

Discuss this help topic in SecureBlackbox Forum