Creating a Java or Python Project
You can select to create a Java or Python project when creating a secure computing application. Related code samples are available for download.
Due to its simplicity, cross-platform interoperability, and portability, in addition to its support for big data and microservices, the Java language has been chosen to develop a broad range of applications. To help port Java applications to the TEE, the confidential OS provides an environment for running Java applications.
Procedure
- Click
in the shortcut menu bar on the left pane or click
next to Development Assistant. The Kunpeng Application Projects page is displayed. See Figure 1. - Click Secure Computing Application. The Secure Computing Application page is displayed. See Figure 2.
- Click Java/Python Application. On the left pane of the displayed page, select Project creation for Task Type, select Java or Python for Project Type, select the required sample project, and configure other parameters as required. See Figure 3 and Figure 4.
- Click Next to configure the target node. You can use an existing server or add a new server. To add a server, enter the IP address, SSH port, user name, password, and storage directory. If you select Configure later, no SDKs will be deployed by default. See Figure 5.
- Determine whether to deploy the SDK. If you select Yes, select Online deployment, Offline deployment, or Configure later. See Figure 6.
If the secure computing SDK fails to be deployed, rectify the fault by following instructions in Failed to Deploy the Secure Computing Application SDK.
Table 1 Parameters for configuring a Java or Python project Parameter
Description
Task Type
Task type, which can be:
- Project creation
- Java/Python application reconstruction
Project Type
The options are:
- Java
- Python
Sample Project
Provided sample project, which can be:
- Hello World
- Titanic
NOTE:
- The Hello World sample project is available when you select Java for Project Type. It is a reference implementation of Java "Hello World" that is developed by using the high-level languages in Kunpeng BoostKit for Confidential Computing.
- The Titanic sample project is available when you select Python for Project Type. It is a reference implementation of Titanic survival data prediction using the Python machine learning library.
Project Name
The default project name is xxx_ProjectN, which can be modified as required.
Name of the Java or Python project to be created.
NOTE:The project name can contain 1 to 64 characters, including only letters, digits, periods (.), hyphens (-), plus signs (+), parentheses (), and underscores (_). It cannot start with a period (.).
Project Location
The default project location is C:\Users\username\KunpengProject, which can be modified as required.
Storage path of the Java or Python project to be created.
(Optional) Signature Private Key
Import the signature private key.
(Optional) Signature Certificate
Import the signature certificate.
Deploy Server
- Existing
- New
- Configure later
NOTE:The new server will be added to the target server management.
IP Address
IP address of the target node for subsequent operations.
SSH Port
SSH port number of the target node.
User Name
Account of the target node for subsequent operations.
Password
Password of the target node user.
Remember password
If you select this option, the password of the current server user will be remembered.
Storage Directory
Storage directory on the target node.
NOTE:The tool reads and writes the content in the storage directory. To avoid data loss, you are advised to use an empty directory.
Deploy SDK
Select an SDK deployment mode.
- Online deployment
- kunpeng-sc-devel
- kunpeng-sc
- Offline deployment
- kunpeng-sc-devel
- kunpeng-sc
- Configure later
NOTE:
- If you select Online deployment, the server must be connected to the Internet. In an isolated network environment, you need to use a proxy to access the Internet. For details, see Configuring a Proxy.
- If you select Offline deployment, the SDK is imported from the local host. Download the SDK to the local host and upload it.
- If you select Configure later, the SDK will not be deployed.
- Click Create. A dialog box is displayed, asking you to confirm whether TrustZone has been enabled. If it is enabled, select Enabled and click OK. See Figure 7.
- After the SDK deployment, deploy the Java or Python runtime environment.
- Deploying the Java runtime environment
- Decompress the file.
1tar -zxvf /user/local/kunpeng-sc/java/bisheng-jdk-8u372-tee-aarch64.tar.gz
- Copy the directory.
1cp -r /usr/local/kunpeng-sc/java/bisheng-jdk-8u372-tee-aarch64/jdk /usr/local/kunpeng-sc-devel/utils/pack-App
- Save the obtained certificate and its private key to the /usr/local/kunpeng-sc-devel/utils/pack-App/pack_tools directory and name them ta_cert.der and private_key.pem, respectively.
- Go to the pack-App directory and run the following command to generate the jdk.sec file:
1 2
cd /usr/local/kunpeng-sc-devel/utils/pack-App python3 pack.py jdk
- Install the Java environment in the TEE.
1tee_teleport -s jdk.sec -t java
- Decompress the file.
- Deploying the Python runtime environment
- Decompress the file.
1tar -zxvf /user/local/kunpeng-sc/python/Python-3.6.15-tee-aarch.tar.gz
- Copy the directory.
1cp -r /usr/local/kunpeng-sc/python/Python-3.6.15-tee-aarch64/python /usr/local/kunpeng-sc-devel/utils/pack-App
- Save the obtained certificate and its private key to the /usr/local/kunpeng-sc-devel/utils/pack-App/pack_tools directory and name them ta_cert.der and private_key.pem, respectively.
- Go to the pack-App directory and run the following command to generate the python.sec file:
1 2
cd /usr/local/kunpeng-sc-devel/utils/pack-App python3 pack.py python
- Install the Python environment in the TEE.
1tee_teleport -s python.sec -t python
You can run the tee_teleport command to install a third-party Java or Python library. For details about how to use tee_teleport, see Table 2.
Table 2 Parameter description Parameter
Description
Return Value
install (-s)
Installs the Java or Python runtime environment in the TEE.
If the installation is successful, 0 is returned. If the installation fails, -1 is returned.
uninstall (-u)
Uninstalls the Java or Python runtime environment in the TEE. This parameter must be used together with parameter type.
If the installation is successful, 0 is returned. If the installation fails, -1 is returned.
type (-t)
Installation type, which can be Java, Python, or Py3rd. This parameter must be used together with parameter -s.
-
import (-m)
Installs the Java or Python third-party library in the TEE.
If the installation is successful, 0 is returned. If the installation fails, -1 is returned.
create (-c)
Creates an application running directory and session ID in the TEE.
If the creation is successful, 0 is returned. If the creation fails, -1 is returned.
id (-i)
Session ID. This parameter must be specified when run, input, output, or destroy is used.
-
run (-r)
Runs the application. This parameter must be used together with parameter sessionID.
If the operation is successful, 0 is returned. If the operation fails, -1 is returned.
input (-n)
Inputs data to the TEE. This parameter can be used together with parameter -d (a relative path is required).
If the operation is successful, 0 is returned. If the operation fails, -1 is returned.
output (-o)
Outputs data from the TEE to the REE. This parameter can be used together with parameter -v.
If the operation is successful, 0 is returned. If the operation fails, -1 is returned.
destroy (-e)
Destroys the data, directory, and session ID of a Java or Python application. This parameter must be used together with parameter sessionID.
If the operation is successful, 0 is returned. If the operation fails, -1 is returned.
delete (-d)
Deletes a subfile or subdirectory of the application in the TEE.
If the operation is successful, 0 is returned. If the operation fails, -1 is returned.
query (-q)
Checks whether a subfile or subdirectory of the application exists in the TEE.
If the queried file or directory exists, 0 is returned. If it does not exist, 1 is returned. If the check fails, -1 is returned.
parameter (-p)
Parameters required for running the application.
-
rename (-a)
Specifies the path of the input file.
-
save (-v)
Specifies the path of the output file.
-
help (-h)
Obtains help information.
-
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13
tee_teleport -s jre.sec -t java # Installs Java. tee_teleport -s python.sec -t python # Installs Python. tee_teleport -u -t Java # Uninstalls Java. tee_teleport -u -t python # Uninstalls Python. tee_teleport -m third.sec -t python # Installs a third-party library. tee_teleport -c test.sec # Installs an application. A sessionID.txt file is generated in the current directory. tee_teleport -r TeeJava.class -i sessionID.txt # Runs an application. tee_teleport -n data_dir -i sessionID.txt # Inputs a file. tee_teleport -o data_dir -i sessionID.txt # Outputs a file. tee_teleport -e -i sessionID.txt # Uninstalls an application. tee_teleport -d output/tee.log -i sessionID.txt # Deletes a file. tee_teleport -q output/tee.log -i sessionID.txt # Queries a file. tee_teleport -c test.sec -r TeeJava.class -n data_dir -o output/tee.log -e # Performs installation, file input, execution, and uninstallation.
- Decompress the file.
- Deploying the Java runtime environment
- After the runtime environment is deployed and the Java or Python project is created, click Open Project to open it in the current window.Figure 10 Viewing the Java or Python Project
If a project folder or file is added, deleted, modified, or renamed, you can synchronize the change to the remote server. For details, see Synchronizing Code to a Remote Server.








