mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-03-10 14:34:27 +00:00
Additional changes. Went to Hibernate 6, encountered issues with the
version of java. Backed down to 5 but ran into different issues
This commit is contained in:
parent
c426cec978
commit
2971459f32
@ -30,7 +30,6 @@ import hirs.data.persist.info.TPMInfo;
|
||||
import hirs.data.service.DeviceRegister;
|
||||
import hirs.persist.CertificateManager;
|
||||
import hirs.persist.DeviceManager;
|
||||
import hirs.persist.ReferenceDigestManager;
|
||||
import hirs.persist.ReferenceEventManager;
|
||||
import hirs.persist.ReferenceManifestManager;
|
||||
import hirs.persist.TPM2ProvisionerState;
|
||||
@ -179,7 +178,6 @@ public abstract class AbstractAttestationCertificateAuthority
|
||||
private final ReferenceManifestManager referenceManifestManager;
|
||||
private final DeviceRegister deviceRegister;
|
||||
private final DeviceManager deviceManager;
|
||||
private final ReferenceDigestManager referenceDigestManager;
|
||||
private final ReferenceEventManager referenceEventManager;
|
||||
private String tpmQuoteHash = "";
|
||||
private String tpmQuoteSignature = "";
|
||||
@ -195,7 +193,6 @@ public abstract class AbstractAttestationCertificateAuthority
|
||||
* @param deviceRegister the device register
|
||||
* @param validDays the number of days issued certs are valid
|
||||
* @param deviceManager the device manager
|
||||
* @param referenceDigestManager the reference digest manager
|
||||
* @param referenceEventManager the reference event manager
|
||||
*/
|
||||
@SuppressWarnings("checkstyle:parameternumber")
|
||||
@ -207,7 +204,6 @@ public abstract class AbstractAttestationCertificateAuthority
|
||||
final ReferenceManifestManager referenceManifestManager,
|
||||
final DeviceRegister deviceRegister, final int validDays,
|
||||
final DeviceManager deviceManager,
|
||||
final ReferenceDigestManager referenceDigestManager,
|
||||
final ReferenceEventManager referenceEventManager) {
|
||||
this.supplyChainValidationService = supplyChainValidationService;
|
||||
this.privateKey = privateKey;
|
||||
@ -218,7 +214,6 @@ public abstract class AbstractAttestationCertificateAuthority
|
||||
this.deviceRegister = deviceRegister;
|
||||
this.validDays = validDays;
|
||||
this.deviceManager = deviceManager;
|
||||
this.referenceDigestManager = referenceDigestManager;
|
||||
this.referenceEventManager = referenceEventManager;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import hirs.attestationca.service.SupplyChainValidationService;
|
||||
import hirs.data.service.DeviceRegister;
|
||||
import hirs.persist.CertificateManager;
|
||||
import hirs.persist.DeviceManager;
|
||||
import hirs.persist.ReferenceDigestManager;
|
||||
import hirs.persist.ReferenceEventManager;
|
||||
import hirs.persist.ReferenceManifestManager;
|
||||
import hirs.structs.converters.StructConverter;
|
||||
@ -41,7 +40,6 @@ public class RestfulAttestationCertificateAuthority
|
||||
* @param deviceRegister the device register
|
||||
* @param validDays the number of days issued certs are valid
|
||||
* @param deviceManager the device manager
|
||||
* @param referenceDigestManager the reference digest manager
|
||||
* @param referenceEventManager the reference event manager
|
||||
*/
|
||||
@SuppressWarnings({ "checkstyle:parameternumber" })
|
||||
@ -54,13 +52,12 @@ public class RestfulAttestationCertificateAuthority
|
||||
final ReferenceManifestManager referenceManifestManager,
|
||||
final DeviceRegister deviceRegister,
|
||||
final DeviceManager deviceManager,
|
||||
final ReferenceDigestManager referenceDigestManager,
|
||||
final ReferenceEventManager referenceEventManager,
|
||||
@Value("${aca.certificates.validity}") final int validDays) {
|
||||
super(supplyChainValidationService, privateKey, acaCertificate, structConverter,
|
||||
certificateManager, referenceManifestManager,
|
||||
deviceRegister, validDays, deviceManager,
|
||||
referenceDigestManager, referenceEventManager);
|
||||
referenceEventManager);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -132,7 +132,7 @@ public class AbstractAttestationCertificateAuthorityTest {
|
||||
public void setup() {
|
||||
aca = new AbstractAttestationCertificateAuthority(null, keyPair.getPrivate(),
|
||||
null, null, null, null, null, 1,
|
||||
null, null, null) {
|
||||
null, null) {
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@ import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
@ -19,7 +21,9 @@ import java.nio.charset.StandardCharsets;
|
||||
* Specifies the location to scan for page controllers, view resolver for JSON data, and view
|
||||
* resolver to map view names to jsp files.
|
||||
*/
|
||||
@Repository
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
@EnableWebMvc
|
||||
@ComponentScan("hirs.attestationca.portal.page.controllers")
|
||||
@Import({ PersistenceConfiguration.class })
|
||||
|
@ -8,9 +8,9 @@ import hirs.persist.CertificateManager;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -22,8 +22,8 @@ import static hirs.attestationca.portal.page.Page.CERTIFICATE_DETAILS;
|
||||
/**
|
||||
* Controller for the Certificate Details page.
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/certificate-details")
|
||||
@RestController
|
||||
@RequestMapping(path = "/certificate-details")
|
||||
public class CertificateDetailsPageController extends PageController<CertificateDetailsPageParams> {
|
||||
|
||||
/**
|
||||
@ -31,6 +31,7 @@ public class CertificateDetailsPageController extends PageController<Certificate
|
||||
*/
|
||||
static final String INITIAL_DATA = "initialData";
|
||||
|
||||
@Autowired
|
||||
private final CertificateManager certificateManager;
|
||||
private static final Logger LOGGER =
|
||||
LogManager.getLogger(CertificateDetailsPageController.class);
|
||||
|
@ -26,14 +26,15 @@ import org.hibernate.criterion.Restrictions;
|
||||
import org.hibernate.sql.JoinType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
@ -57,11 +58,13 @@ import static org.apache.logging.log4j.LogManager.getLogger;
|
||||
/**
|
||||
* Controller for the Certificates list all pages.
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/certificate-request")
|
||||
@RestController
|
||||
@RequestMapping(path = "/certificate-request")
|
||||
public class CertificateRequestPageController extends PageController<NoPageParams> {
|
||||
|
||||
@Autowired
|
||||
private final CertificateManager certificateManager;
|
||||
@Autowired
|
||||
private final OrderedListQuerier<Certificate> dataTableQuerier;
|
||||
|
||||
private CertificateAuthorityCredential certificateAuthorityCredential;
|
||||
@ -127,6 +130,7 @@ public class CertificateRequestPageController extends PageController<NoPageParam
|
||||
* redirect.
|
||||
* @return the path for the view and data model for the page.
|
||||
*/
|
||||
@GetMapping
|
||||
@RequestMapping("/{certificateType}")
|
||||
public ModelAndView initPage(@PathVariable("certificateType") final String certificateType,
|
||||
final NoPageParams params, final Model model) {
|
||||
@ -168,6 +172,7 @@ public class CertificateRequestPageController extends PageController<NoPageParam
|
||||
* @return the data table
|
||||
*/
|
||||
@ResponseBody
|
||||
@GetMapping
|
||||
@RequestMapping(value = "/{certificateType}/list",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE,
|
||||
method = RequestMethod.GET)
|
||||
|
@ -1,19 +1,26 @@
|
||||
package hirs.attestationca.portal.page.controllers;
|
||||
|
||||
import hirs.FilteredRecordsList;
|
||||
import hirs.attestationca.portal.datatables.DataTableInput;
|
||||
import hirs.attestationca.portal.datatables.DataTableResponse;
|
||||
import hirs.attestationca.portal.datatables.OrderedListQueryDataTableAdapter;
|
||||
import static hirs.attestationca.portal.page.Page.DEVICES;
|
||||
import hirs.attestationca.portal.page.PageController;
|
||||
import hirs.attestationca.portal.page.params.NoPageParams;
|
||||
import hirs.data.persist.Device;
|
||||
import hirs.data.persist.certificate.Certificate;
|
||||
import hirs.data.persist.certificate.DeviceAssociatedCertificate;
|
||||
import hirs.persist.DBManager;
|
||||
import hirs.persist.DeviceManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -22,23 +29,19 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static hirs.attestationca.portal.page.Page.DEVICES;
|
||||
import static org.apache.logging.log4j.LogManager.getLogger;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import hirs.FilteredRecordsList;
|
||||
import hirs.data.persist.Device;
|
||||
import hirs.data.persist.certificate.Certificate;
|
||||
import hirs.data.persist.certificate.DeviceAssociatedCertificate;
|
||||
import hirs.persist.DBManager;
|
||||
import hirs.persist.DeviceManager;
|
||||
|
||||
/**
|
||||
* Controller for the Device page.
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/devices")
|
||||
@RestController
|
||||
@RequestMapping(path = "/devices")
|
||||
public class DevicesPageController extends PageController<NoPageParams> {
|
||||
|
||||
@Autowired
|
||||
private final DeviceManager deviceManager;
|
||||
@Autowired
|
||||
private final DBManager<Certificate> certificateDBManager;
|
||||
private static final Logger LOGGER = getLogger(DevicesPageController.class);
|
||||
|
||||
@ -76,6 +79,7 @@ public class DevicesPageController extends PageController<NoPageParams> {
|
||||
* @return the data tables response, including the result set and paging information
|
||||
*/
|
||||
@ResponseBody
|
||||
@GetMapping
|
||||
@RequestMapping(value = "list", produces = MediaType.APPLICATION_JSON_VALUE,
|
||||
method = RequestMethod.GET)
|
||||
public DataTableResponse<HashMap<String, Object>> getTableData(
|
||||
|
@ -1,24 +1,26 @@
|
||||
package hirs.attestationca.portal.page.controllers;
|
||||
|
||||
import static hirs.attestationca.portal.page.Page.HELP;
|
||||
import hirs.attestationca.portal.page.PageController;
|
||||
import hirs.attestationca.portal.page.params.NoPageParams;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import static org.apache.logging.log4j.LogManager.getLogger;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static hirs.attestationca.portal.page.Page.HELP;
|
||||
import static org.apache.logging.log4j.LogManager.getLogger;
|
||||
|
||||
/**
|
||||
* Controller for the Help page.
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/help")
|
||||
@RestController
|
||||
@RequestMapping(path = "/help")
|
||||
public class HelpController extends PageController<NoPageParams> {
|
||||
|
||||
@Autowired
|
||||
|
@ -12,11 +12,12 @@ import hirs.persist.PolicyManager;
|
||||
import hirs.persist.PolicyManagerException;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
import org.springframework.web.servlet.view.RedirectView;
|
||||
@ -31,8 +32,8 @@ import static org.apache.logging.log4j.LogManager.getLogger;
|
||||
/**
|
||||
* Controller for the Policy page.
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/policy")
|
||||
@RestController
|
||||
@RequestMapping(path = "/policy")
|
||||
public class PolicyPageController extends PageController<NoPageParams> {
|
||||
|
||||
private static final Logger LOGGER = getLogger(PolicyPageController.class);
|
||||
@ -45,7 +46,9 @@ public class PolicyPageController extends PageController<NoPageParams> {
|
||||
|
||||
private static final String ENABLED_EXPIRES_PARAMETER_VALUE = "expires";
|
||||
|
||||
@Autowired
|
||||
private PolicyManager policyManager;
|
||||
@Autowired
|
||||
private AppraiserManager appraiserManager;
|
||||
|
||||
/**
|
||||
@ -108,6 +111,7 @@ public class PolicyPageController extends PageController<NoPageParams> {
|
||||
* @return View containing the url and parameters
|
||||
* @throws URISyntaxException if malformed URI
|
||||
*/
|
||||
@GetMapping
|
||||
@RequestMapping(value = "update-pc-validation", method = RequestMethod.POST)
|
||||
public RedirectView updatePcVal(@ModelAttribute final PolicyPageModel ppModel,
|
||||
final RedirectAttributes attr) throws URISyntaxException {
|
||||
@ -159,6 +163,7 @@ public class PolicyPageController extends PageController<NoPageParams> {
|
||||
* @return View containing the url and parameters
|
||||
* @throws URISyntaxException if malformed URI
|
||||
*/
|
||||
@GetMapping
|
||||
@RequestMapping(value = "update-pc-attribute-validation", method = RequestMethod.POST)
|
||||
public RedirectView updatePcAttributeVal(@ModelAttribute final PolicyPageModel ppModel,
|
||||
final RedirectAttributes attr)
|
||||
|
@ -25,9 +25,9 @@ import hirs.validation.SupplyChainValidatorException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -47,14 +47,18 @@ import java.util.UUID;
|
||||
/**
|
||||
* Controller for the Reference Manifest Details page.
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/rim-details")
|
||||
@RestController
|
||||
@RequestMapping(path = "/rim-details")
|
||||
public class ReferenceManifestDetailsPageController
|
||||
extends PageController<ReferenceManifestDetailsPageParams> {
|
||||
|
||||
@Autowired
|
||||
private final ReferenceManifestManager referenceManifestManager;
|
||||
@Autowired
|
||||
private final ReferenceDigestManager referenceDigestManager;
|
||||
@Autowired
|
||||
private final ReferenceEventManager referenceEventManager;
|
||||
@Autowired
|
||||
private final CertificateManager certificateManager;
|
||||
private static final ReferenceManifestValidator RIM_VALIDATOR
|
||||
= new ReferenceManifestValidator();
|
||||
|
@ -30,13 +30,14 @@ import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
@ -66,8 +67,8 @@ import java.util.zip.ZipOutputStream;
|
||||
/**
|
||||
* Controller for the Reference Manifest page.
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/reference-manifests")
|
||||
@RestController
|
||||
@RequestMapping(path = "/reference-manifests")
|
||||
public class ReferenceManifestPageController
|
||||
extends PageController<NoPageParams> {
|
||||
|
||||
@ -75,7 +76,9 @@ public class ReferenceManifestPageController
|
||||
private static final String LOG_FILE_PATTERN = "([^\\s]+(\\.(?i)(rimpcr|rimel|bin|log))$)";
|
||||
|
||||
private final BiosDateValidator biosValidator;
|
||||
@Autowired
|
||||
private final ReferenceManifestManager referenceManifestManager;
|
||||
@Autowired
|
||||
private final ReferenceEventManager referenceEventManager;
|
||||
private static final Logger LOGGER
|
||||
= LogManager.getLogger(ReferenceManifestPageController.class);
|
||||
@ -161,6 +164,7 @@ public class ReferenceManifestPageController
|
||||
* information
|
||||
*/
|
||||
@ResponseBody
|
||||
@GetMapping
|
||||
@RequestMapping(value = "/list",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE,
|
||||
method = RequestMethod.GET)
|
||||
|
@ -23,11 +23,12 @@ import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.text.DateFormat;
|
||||
@ -37,8 +38,8 @@ import java.text.SimpleDateFormat;
|
||||
/**
|
||||
* Controller for the TPM Events page.
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/rim-database")
|
||||
@RestController
|
||||
@RequestMapping(path = "/rim-database")
|
||||
public class RimDatabasePageController
|
||||
extends PageController<NoPageParams> {
|
||||
|
||||
@ -131,6 +132,7 @@ public class RimDatabasePageController
|
||||
* information
|
||||
*/
|
||||
@ResponseBody
|
||||
@GetMapping
|
||||
@RequestMapping(value = "/list",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE,
|
||||
method = RequestMethod.GET)
|
||||
|
@ -22,11 +22,12 @@ import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -52,12 +53,15 @@ import static org.apache.logging.log4j.LogManager.getLogger;
|
||||
/**
|
||||
* Controller for the Validation Reports page.
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/validation-reports")
|
||||
@RestController
|
||||
@RequestMapping(path = "/validation-reports")
|
||||
public class ValidationReportsPageController extends PageController<NoPageParams> {
|
||||
|
||||
@Autowired
|
||||
private final CrudManager<SupplyChainValidationSummary> supplyChainValidatorSummaryManager;
|
||||
@Autowired
|
||||
private final CertificateManager certificateManager;
|
||||
@Autowired
|
||||
private final DeviceManager deviceManager;
|
||||
|
||||
private static String systemColumnHeaders = "Verified Manufacturer,"
|
||||
@ -105,6 +109,7 @@ public class ValidationReportsPageController extends PageController<NoPageParams
|
||||
* @return the data table response containing the supply chain summary records
|
||||
*/
|
||||
@ResponseBody
|
||||
@GetMapping
|
||||
@RequestMapping(value = "list", produces = MediaType.APPLICATION_JSON_VALUE,
|
||||
method = RequestMethod.GET)
|
||||
public DataTableResponse<SupplyChainValidationSummary> getTableData(
|
||||
|
@ -20,11 +20,15 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
* Spring configuration class for persistence beans used by the Attestation CA Portal.
|
||||
*/
|
||||
@Repository
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
@Import({ HibernateConfiguration.class })
|
||||
public class PersistenceConfiguration {
|
||||
|
||||
|
@ -33,7 +33,6 @@ dependencies {
|
||||
compile libs.commons_http
|
||||
compile libs.commons_valid
|
||||
compile libs.hibernate
|
||||
// compile libs.hikari
|
||||
compile libs.jackson
|
||||
compile libs.jadira_usertype
|
||||
compile libs.joda_time
|
||||
|
@ -1,8 +1,5 @@
|
||||
package hirs.data.persist;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
@ -25,8 +22,6 @@ public abstract class AbstractEntity {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(generator = "uuid2")
|
||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
@Type(type = "uuid-char")
|
||||
private UUID id;
|
||||
|
||||
@Column (name = "create_time")
|
||||
|
@ -5,7 +5,6 @@ import com.google.common.base.Preconditions;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
||||
@ -91,7 +90,6 @@ public abstract class ReferenceManifest extends ArchivableEntity {
|
||||
private String platformModel = null;
|
||||
@Column(nullable = false)
|
||||
private String fileName = null;
|
||||
@Type(type = "uuid-char")
|
||||
@Column
|
||||
private UUID associatedRim;
|
||||
@Column
|
||||
|
@ -1,7 +1,8 @@
|
||||
package hirs.data.persist;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
||||
import javax.persistence.Column;
|
||||
@ -10,9 +11,8 @@ import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.Table;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.hibernate.annotations.Type;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The <code>State</code> class represents a state. This is an abstract class
|
||||
@ -33,7 +33,6 @@ public abstract class State {
|
||||
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@Type(type = "uuid-char")
|
||||
private final UUID id;
|
||||
|
||||
@Column (nullable = false)
|
||||
|
@ -2,18 +2,16 @@ package hirs.data.persist.info;
|
||||
|
||||
import hirs.data.persist.DeviceInfoReport;
|
||||
import hirs.data.persist.InetAddressXmlAdapter;
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Arrays;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.hibernate.annotations.Type;
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This class is used to represent the network info of a device.
|
||||
@ -33,7 +31,7 @@ public class NetworkInfo implements Serializable {
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(value = InetAddressXmlAdapter.class)
|
||||
@Column(length = DeviceInfoReport.SHORT_STRING_LENGTH, nullable = true)
|
||||
@Type(type = "hirs.data.persist.type.InetAddressType")
|
||||
//@Type(type = "hirs.data.persist.type.InetAddressType")
|
||||
private InetAddress ipAddress;
|
||||
|
||||
@XmlElement
|
||||
|
@ -3,20 +3,17 @@ package hirs.data.persist.info;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import hirs.data.persist.DeviceInfoReport;
|
||||
import hirs.data.persist.X509CertificateAdapter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.security.cert.X509Certificate;
|
||||
import hirs.utils.StringValidator;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Lob;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import hirs.utils.StringValidator;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.hibernate.annotations.Type;
|
||||
import java.io.Serializable;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
/**
|
||||
* This class is used to represent the TPM information for a device.
|
||||
@ -49,7 +46,7 @@ public class TPMInfo implements Serializable {
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(X509CertificateAdapter.class)
|
||||
@Lob
|
||||
@Type(type = "hirs.data.persist.type.X509CertificateType")
|
||||
// @Type(type = "hirs.data.persist.type.X509CertificateType")
|
||||
@JsonIgnore
|
||||
private X509Certificate identityCertificate;
|
||||
|
||||
|
@ -16,6 +16,7 @@ import org.hibernate.criterion.MatchMode;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.hibernate.query.Query;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
@ -38,6 +39,7 @@ import static org.hibernate.criterion.Restrictions.sqlRestriction;
|
||||
*
|
||||
* @param <T> type of objects to manage by this manager
|
||||
*/
|
||||
@Service
|
||||
public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(AbstractDbManager.class);
|
||||
|
@ -4,6 +4,7 @@ import hirs.appraiser.Appraiser;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -11,6 +12,7 @@ import java.util.List;
|
||||
* This class defines a <code>ApprasierManager</code> that stores the
|
||||
* appraisers in a database.
|
||||
*/
|
||||
@Service
|
||||
public class DBAppraiserManager extends DBManager<Appraiser> implements AppraiserManager {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
|
@ -7,6 +7,7 @@ import org.hibernate.SessionFactory;
|
||||
import org.springframework.retry.RetryCallback;
|
||||
import org.springframework.retry.RetryContext;
|
||||
import org.springframework.retry.support.RetryTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
@ -15,6 +16,7 @@ import java.util.Set;
|
||||
/**
|
||||
* This class is used to persist and retrieve {@link Certificate}s into and from a database.
|
||||
*/
|
||||
@Service
|
||||
public class DBCertificateManager extends DBManager<Certificate>
|
||||
implements CertificateManager {
|
||||
|
||||
|
@ -10,6 +10,7 @@ import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.query.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
@ -25,6 +26,7 @@ import java.util.Set;
|
||||
* This class defines the <code>DBDeviceGroupManager</code> that is used to
|
||||
* store <code>DeviceGroup</code>s in the database.
|
||||
*/
|
||||
@Service
|
||||
public class DBDeviceGroupManager extends DBManager<DeviceGroup> implements DeviceGroupManager {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(DBDeviceGroupManager.class);
|
||||
|
@ -11,6 +11,7 @@ import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.query.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
@ -29,6 +30,7 @@ import java.util.Set;
|
||||
* This class defines a <code>DeviceManager</code> that stores the devices
|
||||
* in a database.
|
||||
*/
|
||||
@Service
|
||||
public class DBDeviceManager extends DBManager<Device> implements
|
||||
DeviceManager {
|
||||
|
||||
|
@ -15,6 +15,7 @@ import org.springframework.retry.RetryListener;
|
||||
import org.springframework.retry.backoff.FixedBackOffPolicy;
|
||||
import org.springframework.retry.policy.SimpleRetryPolicy;
|
||||
import org.springframework.retry.support.RetryTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import java.io.Serializable;
|
||||
@ -29,6 +30,7 @@ import java.util.Map;
|
||||
* archive, and delete operations for managing objects in a database.
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class DBManager<T> extends AbstractDbManager<T> {
|
||||
private static final Logger LOGGER = LogManager.getLogger(DBManager.class);
|
||||
|
||||
|
@ -11,6 +11,7 @@ import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
@ -23,6 +24,7 @@ import java.util.List;
|
||||
* This class defines a <code>PolicyManager</code> that stores policies in a
|
||||
* database.
|
||||
*/
|
||||
@Repository
|
||||
public class DBPolicyManager extends DBManager<Policy> implements PolicyManager {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(DBPolicyManager.class);
|
||||
|
@ -1,19 +1,20 @@
|
||||
package hirs.persist;
|
||||
|
||||
import hirs.data.persist.info.PortalInfo;
|
||||
import hirs.data.persist.enums.PortalScheme;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import hirs.data.persist.info.PortalInfo;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
/**
|
||||
* A <code>DBPortalInfoManager</code> is a service (extends <code>DBManager</code>) that
|
||||
* implements the <code>PortalInfoManager</code> that stores and retrieves Portal Info objects.
|
||||
*/
|
||||
@Service
|
||||
public class DBPortalInfoManager extends DBManager<PortalInfo> implements PortalInfoManager {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(DBPortalInfoManager.class);
|
||||
|
@ -11,6 +11,7 @@ import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.query.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
@ -26,6 +27,7 @@ import java.util.UUID;
|
||||
* This class is used to persist and retrieve {@link hirs.data.persist.ReferenceDigestValue}s into
|
||||
* and from the database.
|
||||
*/
|
||||
@Service
|
||||
public class DBReferenceEventManager extends DBManager<ReferenceDigestValue>
|
||||
implements ReferenceEventManager {
|
||||
|
||||
|
@ -3,7 +3,7 @@ package hirs.persist;
|
||||
import hirs.data.persist.ReferenceManifest;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
@ -20,6 +20,7 @@ import java.util.Set;
|
||||
* This class is used to persist and retrieve {@link ReferenceManifest}s into
|
||||
* and from the database.
|
||||
*/
|
||||
@Service
|
||||
public class DBReferenceManifestManager extends DBManager<ReferenceManifest>
|
||||
implements ReferenceManifestManager {
|
||||
|
||||
|
@ -8,6 +8,7 @@ import org.hibernate.criterion.Conjunction;
|
||||
import org.hibernate.criterion.Disjunction;
|
||||
import org.hibernate.criterion.MatchMode;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -20,6 +21,7 @@ import static org.hibernate.criterion.Restrictions.ilike;
|
||||
* This class defines a <code>ReportManager</code> that stores the reports in a
|
||||
* database.
|
||||
*/
|
||||
@Service
|
||||
public class DBReportManager extends DBManager<Report> implements ReportManager {
|
||||
private static final Logger LOGGER = getLogger(DBReportManager.class);
|
||||
|
||||
|
@ -5,6 +5,7 @@ import hirs.data.persist.ReportRequestState;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
@ -17,6 +18,7 @@ import java.util.List;
|
||||
* This class defines a <code>ReportRequestStateManager</code> that stores ReportRequestStates in a
|
||||
* database.
|
||||
*/
|
||||
@Service
|
||||
public class DBReportRequestStateManager extends DBManager<ReportRequestState>
|
||||
implements ReportRequestStateManager {
|
||||
private static final Logger LOGGER = LogManager.getLogger(DBReportRequestStateManager.class);
|
||||
|
@ -7,6 +7,7 @@ import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.query.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
@ -23,6 +24,7 @@ import static org.apache.logging.log4j.LogManager.getLogger;
|
||||
* report
|
||||
* summary in a database.
|
||||
*/
|
||||
@Service
|
||||
public class DBReportSummaryManager extends DBManager<ReportSummary>
|
||||
implements ReportSummaryManager {
|
||||
|
||||
|
@ -3,6 +3,7 @@ package hirs.persist;
|
||||
import hirs.repository.RepoPackage;
|
||||
import hirs.repository.Repository;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@ -11,6 +12,7 @@ import java.util.List;
|
||||
* This class defines a {@link RepositoryManager} that stores Repositories and RepoPackages
|
||||
* in a database.
|
||||
*/
|
||||
@Service
|
||||
public class DBRepositoryManager implements RepositoryManager {
|
||||
private final DBManager<Repository> repositoryDBManager;
|
||||
private final DBManager<RepoPackage> repoPackageDBManager;
|
||||
|
@ -2,6 +2,7 @@ package hirs.persist;
|
||||
|
||||
import hirs.FilteredRecordsList;
|
||||
import hirs.data.persist.Device;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -11,6 +12,7 @@ import java.util.Set;
|
||||
* <code>DeviceManager</code> is used to store and manage devices. It has
|
||||
* support for the basic create, read, update, and delete methods.
|
||||
*/
|
||||
@Repository
|
||||
public interface DeviceManager extends OrderedListQuerier<Device> {
|
||||
|
||||
/**
|
||||
|
@ -1,18 +1,19 @@
|
||||
package hirs.persist;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.context.annotation.PropertySources;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
import org.springframework.orm.hibernate5.HibernateTransactionManager;
|
||||
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@ -86,14 +87,16 @@ public class HibernateConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
HikariDataSource dataSource = new HikariDataSource();
|
||||
dataSource.setJdbcUrl(url);
|
||||
DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
||||
dataSource.setUrl(url);
|
||||
dataSource.setUsername(username);
|
||||
dataSource.setPassword(password);
|
||||
dataSource.setDriverClassName(driverClass);
|
||||
dataSource.setMaximumPoolSize(Integer.parseInt(maximumPoolSize));
|
||||
dataSource.setConnectionTimeout(Long.parseLong(connectionTimeout));
|
||||
dataSource.setLeakDetectionThreshold(Long.parseLong(leakDetectionThreshold));
|
||||
|
||||
// dataSource.setMaximumPoolSize(Integer.parseInt(maximumPoolSize));
|
||||
// dataSource.setConnectionTimeout(Long.parseLong(connectionTimeout));
|
||||
// dataSource.setLeakDetectionThreshold(Long.parseLong(leakDetectionThreshold));
|
||||
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
@ -121,26 +124,71 @@ public class HibernateConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
public LocalSessionFactoryBean sessionFactory() {
|
||||
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
|
||||
sessionFactory.setDataSource(dataSource());
|
||||
// Hibernate 5.4 SessionFactory example without XML
|
||||
Map<String, String> settings = new HashMap<>();
|
||||
settings.put("connection.driver_class", "com.mysql.jdbc.Driver");
|
||||
settings.put("dialect", "org.hibernate.dialect.MySQL8Dialect");
|
||||
settings.put("hibernate.connection.url",
|
||||
"jdbc:mysql://localhost/hibernate_examples");
|
||||
settings.put("hibernate.connection.username", "root");
|
||||
settings.put("hibernate.connection.password", "root");
|
||||
settings.put("hibernate.current_session_context_class", "thread");
|
||||
settings.put("hibernate.show_sql", "true");
|
||||
settings.put("hibernate.format_sql", "true");
|
||||
|
||||
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
|
||||
.applySettings(settings).build();
|
||||
|
||||
MetadataSources metadataSources = new MetadataSources(serviceRegistry);
|
||||
// metadataSources.addAnnotatedClass(Player.class);
|
||||
Metadata metadata = metadataSources.buildMetadata();
|
||||
|
||||
// here we build the SessionFactory (Hibernate 5.4)
|
||||
LocalSessionFactoryBean sessionFactory = (LocalSessionFactoryBean) metadata
|
||||
.getSessionFactoryBuilder()
|
||||
.build();
|
||||
sessionFactory.setHibernateProperties(hibernateProperties());
|
||||
sessionFactory.setPackagesToScan("hirs");
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
// public static SessionFactory getCurrentSessionFromJPA() {
|
||||
// // JPA and Hibernate SessionFactory example
|
||||
// EntityManagerFactory emf =
|
||||
// Persistence.createEntityManagerFactory("jpa-tutorial");
|
||||
// EntityManager entityManager = emf.createEntityManager();
|
||||
// // Get the Hibernate Session from the EntityManager in JPA
|
||||
// Session session = entityManager.unwrap(org.hibernate.Session.class);
|
||||
// SessionFactory factory = session.getSessionFactory();
|
||||
// return factory;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Configures a session factory bean that in turn configures the hibernate session factory.
|
||||
// * Enables auto scanning of annotations such that entities do not need to be registered in a
|
||||
// * hibernate configuration file.
|
||||
// *
|
||||
// * @return session factory
|
||||
// */
|
||||
// @Bean
|
||||
// public LocalSessionFactoryBean sessionFactory() {
|
||||
// LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
|
||||
// sessionFactory.setDataSource(dataSource());
|
||||
// sessionFactory.setHibernateProperties(hibernateProperties());
|
||||
// sessionFactory.setPackagesToScan("hirs");
|
||||
// return sessionFactory;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Configure a transaction manager for the hibernate session factory.
|
||||
*
|
||||
* @return transaction manager
|
||||
*/
|
||||
@Bean
|
||||
public HibernateTransactionManager transactionManager() {
|
||||
SessionFactory sessionFactory = sessionFactory().getObject();
|
||||
if (sessionFactory != null) {
|
||||
return new HibernateTransactionManager(sessionFactory);
|
||||
} else {
|
||||
return new HibernateTransactionManager();
|
||||
}
|
||||
public HibernateTransactionManager getTransactionManager() {
|
||||
HibernateTransactionManager transactionManager = new HibernateTransactionManager();
|
||||
transactionManager.setSessionFactory(sessionFactory().getObject());
|
||||
return transactionManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,5 @@
|
||||
package hirs.persist;
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.joda.time.Interval;
|
||||
import org.joda.time.LocalDateTime;
|
||||
import org.joda.time.LocalTime;
|
||||
@ -8,7 +7,6 @@ import org.joda.time.Period;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@ -26,7 +24,6 @@ public class ScheduledJobInfo {
|
||||
public static final LocalTime DEFAULT_START_TIME = new LocalTime(22, 0, 0);
|
||||
|
||||
@Column
|
||||
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalTime")
|
||||
private LocalTime startTime;
|
||||
|
||||
@Column
|
||||
|
@ -2,7 +2,6 @@ package hirs.repository;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import hirs.data.persist.Digest;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
@ -33,7 +32,6 @@ import java.util.UUID;
|
||||
public abstract class RepoPackage {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@Type(type = "uuid-char")
|
||||
private UUID id;
|
||||
|
||||
@Column
|
||||
|
@ -1,6 +1,6 @@
|
||||
package hirs.utils;
|
||||
|
||||
import org.hibernate.dialect.MySQL5InnoDBDialect;
|
||||
import org.hibernate.dialect.MySQLDialect;
|
||||
|
||||
/**
|
||||
* This class is a shim on top of the standard MySQL5InnoDBDialect to set the row format
|
||||
@ -24,7 +24,7 @@ import org.hibernate.dialect.MySQL5InnoDBDialect;
|
||||
* https://dev.mysql.com/doc/refman/5.7/en/innodb-row-format-dynamic.html
|
||||
* https://dev.mysql.com/doc/refman/5.5/en/innodb-restrictions.html
|
||||
*/
|
||||
public class MySqlUtf8CompatibleDialect extends MySQL5InnoDBDialect {
|
||||
public class MySqlUtf8CompatibleDialect extends MySQLDialect {
|
||||
/**
|
||||
* Returns the table 'type' string, which specifies the storage engine (via the
|
||||
* super call) and appends the desired row format.
|
||||
|
@ -106,10 +106,9 @@ subprojects {
|
||||
findbugs: 'com.google.code.findbugs:findbugs:3.0.0',
|
||||
gson: 'com.google.code.gson:gson:2.9.0',
|
||||
guava: 'com.google.guava:guava:31.1-jre',
|
||||
hibernate: [ 'org.hibernate.common:hibernate-commons-annotations:5.0.0.Final',
|
||||
'org.hibernate:hibernate-core:5.0.0.Final',
|
||||
'org.hibernate:hibernate-hikaricp:5.0.0.Final'],
|
||||
// hikari: 'com.zaxxer:HikariCP:5.0.1',
|
||||
hibernate: [ 'org.hibernate.common:hibernate-commons-annotations:5.1.1.Final',
|
||||
'org.hibernate:hibernate-core:5.2.4.Final',
|
||||
'org.hibernate:hibernate-hikaricp:5.2.4.Final'],
|
||||
hsqldb: 'org.hsqldb:hsqldb:2.6.1',
|
||||
http: 'org.apache.httpcomponents:httpclient:4.5.13',
|
||||
jackson: [ 'com.fasterxml.jackson.core:jackson-core:2.13.2',
|
||||
|
Loading…
x
Reference in New Issue
Block a user