<commit_before>package vaov.client.account;

import java.security.PublicKey;

import vaov.client.service.ServiceFactory;
import vaov.client.util.Config;
import vaov.client.util.KeyException;
import vaov.client.util.KeystoreService;
import vaov.client.util.PublicKeyConverter;
import vaov.remote.account.to.AccountTO;
import vaov.remote.account.to.PublicKeyTO;
import vaov.remote.services.KeyId;
import vaov.remote.services.VaovAccountService;

public abstract class PublishedAccountsService {

	/**
	 * Loads Key from Database
	 */
	public static PublicKey getKey(KeyId keyId) throws KeyException {
		if (!hasKey(keyId)) {
			getAccountFromServer(keyId);
		}
		return KeystoreService.loadKeyPair(keyId, Config.getPublicKeyPassword()).getPublic();
	}

	private static void getAccountFromServer(KeyId keyId) throws KeyException {
		VaovAccountService accountService = ServiceFactory.getAccountService();
		AccountTO accountTO = accountService.getAccount(keyId);
		if (!keyId.equals(accountTO.getHash())) {
			throw new KeyException("Hash from server does not match");
		}
		PublicKeyTO publicKeyTO = accountTO.getPublicKey();
		PublicKey publicKey = PublicKeyConverter.readPublicKey(publicKeyTO.getModulus(), publicKeyTO.getExponent());
		KeystoreService.storePublicKey(keyId, publicKey);
	}

	/**
	 * checks if the database has a valid entry for the hash
	 */
	private static boolean hasKey(KeyId keyId) {
		return KeystoreService.loadPublicKey(keyId).isPresent();
	}
}
<commit_msg>fixed comparison between keyId and String<commit_after>package vaov.client.account;

import java.security.PublicKey;

import vaov.client.service.ServiceFactory;
import vaov.client.util.Config;
import vaov.client.util.KeyException;
import vaov.client.util.KeystoreService;
import vaov.client.util.PublicKeyConverter;
import vaov.remote.account.to.AccountTO;
import vaov.remote.account.to.PublicKeyTO;
import vaov.remote.services.KeyId;
import vaov.remote.services.VaovAccountService;

public abstract class PublishedAccountsService {

	/**
	 * Loads Key from Database
	 */
	public static PublicKey getKey(KeyId keyId) throws KeyException {
		if (!hasKey(keyId)) {
			getAccountFromServer(keyId);
		}
		return KeystoreService.loadKeyPair(keyId, Config.getPublicKeyPassword()).getPublic();
	}

	private static void getAccountFromServer(KeyId keyId) throws KeyException {
		VaovAccountService accountService = ServiceFactory.getAccountService();
		AccountTO accountTO = accountService.getAccount(keyId);
		if (!keyId.equals(new KeyId(accountTO.getHash()))) {
			throw new KeyException("Hash from server does not match");
		}
		PublicKeyTO publicKeyTO = accountTO.getPublicKey();
		PublicKey publicKey = PublicKeyConverter.readPublicKey(publicKeyTO.getModulus(), publicKeyTO.getExponent());
		KeystoreService.storePublicKey(keyId, publicKey);
	}

	/**
	 * checks if the database has a valid entry for the hash
	 */
	private static boolean hasKey(KeyId keyId) {
		return KeystoreService.loadPublicKey(keyId).isPresent();
	}
}

{'fraction_non_alphanumeric': 0.09996667777407531, 'fraction_numerical': 0.0, 'mean_word_length': 5.838268792710706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2146144', 'n_tokens_mistral': 946, 'n_tokens_neox': 889, 'n_words': 192}