Updated how the platform certificate is accessed

This commit is contained in:
Cyrus 2024-03-18 14:57:05 -04:00
parent e0de63aa03
commit 32b10260fd
3 changed files with 10 additions and 8 deletions

View File

@ -25,7 +25,6 @@ public interface CertificateRepository extends JpaRepository<Certificate, UUID>
List<Certificate> findByType(String dType);
@Query(value = "SELECT * FROM Certificate where serialNumber = ?1 AND DTYPE = ?2", nativeQuery = true)
Certificate findBySerialNumber(BigInteger serialNumber, String dType);
Certificate findByPlatformSerialAndSerialNumber(String platformSerial, BigInteger serialNumber);
@Query(value = "SELECT * FROM Certificate where platformSerial = ?1 AND DTYPE = 'PlatformCredential'", nativeQuery = true)
List<PlatformCredential> byBoardSerialNumber(String boardSerialNumber);
@Query(value = "SELECT * FROM Certificate where holderSerialNumber = ?1 AND DTYPE = 'PlatformCredential'", nativeQuery = true)

View File

@ -6,6 +6,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.math.BigInteger;
import java.util.List;
import java.util.UUID;
@ -15,4 +16,5 @@ public interface PlatformCertificateRepository extends JpaRepository<PlatformCre
List<PlatformCredential> findByArchiveFlag(boolean archiveFlag);
Page<PlatformCredential> findByArchiveFlag(boolean archiveFlag, Pageable pageable);
List<PlatformCredential> findByDeviceId(UUID deviceId);
PlatformCredential findByPlatformSerialAndSerialNumber(String platformSerial, BigInteger serialNumber);
}

View File

@ -4,6 +4,7 @@ import hirs.attestationca.persist.entity.manager.CertificateRepository;
import hirs.attestationca.persist.entity.manager.ComponentAttributeRepository;
import hirs.attestationca.persist.entity.manager.ComponentInfoRepository;
import hirs.attestationca.persist.entity.manager.ComponentResultRepository;
import hirs.attestationca.persist.entity.manager.PlatformCertificateRepository;
import hirs.attestationca.persist.entity.userdefined.certificate.ComponentResult;
import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential;
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentAttributeResult;
@ -28,20 +29,20 @@ import java.util.UUID;
@Log4j2
@Controller
@RequestMapping("/HIRS_AttestationCAPortal/portal/component-validation")
@RequestMapping("/HIRS_AttestationCAPortal/portal/component-comparison")
public class ComponentComparisonPageController extends PageController<CertificateDetailsPageParams> {
private final CertificateRepository certificateRepository;
private final PlatformCertificateRepository platformCertificateRepository;
private final ComponentResultRepository componentResultRepository;
private final ComponentInfoRepository componentInfoRepository;
private final ComponentAttributeRepository componentAttributeRepository;
@Autowired
public ComponentComparisonPageController(final CertificateRepository certificateRepository,
public ComponentComparisonPageController(final PlatformCertificateRepository platformCertificateRepository,
final ComponentResultRepository componentResultRepository,
final ComponentInfoRepository componentInfoRepository,
final ComponentAttributeRepository componentAttributeRepository) {
super(Page.COMPONENT_COMPARISON);
this.certificateRepository = certificateRepository;
this.platformCertificateRepository = platformCertificateRepository;
this.componentResultRepository = componentResultRepository;
this.componentInfoRepository = componentInfoRepository;
this.componentAttributeRepository = componentAttributeRepository;
@ -76,7 +77,7 @@ public class ComponentComparisonPageController extends PageController<Certificat
try {
UUID uuid = UUID.fromString(params.getId());
data.putAll(getPlatformComponentInformation(uuid, params.getDeviceName(),
certificateRepository, componentResultRepository,
platformCertificateRepository, componentResultRepository,
componentInfoRepository,
componentAttributeRepository));
} catch (IllegalArgumentException iaEx) {
@ -113,7 +114,7 @@ public class ComponentComparisonPageController extends PageController<Certificat
*/
public static HashMap<String, Object> getPlatformComponentInformation(
final UUID sessionId, final String deviceName,
final CertificateRepository certificateRepository,
final PlatformCertificateRepository platformCertificateRepository,
final ComponentResultRepository componentResultRepository,
final ComponentInfoRepository componentInfoRepository,
final ComponentAttributeRepository componentAttributeRepository)
@ -129,7 +130,7 @@ public class ComponentComparisonPageController extends PageController<Certificat
}
});
componentResults.addAll(componentResultRepository.findAllById(tempIdList));
PlatformCredential platformCredential = (PlatformCredential) certificateRepository
PlatformCredential platformCredential = platformCertificateRepository
.findByPlatformSerialAndSerialNumber(componentResults.get(0).getBoardSerialNumber(),
BigInteger.valueOf(Long.parseLong(componentResults.get(0).getCertificateSerialNumber())));