mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-01-31 00:24:00 +00:00
Merge pull request #543 from nsacyber/v3_issue-534
[#534] Updated display code
This commit is contained in:
commit
ecfd2adc42
@ -0,0 +1,17 @@
|
|||||||
|
package hirs.attestationca.persist.entity.manager;
|
||||||
|
|
||||||
|
import hirs.attestationca.persist.entity.userdefined.certificate.CertificateAuthorityCredential;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface CACredentialRepository extends JpaRepository<CertificateAuthorityCredential, UUID> {
|
||||||
|
|
||||||
|
@Query(value = "SELECT * FROM Certificate where DTYPE='CertificateAuthorityCredential'", nativeQuery = true)
|
||||||
|
@Override
|
||||||
|
List<CertificateAuthorityCredential> findAll();
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package hirs.attestationca.persist.entity.manager;
|
package hirs.attestationca.persist.entity.manager;
|
||||||
|
|
||||||
import hirs.attestationca.persist.entity.userdefined.Certificate;
|
import hirs.attestationca.persist.entity.userdefined.Certificate;
|
||||||
import hirs.attestationca.persist.entity.userdefined.certificate.EndorsementCredential;
|
|
||||||
import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential;
|
import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
@ -30,8 +29,6 @@ public interface CertificateRepository<T extends Certificate> extends JpaReposit
|
|||||||
List<PlatformCredential> byBoardSerialNumber(String boardSerialNumber);
|
List<PlatformCredential> byBoardSerialNumber(String boardSerialNumber);
|
||||||
@Query(value = "SELECT * FROM Certificate where holderSerialNumber = ?1 AND DTYPE = 'PlatformCredential'", nativeQuery = true)
|
@Query(value = "SELECT * FROM Certificate where holderSerialNumber = ?1 AND DTYPE = 'PlatformCredential'", nativeQuery = true)
|
||||||
PlatformCredential getPcByHolderSerialNumber(BigInteger holderSerialNumber);
|
PlatformCredential getPcByHolderSerialNumber(BigInteger holderSerialNumber);
|
||||||
@Query(value = "SELECT * FROM Certificate where holderSerialNumber = ?1 AND DTYPE = 'EndorsementCredential'", nativeQuery = true)
|
|
||||||
EndorsementCredential getEcByHolderSerialNumber(BigInteger holderSerialNumber);
|
|
||||||
@Query(value = "SELECT * FROM Certificate where certificateHash = ?1 AND DTYPE = ?2", nativeQuery = true)
|
@Query(value = "SELECT * FROM Certificate where certificateHash = ?1 AND DTYPE = ?2", nativeQuery = true)
|
||||||
T findByCertificateHash(int certificateHash, String dType);
|
T findByCertificateHash(int certificateHash, String dType);
|
||||||
@Query(value = "SELECT * FROM Certificate where subjectKeyIdentifier = ?1", nativeQuery = true)
|
@Query(value = "SELECT * FROM Certificate where subjectKeyIdentifier = ?1", nativeQuery = true)
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package hirs.attestationca.persist.entity.manager;
|
||||||
|
|
||||||
|
import hirs.attestationca.persist.entity.userdefined.certificate.EndorsementCredential;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface EndorsementCredentialRepository extends JpaRepository<EndorsementCredential, UUID> {
|
||||||
|
|
||||||
|
@Query(value = "SELECT * FROM Certificate where DTYPE='EndorsementCredential'", nativeQuery = true)
|
||||||
|
@Override
|
||||||
|
List<EndorsementCredential> findAll();
|
||||||
|
@Query(value = "SELECT * FROM Certificate where holderSerialNumber = ?1 AND DTYPE = 'EndorsementCredential'", nativeQuery = true)
|
||||||
|
EndorsementCredential getEcByHolderSerialNumber(BigInteger holderSerialNumber);
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package hirs.attestationca.persist.entity.manager;
|
||||||
|
|
||||||
|
import hirs.attestationca.persist.entity.userdefined.certificate.IssuedAttestationCertificate;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface IssuedCertificateRepository extends JpaRepository<IssuedAttestationCertificate, UUID> {
|
||||||
|
|
||||||
|
@Query(value = "SELECT * FROM Certificate where DTYPE='IssuedAttestationCertificate'", nativeQuery = true)
|
||||||
|
@Override
|
||||||
|
List<IssuedAttestationCertificate> findAll();
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package hirs.attestationca.persist.entity.manager;
|
||||||
|
|
||||||
|
import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface PlatformCertificateRepository extends JpaRepository<PlatformCredential, UUID> {
|
||||||
|
|
||||||
|
@Query(value = "SELECT * FROM Certificate where DTYPE='PlatformCredential'", nativeQuery = true)
|
||||||
|
@Override
|
||||||
|
List<PlatformCredential> findAll();
|
||||||
|
}
|
@ -24,6 +24,7 @@ import org.bouncycastle.asn1.DERIA5String;
|
|||||||
import org.bouncycastle.asn1.DEROctetString;
|
import org.bouncycastle.asn1.DEROctetString;
|
||||||
import org.bouncycastle.asn1.DERTaggedObject;
|
import org.bouncycastle.asn1.DERTaggedObject;
|
||||||
import org.bouncycastle.asn1.DLSequence;
|
import org.bouncycastle.asn1.DLSequence;
|
||||||
|
import org.bouncycastle.asn1.DLTaggedObject;
|
||||||
import org.bouncycastle.asn1.x500.X500Name;
|
import org.bouncycastle.asn1.x500.X500Name;
|
||||||
import org.bouncycastle.asn1.x509.AccessDescription;
|
import org.bouncycastle.asn1.x509.AccessDescription;
|
||||||
import org.bouncycastle.asn1.x509.AttCertIssuer;
|
import org.bouncycastle.asn1.x509.AttCertIssuer;
|
||||||
@ -665,7 +666,7 @@ public abstract class Certificate extends ArchivableEntity {
|
|||||||
// V1 X509Certificate
|
// V1 X509Certificate
|
||||||
return CertificateType.X509_CERTIFICATE;
|
return CertificateType.X509_CERTIFICATE;
|
||||||
}
|
}
|
||||||
} else if (testSeq.toArray()[0] instanceof DERTaggedObject) {
|
} else if (testSeq.toArray()[0] instanceof DERTaggedObject || testSeq.toArray()[0] instanceof DLTaggedObject) {
|
||||||
// V2 or V3 X509Certificate
|
// V2 or V3 X509Certificate
|
||||||
return CertificateType.X509_CERTIFICATE;
|
return CertificateType.X509_CERTIFICATE;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import java.util.Properties;
|
|||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@PropertySource({ "classpath:hibernate.properties", "classpath:portal.properties" })
|
@PropertySource({ "classpath:hibernate.properties", "classpath:portal.properties" })
|
||||||
@ComponentScan({"hirs.attestationca.portal", "hirs.attestationca.portal.page.controllers", "hirs.attestationca.persist.entity"})//, "hirs.attestationca.persist.service"})
|
@ComponentScan({"hirs.attestationca.portal", "hirs.attestationca.portal.page.controllers", "hirs.attestationca.persist.entity"})
|
||||||
@EnableJpaRepositories(basePackages = "hirs.attestationca.persist.entity.manager")
|
@EnableJpaRepositories(basePackages = "hirs.attestationca.persist.entity.manager")
|
||||||
public class PersistenceJPAConfig implements WebMvcConfigurer {
|
public class PersistenceJPAConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@ -2,10 +2,16 @@ package hirs.attestationca.portal.datatables;
|
|||||||
|
|
||||||
import hirs.attestationca.persist.CriteriaModifier;
|
import hirs.attestationca.persist.CriteriaModifier;
|
||||||
import hirs.attestationca.persist.FilteredRecordsList;
|
import hirs.attestationca.persist.FilteredRecordsList;
|
||||||
|
import hirs.attestationca.persist.entity.userdefined.rim.ReferenceDigestValue;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.persistence.criteria.CriteriaQuery;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -16,13 +22,10 @@ import java.util.UUID;
|
|||||||
* of ordered lists.
|
* of ordered lists.
|
||||||
* @param <T> The type of object to query
|
* @param <T> The type of object to query
|
||||||
*/
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public final class OrderedListQueryDataTableAdapter<T> {
|
public final class OrderedListQueryDataTableAdapter<T> {
|
||||||
|
|
||||||
private OrderedListQueryDataTableAdapter() {
|
|
||||||
// do not construct
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ordered list of records using a default, no-op criteria modifier.
|
* Gets the ordered list of records using a default, no-op criteria modifier.
|
||||||
* @param clazz the type of objects to query for
|
* @param clazz the type of objects to query for
|
||||||
@ -36,7 +39,14 @@ public final class OrderedListQueryDataTableAdapter<T> {
|
|||||||
final JpaRepository<T, UUID> dbManager,
|
final JpaRepository<T, UUID> dbManager,
|
||||||
final DataTableInput dataTableInput,
|
final DataTableInput dataTableInput,
|
||||||
final String orderColumnName) {
|
final String orderColumnName) {
|
||||||
return getOrderedList(clazz, dbManager, dataTableInput, orderColumnName, null);
|
CriteriaModifier defaultModifier = new CriteriaModifier() {
|
||||||
|
@Override
|
||||||
|
public void modify(final CriteriaQuery criteriaQuery) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return getOrderedList(clazz, dbManager, dataTableInput, orderColumnName, defaultModifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +60,7 @@ public final class OrderedListQueryDataTableAdapter<T> {
|
|||||||
* @return the filtered record list
|
* @return the filtered record list
|
||||||
*/
|
*/
|
||||||
public static <T> FilteredRecordsList<T> getOrderedList(final Class<? extends T> clazz,
|
public static <T> FilteredRecordsList<T> getOrderedList(final Class<? extends T> clazz,
|
||||||
final JpaRepository<T, UUID> dbManager,
|
final JpaRepository<?, UUID> dbManager,
|
||||||
final DataTableInput dataTableInput,
|
final DataTableInput dataTableInput,
|
||||||
final String orderColumnName,
|
final String orderColumnName,
|
||||||
final CriteriaModifier criteriaModifier) {
|
final CriteriaModifier criteriaModifier) {
|
||||||
@ -70,6 +80,48 @@ public final class OrderedListQueryDataTableAdapter<T> {
|
|||||||
FilteredRecordsList<T> filteredRecordsList = new FilteredRecordsList<>();
|
FilteredRecordsList<T> filteredRecordsList = new FilteredRecordsList<>();
|
||||||
|
|
||||||
|
|
||||||
|
filteredRecordsList.setRecordsTotal(dbManager.count());
|
||||||
|
filteredRecordsList.addAll((Collection<? extends T>) dbManager.findAll());
|
||||||
|
filteredRecordsList.setRecordsFiltered(10);
|
||||||
|
|
||||||
|
return filteredRecordsList;
|
||||||
|
|
||||||
|
// return dbManager.getOrderedList(clazz, orderColumnName, isAscending,
|
||||||
|
// dataTableInput.getStart(), dataTableInput.getLength(),
|
||||||
|
// dataTableInput.getSearch().getValue(),
|
||||||
|
// searchableColumnMap, criteriaModifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FilteredRecordsList<ReferenceDigestValue> getOrderedList(final JpaRepository<ReferenceDigestValue, UUID> dbManager,
|
||||||
|
final DataTableInput dataTableInput,
|
||||||
|
final String orderColumnName,
|
||||||
|
final CriteriaModifier criteriaModifier,
|
||||||
|
final EntityManager entityManager) {
|
||||||
|
|
||||||
|
Map<String, Boolean> searchableColumnMap = new HashMap<>();
|
||||||
|
for (Column column : dataTableInput.getColumns()) {
|
||||||
|
searchableColumnMap.put(column.getData(), column.isSearchable());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Order> orders = dataTableInput.getOrder();
|
||||||
|
boolean isAscending = true;
|
||||||
|
if (!CollectionUtils.isEmpty(orders)) {
|
||||||
|
isAscending = orders.get(0).isAscending();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Session session = entityManager.unwrap(Session.class);
|
||||||
|
// CriteriaBuilder cb = session.getCriteriaBuilder();
|
||||||
|
// CriteriaQuery<ReferenceDigestValue> criteriaQuery = cb.createQuery(ReferenceDigestValue.class);
|
||||||
|
// Root<ReferenceDigestValue> rimRoot = criteriaQuery.from(ReferenceDigestValue.class);
|
||||||
|
//
|
||||||
|
// TypedQuery<ReferenceDigestValue> query = entityManager.createQuery(criteriaQuery);
|
||||||
|
|
||||||
|
|
||||||
|
//Object that will store query values
|
||||||
|
FilteredRecordsList<ReferenceDigestValue> filteredRecordsList = new FilteredRecordsList<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
filteredRecordsList.setRecordsTotal(dbManager.count());
|
filteredRecordsList.setRecordsTotal(dbManager.count());
|
||||||
filteredRecordsList.addAll(dbManager.findAll());
|
filteredRecordsList.addAll(dbManager.findAll());
|
||||||
filteredRecordsList.setRecordsFiltered(10);
|
filteredRecordsList.setRecordsFiltered(10);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package hirs.attestationca.portal.page.controllers;
|
package hirs.attestationca.portal.page.controllers;
|
||||||
|
|
||||||
|
import hirs.attestationca.persist.entity.manager.CACredentialRepository;
|
||||||
import hirs.attestationca.persist.entity.manager.CertificateRepository;
|
import hirs.attestationca.persist.entity.manager.CertificateRepository;
|
||||||
import hirs.attestationca.persist.entity.manager.ComponentResultRepository;
|
import hirs.attestationca.persist.entity.manager.ComponentResultRepository;
|
||||||
import hirs.attestationca.portal.page.Page;
|
import hirs.attestationca.portal.page.Page;
|
||||||
@ -31,19 +32,23 @@ public class CertificateDetailsPageController extends PageController<Certificate
|
|||||||
*/
|
*/
|
||||||
static final String INITIAL_DATA = "initialData";
|
static final String INITIAL_DATA = "initialData";
|
||||||
private final CertificateRepository certificateRepository;
|
private final CertificateRepository certificateRepository;
|
||||||
|
private final CACredentialRepository caCredentialRepository;
|
||||||
private final ComponentResultRepository componentResultRepository;
|
private final ComponentResultRepository componentResultRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor providing the Page's display and routing specification.
|
* Constructor providing the Page's display and routing specification.
|
||||||
* @param certificateRepository the certificate repository
|
* @param certificateRepository the certificate repository
|
||||||
* @param componentResultRepository the component result repository
|
* @param componentResultRepository the component result repository
|
||||||
|
* @param caCredentialRepository the ca credential manager
|
||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
public CertificateDetailsPageController(final CertificateRepository certificateRepository,
|
public CertificateDetailsPageController(final CertificateRepository certificateRepository,
|
||||||
final ComponentResultRepository componentResultRepository) {
|
final ComponentResultRepository componentResultRepository,
|
||||||
|
final CACredentialRepository caCredentialRepository) {
|
||||||
super(Page.CERTIFICATE_DETAILS);
|
super(Page.CERTIFICATE_DETAILS);
|
||||||
this.certificateRepository = certificateRepository;
|
this.certificateRepository = certificateRepository;
|
||||||
this.componentResultRepository = componentResultRepository;
|
this.componentResultRepository = componentResultRepository;
|
||||||
|
this.caCredentialRepository = caCredentialRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,7 +86,7 @@ public class CertificateDetailsPageController extends PageController<Certificate
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case "certificateauthority":
|
case "certificateauthority":
|
||||||
data.putAll(CertificateStringMapBuilder.getCertificateAuthorityInformation(
|
data.putAll(CertificateStringMapBuilder.getCertificateAuthorityInformation(
|
||||||
uuid, certificateRepository));
|
uuid, certificateRepository, caCredentialRepository));
|
||||||
break;
|
break;
|
||||||
case "endorsement":
|
case "endorsement":
|
||||||
data.putAll(CertificateStringMapBuilder.getEndorsementInformation(uuid,
|
data.putAll(CertificateStringMapBuilder.getEndorsementInformation(uuid,
|
||||||
|
@ -3,7 +3,11 @@ package hirs.attestationca.portal.page.controllers;
|
|||||||
import hirs.attestationca.persist.CriteriaModifier;
|
import hirs.attestationca.persist.CriteriaModifier;
|
||||||
import hirs.attestationca.persist.DBServiceException;
|
import hirs.attestationca.persist.DBServiceException;
|
||||||
import hirs.attestationca.persist.FilteredRecordsList;
|
import hirs.attestationca.persist.FilteredRecordsList;
|
||||||
|
import hirs.attestationca.persist.entity.manager.CACredentialRepository;
|
||||||
import hirs.attestationca.persist.entity.manager.CertificateRepository;
|
import hirs.attestationca.persist.entity.manager.CertificateRepository;
|
||||||
|
import hirs.attestationca.persist.entity.manager.EndorsementCredentialRepository;
|
||||||
|
import hirs.attestationca.persist.entity.manager.IssuedCertificateRepository;
|
||||||
|
import hirs.attestationca.persist.entity.manager.PlatformCertificateRepository;
|
||||||
import hirs.attestationca.persist.entity.userdefined.Certificate;
|
import hirs.attestationca.persist.entity.userdefined.Certificate;
|
||||||
import hirs.attestationca.persist.entity.userdefined.certificate.CertificateAuthorityCredential;
|
import hirs.attestationca.persist.entity.userdefined.certificate.CertificateAuthorityCredential;
|
||||||
import hirs.attestationca.persist.entity.userdefined.certificate.EndorsementCredential;
|
import hirs.attestationca.persist.entity.userdefined.certificate.EndorsementCredential;
|
||||||
@ -67,6 +71,10 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
|
|
||||||
private CertificateAuthorityCredential certificateAuthorityCredential;
|
private CertificateAuthorityCredential certificateAuthorityCredential;
|
||||||
private final CertificateRepository certificateRepository;
|
private final CertificateRepository certificateRepository;
|
||||||
|
private final PlatformCertificateRepository platformCertificateRepository;
|
||||||
|
private final EndorsementCredentialRepository endorsementCredentialRepository;
|
||||||
|
private final IssuedCertificateRepository issuedCertificateRepository;
|
||||||
|
private final CACredentialRepository caCredentialRepository;
|
||||||
|
|
||||||
private static final String TRUSTCHAIN = "trust-chain";
|
private static final String TRUSTCHAIN = "trust-chain";
|
||||||
private static final String PLATFORMCREDENTIAL = "platform-credentials";
|
private static final String PLATFORMCREDENTIAL = "platform-credentials";
|
||||||
@ -81,15 +89,27 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
/**
|
/**
|
||||||
* Constructor providing the Page's display and routing specification.
|
* Constructor providing the Page's display and routing specification.
|
||||||
*
|
*
|
||||||
* @param certificateRepository the certificate manager
|
* @param certificateRepository the general certificate manager
|
||||||
|
* @param platformCertificateRepository the platform credential manager
|
||||||
|
* @param endorsementCredentialRepository the endorsement credential manager
|
||||||
|
* @param issuedCertificateRepository the issued certificate manager
|
||||||
|
* @param caCredentialRepository the ca credential manager
|
||||||
// * @param acaCertificate the ACA's X509 certificate
|
// * @param acaCertificate the ACA's X509 certificate
|
||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
public CertificatePageController(final CertificateRepository certificateRepository
|
public CertificatePageController(final CertificateRepository certificateRepository,
|
||||||
|
final PlatformCertificateRepository platformCertificateRepository,
|
||||||
|
final EndorsementCredentialRepository endorsementCredentialRepository,
|
||||||
|
final IssuedCertificateRepository issuedCertificateRepository,
|
||||||
|
final CACredentialRepository caCredentialRepository
|
||||||
// final X509Certificate acaCertificate
|
// final X509Certificate acaCertificate
|
||||||
) {
|
) {
|
||||||
super(Page.TRUST_CHAIN);
|
super(Page.TRUST_CHAIN);
|
||||||
this.certificateRepository = certificateRepository;
|
this.certificateRepository = certificateRepository;
|
||||||
|
this.platformCertificateRepository = platformCertificateRepository;
|
||||||
|
this.endorsementCredentialRepository = endorsementCredentialRepository;
|
||||||
|
this.issuedCertificateRepository = issuedCertificateRepository;
|
||||||
|
this.caCredentialRepository = caCredentialRepository;
|
||||||
|
|
||||||
// try {
|
// try {
|
||||||
certificateAuthorityCredential = null;
|
certificateAuthorityCredential = null;
|
||||||
@ -145,7 +165,7 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
mav = getBaseModelAndView(Page.TRUST_CHAIN);
|
mav = getBaseModelAndView(Page.TRUST_CHAIN);
|
||||||
// Map with the ACA certificate information
|
// Map with the ACA certificate information
|
||||||
data.putAll(CertificateStringMapBuilder.getCertificateAuthorityInformation(
|
data.putAll(CertificateStringMapBuilder.getCertificateAuthorityInformation(
|
||||||
certificateAuthorityCredential, this.certificateRepository));
|
certificateAuthorityCredential, this.certificateRepository, this.caCredentialRepository));
|
||||||
mav.addObject(ACA_CERT_DATA, data);
|
mav.addObject(ACA_CERT_DATA, data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -197,15 +217,19 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
FilteredRecordsList<Certificate> records
|
|
||||||
= OrderedListQueryDataTableAdapter.getOrderedList(
|
|
||||||
getCertificateClass(certificateType), this.certificateRepository,
|
|
||||||
input, orderColumnName, criteriaModifier);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ok I think what I will do is make repositories for each certificate type to I can
|
||||||
|
* tell it what the type T is.
|
||||||
|
*/
|
||||||
|
FilteredRecordsList<Certificate> records = new FilteredRecordsList<>();
|
||||||
// special parsing for platform credential
|
// special parsing for platform credential
|
||||||
// Add the EndorsementCredential for each PlatformCredential based on the
|
// Add the EndorsementCredential for each PlatformCredential based on the
|
||||||
// serial number. (pc.HolderSerialNumber = ec.SerialNumber)
|
// serial number. (pc.HolderSerialNumber = ec.SerialNumber)
|
||||||
if (certificateType.equals(PLATFORMCREDENTIAL)) {
|
if (certificateType.equals(PLATFORMCREDENTIAL)) {
|
||||||
|
records = OrderedListQueryDataTableAdapter.getOrderedList(
|
||||||
|
getCertificateClass(certificateType), platformCertificateRepository,
|
||||||
|
input, orderColumnName, criteriaModifier);
|
||||||
EndorsementCredential associatedEC;
|
EndorsementCredential associatedEC;
|
||||||
|
|
||||||
if (!records.isEmpty()) {
|
if (!records.isEmpty()) {
|
||||||
@ -213,7 +237,7 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
for (int i = 0; i < records.size(); i++) {
|
for (int i = 0; i < records.size(); i++) {
|
||||||
PlatformCredential pc = (PlatformCredential) records.get(i);
|
PlatformCredential pc = (PlatformCredential) records.get(i);
|
||||||
// find the EC using the PC's "holder serial number"
|
// find the EC using the PC's "holder serial number"
|
||||||
associatedEC = certificateRepository
|
associatedEC = this.endorsementCredentialRepository
|
||||||
.getEcByHolderSerialNumber(pc.getHolderSerialNumber());
|
.getEcByHolderSerialNumber(pc.getHolderSerialNumber());
|
||||||
|
|
||||||
if (associatedEC != null) {
|
if (associatedEC != null) {
|
||||||
@ -224,6 +248,14 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
pc.setEndorsementCredential(associatedEC);
|
pc.setEndorsementCredential(associatedEC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (certificateType.equals(ENDORSEMENTCREDENTIAL)) {
|
||||||
|
records = OrderedListQueryDataTableAdapter.getOrderedList(
|
||||||
|
getCertificateClass(certificateType), endorsementCredentialRepository,
|
||||||
|
input, orderColumnName, criteriaModifier);
|
||||||
|
} else if (certificateType.equals(TRUSTCHAIN)) {
|
||||||
|
records = OrderedListQueryDataTableAdapter.getOrderedList(
|
||||||
|
getCertificateClass(certificateType), caCredentialRepository,
|
||||||
|
input, orderColumnName, criteriaModifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("Returning list of size: " + records.size());
|
log.debug("Returning list of size: " + records.size());
|
||||||
@ -315,7 +347,6 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
// send a 404 error when invalid certificate
|
// send a 404 error when invalid certificate
|
||||||
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -617,11 +648,11 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
// build the certificate from the uploaded bytes
|
// build the certificate from the uploaded bytes
|
||||||
try {
|
try {
|
||||||
fileBytes = file.getBytes();
|
fileBytes = file.getBytes();
|
||||||
} catch (IOException e) {
|
} catch (IOException ioEx) {
|
||||||
final String failMessage = String.format(
|
final String failMessage = String.format(
|
||||||
"Failed to read uploaded file (%s): ", fileName);
|
"Failed to read uploaded file (%s): ", fileName);
|
||||||
log.error(failMessage, e);
|
log.error(failMessage, ioEx);
|
||||||
messages.addError(failMessage + e.getMessage());
|
messages.addError(failMessage + ioEx.getMessage());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -639,11 +670,11 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
messages.addError(failMessage);
|
messages.addError(failMessage);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException ioEx) {
|
||||||
final String failMessage = String.format(
|
final String failMessage = String.format(
|
||||||
"Failed to parse uploaded file (%s): ", fileName);
|
"Failed to parse uploaded file (%s): ", fileName);
|
||||||
log.error(failMessage, e);
|
log.error(failMessage, ioEx);
|
||||||
messages.addError(failMessage + e.getMessage());
|
messages.addError(failMessage + ioEx.getMessage());
|
||||||
return null;
|
return null;
|
||||||
} catch (DecoderException dEx) {
|
} catch (DecoderException dEx) {
|
||||||
final String failMessage = String.format(
|
final String failMessage = String.format(
|
||||||
|
@ -10,7 +10,6 @@ import hirs.attestationca.persist.entity.userdefined.rim.ReferenceDigestValue;
|
|||||||
import hirs.attestationca.persist.entity.userdefined.rim.SupportReferenceManifest;
|
import hirs.attestationca.persist.entity.userdefined.rim.SupportReferenceManifest;
|
||||||
import hirs.attestationca.portal.datatables.DataTableInput;
|
import hirs.attestationca.portal.datatables.DataTableInput;
|
||||||
import hirs.attestationca.portal.datatables.DataTableResponse;
|
import hirs.attestationca.portal.datatables.DataTableResponse;
|
||||||
import hirs.attestationca.portal.datatables.OrderedListQueryDataTableAdapter;
|
|
||||||
import hirs.attestationca.portal.page.Page;
|
import hirs.attestationca.portal.page.Page;
|
||||||
import hirs.attestationca.portal.page.PageController;
|
import hirs.attestationca.portal.page.PageController;
|
||||||
import hirs.attestationca.portal.page.params.NoPageParams;
|
import hirs.attestationca.portal.page.params.NoPageParams;
|
||||||
@ -22,6 +21,9 @@ import jakarta.validation.Valid;
|
|||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
@ -105,13 +107,23 @@ public class RimDatabasePageController extends PageController<NoPageParams> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
log.info("Querying with the following datatableinput: " + input.toString());
|
log.info("Querying with the following datatableinput: " + input.toString());
|
||||||
|
FilteredRecordsList<ReferenceDigestValue> referenceDigestValues = new FilteredRecordsList<>();
|
||||||
|
Pageable paging = PageRequest.of(input.getStart(), input.getLength(), Sort.by(orderColumnName));
|
||||||
|
|
||||||
FilteredRecordsList<ReferenceDigestValue> referenceDigestValues =
|
org.springframework.data.domain.Page<ReferenceDigestValue> pagedResult = referenceDigestValueRepository.findAll(paging);
|
||||||
OrderedListQueryDataTableAdapter.getOrderedList(
|
|
||||||
ReferenceDigestValue.class,
|
|
||||||
referenceDigestValueRepository,
|
|
||||||
input, orderColumnName, criteriaModifier);
|
|
||||||
|
|
||||||
|
if (pagedResult.hasContent()) {
|
||||||
|
referenceDigestValues.addAll(pagedResult.getContent());
|
||||||
|
}
|
||||||
|
referenceDigestValues.setRecordsTotal(referenceDigestValueRepository.count());
|
||||||
|
referenceDigestValues.setRecordsFiltered(input.getLength());
|
||||||
|
|
||||||
|
// FilteredRecordsList<ReferenceDigestValue> referenceDigestValues =
|
||||||
|
// OrderedListQueryDataTableAdapter.getOrderedList(
|
||||||
|
// referenceDigestValueRepository,
|
||||||
|
// input, orderColumnName, criteriaModifier, entityManager);
|
||||||
|
|
||||||
|
// might be able to get rid of this, maybe right a query that looks for not updated
|
||||||
SupportReferenceManifest support;
|
SupportReferenceManifest support;
|
||||||
for (ReferenceDigestValue rdv : referenceDigestValues) {
|
for (ReferenceDigestValue rdv : referenceDigestValues) {
|
||||||
// We are updating the base rim ID field if necessary and
|
// We are updating the base rim ID field if necessary and
|
||||||
@ -123,7 +135,6 @@ public class RimDatabasePageController extends PageController<NoPageParams> {
|
|||||||
referenceDigestValueRepository.save(rdv);
|
referenceDigestValueRepository.save(rdv);
|
||||||
} catch (DBManagerException e) {
|
} catch (DBManagerException e) {
|
||||||
log.error("Failed to update TPM Event with Base RIM ID");
|
log.error("Failed to update TPM Event with Base RIM ID");
|
||||||
log.error(rdv);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package hirs.attestationca.portal.page.utils;
|
package hirs.attestationca.portal.page.utils;
|
||||||
|
|
||||||
|
import hirs.attestationca.persist.entity.manager.CACredentialRepository;
|
||||||
import hirs.attestationca.persist.entity.manager.CertificateRepository;
|
import hirs.attestationca.persist.entity.manager.CertificateRepository;
|
||||||
import hirs.attestationca.persist.entity.manager.ComponentResultRepository;
|
import hirs.attestationca.persist.entity.manager.ComponentResultRepository;
|
||||||
import hirs.attestationca.persist.entity.userdefined.Certificate;
|
import hirs.attestationca.persist.entity.userdefined.Certificate;
|
||||||
@ -65,8 +66,12 @@ public final class CertificateStringMapBuilder {
|
|||||||
|
|
||||||
if (certificate.getSubject() != null) {
|
if (certificate.getSubject() != null) {
|
||||||
data.put("subject", certificate.getSubject());
|
data.put("subject", certificate.getSubject());
|
||||||
data.put("isSelfSigned",
|
if (certificate.getHolderIssuer() != null) {
|
||||||
String.valueOf(certificate.getHolderIssuer().equals(certificate.getSubject())));
|
data.put("isSelfSigned",
|
||||||
|
String.valueOf(certificate.getHolderIssuer().equals(certificate.getSubject())));
|
||||||
|
} else {
|
||||||
|
data.put("isSelfSigned", "false");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
data.put("isSelfSigned", "false");
|
data.put("isSelfSigned", "false");
|
||||||
}
|
}
|
||||||
@ -182,8 +187,8 @@ public final class CertificateStringMapBuilder {
|
|||||||
}
|
}
|
||||||
return containsAllChain(issuerCert, certificateRepository);
|
return containsAllChain(issuerCert, certificateRepository);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException ioEx) {
|
||||||
log.error(e);
|
log.error(ioEx);
|
||||||
return certificate;
|
return certificate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,17 +200,18 @@ public final class CertificateStringMapBuilder {
|
|||||||
* Returns the Certificate Authority information.
|
* Returns the Certificate Authority information.
|
||||||
*
|
*
|
||||||
* @param uuid ID for the certificate.
|
* @param uuid ID for the certificate.
|
||||||
* @param certificateRepository the certificate manager for retrieving certs.
|
* @param caCertificateRepository the certificate manager for retrieving certs.
|
||||||
* @return a hash map with the endorsement certificate information.
|
* @return a hash map with the endorsement certificate information.
|
||||||
*/
|
*/
|
||||||
public static HashMap<String, String> getCertificateAuthorityInformation(final UUID uuid,
|
public static HashMap<String, String> getCertificateAuthorityInformation(final UUID uuid,
|
||||||
final CertificateRepository certificateRepository) {
|
final CertificateRepository certificateRepository,
|
||||||
CertificateAuthorityCredential certificate = (CertificateAuthorityCredential) certificateRepository.getCertificate(uuid);
|
final CACredentialRepository caCertificateRepository) {
|
||||||
|
CertificateAuthorityCredential certificate = caCertificateRepository.getReferenceById(uuid);
|
||||||
|
|
||||||
String notFoundMessage = "Unable to find Certificate Authority "
|
String notFoundMessage = "Unable to find Certificate Authority "
|
||||||
+ "Credential with ID: " + uuid;
|
+ "Credential with ID: " + uuid;
|
||||||
|
|
||||||
return getCertificateAuthorityInfoHelper(certificateRepository, certificate, notFoundMessage);
|
return getCertificateAuthorityInfoHelper(certificateRepository, caCertificateRepository, certificate, notFoundMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -213,17 +219,20 @@ public final class CertificateStringMapBuilder {
|
|||||||
*
|
*
|
||||||
* @param certificate the certificate
|
* @param certificate the certificate
|
||||||
* @param certificateRepository the certificate repository for retrieving certs.
|
* @param certificateRepository the certificate repository for retrieving certs.
|
||||||
|
* @param caCertificateRepository the certificate repository for retrieving certs.
|
||||||
* @return a hash map with the endorsement certificate information.
|
* @return a hash map with the endorsement certificate information.
|
||||||
*/
|
*/
|
||||||
public static HashMap<String, String> getCertificateAuthorityInformation(
|
public static HashMap<String, String> getCertificateAuthorityInformation(
|
||||||
final CertificateAuthorityCredential certificate,
|
final CertificateAuthorityCredential certificate,
|
||||||
final CertificateRepository certificateRepository) {
|
final CertificateRepository certificateRepository,
|
||||||
return getCertificateAuthorityInfoHelper(certificateRepository, certificate,
|
final CACredentialRepository caCertificateRepository) {
|
||||||
|
return getCertificateAuthorityInfoHelper(certificateRepository, caCertificateRepository, certificate,
|
||||||
"No cert provided for mapping");
|
"No cert provided for mapping");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashMap<String, String> getCertificateAuthorityInfoHelper(
|
private static HashMap<String, String> getCertificateAuthorityInfoHelper(
|
||||||
final CertificateRepository certificateRepository,
|
final CertificateRepository certificateRepository,
|
||||||
|
final CACredentialRepository caCertificateRepository,
|
||||||
final CertificateAuthorityCredential certificate, final String notFoundMessage) {
|
final CertificateAuthorityCredential certificate, final String notFoundMessage) {
|
||||||
HashMap<String, String> data = new HashMap<>();
|
HashMap<String, String> data = new HashMap<>();
|
||||||
|
|
||||||
@ -251,7 +260,7 @@ public final class CertificateStringMapBuilder {
|
|||||||
public static HashMap<String, String> getEndorsementInformation(final UUID uuid,
|
public static HashMap<String, String> getEndorsementInformation(final UUID uuid,
|
||||||
final CertificateRepository certificateRepository) {
|
final CertificateRepository certificateRepository) {
|
||||||
HashMap<String, String> data = new HashMap<>();
|
HashMap<String, String> data = new HashMap<>();
|
||||||
EndorsementCredential certificate = (EndorsementCredential) certificateRepository.findById(uuid).get();
|
EndorsementCredential certificate = (EndorsementCredential) certificateRepository.getCertificate(uuid);
|
||||||
|
|
||||||
if (certificate != null) {
|
if (certificate != null) {
|
||||||
data.putAll(getGeneralCertificateInfo(certificate, certificateRepository));
|
data.putAll(getGeneralCertificateInfo(certificate, certificateRepository));
|
||||||
@ -296,7 +305,7 @@ public final class CertificateStringMapBuilder {
|
|||||||
final ComponentResultRepository componentResultRepository)
|
final ComponentResultRepository componentResultRepository)
|
||||||
throws IllegalArgumentException, IOException {
|
throws IllegalArgumentException, IOException {
|
||||||
HashMap<String, Object> data = new HashMap<>();
|
HashMap<String, Object> data = new HashMap<>();
|
||||||
PlatformCredential certificate = (PlatformCredential) certificateRepository.findById(uuid).get();
|
PlatformCredential certificate = (PlatformCredential) certificateRepository.getCertificate(uuid);
|
||||||
|
|
||||||
if (certificate != null) {
|
if (certificate != null) {
|
||||||
data.putAll(getGeneralCertificateInfo(certificate, certificateRepository));
|
data.putAll(getGeneralCertificateInfo(certificate, certificateRepository));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user