org.ejbca.core.ejb.hardtoken.HardTokenData htd = org.ejbca.core.ejb.hardtoken.HardTokenData.findByTokenSN(entityManager, tokensn);
if (htd == null) {
String msg = intres.getLocalizedMessage("hardtoken.errorremovetoken", tokensn);
logSession.log(admin, caid, LogConstants.MODULE_HARDTOKEN, new java.util.Date(), null, null, LogConstants.EVENT_ERROR_HARDTOKENDATA, msg);
throw new HardTokenDoesntExistsException("Tokensn : " + tokensn);
}
caid = htd.getSignificantIssuerDN().hashCode();
entityManager.remove(htd);
// Remove all certificate mappings.
removeHardTokenCertificateMappings(admin, tokensn);