code: public static KeyChain configureKeyChain(Name deviceName) throws net.named_data.jndn.security.SecurityException {
          // access key chain in ~/.ndn; creates if necessary
          PrivateKeyStorage keyStorage = new FilePrivateKeyStorage();
          IdentityStorage identityStorage = new BasicIdentityStorage();
          KeyChain keyChain = new KeyChain(new IdentityManager(identityStorage, keyStorage),
                  new SelfVerifyPolicyManager(identityStorage));
  
          // create keys, certs if necessary
          if (!identityStorage.doesIdentityExist(deviceName)) {
              Name certificateName = keyChain.createIdentityAndCertificate(deviceName);
              Name keyName = IdentityCertificate.certificateNameToPublicKeyName(certificateName);
              keyChain.setDefaultKeyForIdentity(keyName);
          }
  
          // set default identity
          keyChain.getIdentityManager().setDefaultIdentity(deviceName);
  
          return keyChain;
      }
docs: Build and configure an NDN {@link KeyChain} from the file system; looks in the ~/.ndn folder for keys and
  identity SQLite DB.
  
  @param deviceName the identity of the device; this identity will be created if it does not exist
  @return a configured {@link KeyChain}
  @throws net.named_data.jndn.security.SecurityException if key chain creation fails