Example code, illustrating the usage of the Secure App ROM
  • 26 Dec 2024
  • 1 Minute à lire
  • Sombre
    Lumière
  • PDF

Example code, illustrating the usage of the Secure App ROM

  • Sombre
    Lumière
  • PDF

The content is currently unavailable in French. You are viewing the default English version.
Résumé de l’article

The example shows a class SARExample which provides some API to load data from the Secure App ROM for a single fixed key.

Function retrieving data from the Secure App ROM.

package com.example.sar;

import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import android.content.Context;
import no.promon.shield.storage.rom.SecureAppRom;

public class SARExample {
  private static final String KEY = "secret/Text";

  String getSecretText(Context context) throws IOException {
    InputStream is = SecureAppRom.getInstance(context).open(KEY);
    
    // Read the stream
    StringBuilder text = new StringBuilder();
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    String line;
    while ((line = reader.readLine()) != null) {
      text.append(line);
    }
    return text.toString();
  }
}

The function calls SecureAppRom.getInstance() to get a SecureAppRom instance and then opens an InputStream for the file assets/sarom/secret/Text by calling SecureAppRom.open("secret/Text") and finally reads the content from the input stream as a text file.


Cet article vous a-t-il été utile ?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Ozzy, facilitant la découverte de connaissances grâce à l’intelligence conversationnelle