mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-02-08 20:30:11 +00:00
Additional classes created, certificate, reference manifest and digest
values. Created default service for common classes.
This commit is contained in:
parent
b8ca5f9ea9
commit
fa7eef6857
@ -0,0 +1,14 @@
|
|||||||
|
package hirs.attestationca.repository;
|
||||||
|
|
||||||
|
import hirs.data.persist.certificate.Certificate;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setting up for new creation for CRUD operations.
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public interface CertificateRepository extends JpaRepository<Certificate, UUID> {
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package hirs.attestationca.repository;
|
||||||
|
|
||||||
|
import hirs.data.persist.ReferenceDigestValue;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setting up for new creation for CRUD operations.
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public interface ReferenceDigestValueRepository extends JpaRepository<ReferenceDigestValue, UUID> {
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package hirs.attestationca.repository;
|
||||||
|
|
||||||
|
import hirs.data.persist.ReferenceManifest;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setting up for new creation for CRUD operations.
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public interface ReferenceManifestRepository extends JpaRepository<ReferenceManifest, UUID> {
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package hirs.attestationca.service;
|
||||||
|
|
||||||
|
import hirs.data.persist.certificate.Certificate;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A <code>CertificateService</code> manages <code>Certificate</code>s. A
|
||||||
|
* <code>CertificateService</code> is used to store and manage certificates. It has
|
||||||
|
* support for the basic create, read, update, and delete methods.
|
||||||
|
*/
|
||||||
|
public interface CertificateService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the <code>Certificate</code> in the database. This creates a new
|
||||||
|
* database session and saves the device.
|
||||||
|
*
|
||||||
|
* @param certificate Certificate to save
|
||||||
|
* @return reference to saved certificate
|
||||||
|
*/
|
||||||
|
Certificate saveCertificate(Certificate certificate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a <code>Certificate</code>. This updates the database entries to
|
||||||
|
* reflect the new values that should be set.
|
||||||
|
*
|
||||||
|
* @param certificate Certificate object to save
|
||||||
|
* @param uuid UUID for the database object
|
||||||
|
* @return a Certificate object
|
||||||
|
*/
|
||||||
|
Certificate updateCertificate(Certificate certificate, UUID uuid);
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
package hirs.attestationca.service;
|
||||||
|
|
||||||
|
import hirs.FilteredRecordsList;
|
||||||
|
import hirs.attestationca.repository.CertificateRepository;
|
||||||
|
import hirs.data.persist.certificate.Certificate;
|
||||||
|
import hirs.persist.CriteriaModifier;
|
||||||
|
import hirs.persist.DBManagerException;
|
||||||
|
import hirs.persist.OrderedQuery;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A <code>CertificateServiceImpl</code> manages <code>Certificate</code>s. A
|
||||||
|
* <code>CertificateServiceImpl</code> is used to store and manage certificates. It has
|
||||||
|
* support for the basic create, read, update, and delete methods.
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CertificateServiceImpl implements DefaultService<Certificate>,
|
||||||
|
CertificateService, OrderedQuery<Certificate> {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
@Autowired
|
||||||
|
private CertificateRepository certificateRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Certificate saveCertificate(final Certificate certificate) {
|
||||||
|
LOGGER.debug("Saving certificate: {}", certificate);
|
||||||
|
return certificateRepository.save(certificate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Certificate updateCertificate(final Certificate certificate,
|
||||||
|
final UUID uuid) {
|
||||||
|
LOGGER.debug("Updating certificate: {}", certificate);
|
||||||
|
Certificate dbCertificate;
|
||||||
|
|
||||||
|
if (uuid == null) {
|
||||||
|
LOGGER.debug("Certificate not found: {}", certificate);
|
||||||
|
dbCertificate = certificate;
|
||||||
|
} else {
|
||||||
|
// will not return null, throws and exception
|
||||||
|
dbCertificate = certificateRepository.getReferenceById(uuid);
|
||||||
|
|
||||||
|
// run through things that aren't equal and update
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
certificateRepository.save(dbCertificate);
|
||||||
|
|
||||||
|
return dbCertificate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Certificate> getList() {
|
||||||
|
LOGGER.debug("Getting all certificates...");
|
||||||
|
return this.certificateRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteObjectById(final UUID uuid) {
|
||||||
|
LOGGER.debug("Deleting certificate by id: {}", uuid);
|
||||||
|
this.certificateRepository.deleteById(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FilteredRecordsList getOrderedList(
|
||||||
|
final Class<Certificate> clazz, final String columnToOrder,
|
||||||
|
final boolean ascending, final int firstResult, final int maxResults,
|
||||||
|
final String search, final Map<String, Boolean> searchableColumns)
|
||||||
|
throws DBManagerException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FilteredRecordsList<Certificate> getOrderedList(
|
||||||
|
final Class<Certificate> clazz, final String columnToOrder,
|
||||||
|
final boolean ascending, final int firstResult, final int maxResults,
|
||||||
|
final String search, final Map<String, Boolean> searchableColumns,
|
||||||
|
final CriteriaModifier criteriaModifier)
|
||||||
|
throws DBManagerException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package hirs.attestationca.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A <code>DefaultService</code> manages base operations. A
|
||||||
|
* <code>DefaultService</code> is used to store and manage devices. It has
|
||||||
|
* support for the basic create, read, update, and delete methods.
|
||||||
|
* @param <T> class type
|
||||||
|
*/
|
||||||
|
public interface DefaultService<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all <code>T</code>. This searches through
|
||||||
|
* the database for this information.
|
||||||
|
*
|
||||||
|
* @return list of <code>T</code>
|
||||||
|
*/
|
||||||
|
List<T> getList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the <code>T</code> from the database. This removes all
|
||||||
|
* of the database entries that stored information with regards to the
|
||||||
|
* <code>T</code> with a foreign key relationship.
|
||||||
|
*
|
||||||
|
* @param uuid of the object to be deleted
|
||||||
|
*/
|
||||||
|
void deleteObjectById(UUID uuid);
|
||||||
|
}
|
@ -28,16 +28,6 @@ public interface DeviceService {
|
|||||||
*/
|
*/
|
||||||
Device saveDevice(Device device) throws DeviceManagerException;
|
Device saveDevice(Device device) throws DeviceManagerException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of all <code>Devices</code>. This searches through
|
|
||||||
* the database for this information.
|
|
||||||
*
|
|
||||||
* @return list of <code>Devices</code>
|
|
||||||
* @throws DeviceManagerException
|
|
||||||
* if unable to search the database
|
|
||||||
*/
|
|
||||||
List<Device> getDeviceList();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a <code>Device</code>. This updates the database entries to
|
* Updates a <code>Device</code>. This updates the database entries to
|
||||||
* reflect the new values that should be set.
|
* reflect the new values that should be set.
|
||||||
@ -63,16 +53,4 @@ public interface DeviceService {
|
|||||||
* while trying to save it to the database
|
* while trying to save it to the database
|
||||||
*/
|
*/
|
||||||
void updateDeviceList(List<Device> deviceList) throws DeviceManagerException;
|
void updateDeviceList(List<Device> deviceList) throws DeviceManagerException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes the <code>Device</code> from the database. This removes all
|
|
||||||
* of the database entries that stored information with regards to the
|
|
||||||
* <code>Device</code> with a foreign key relationship.
|
|
||||||
*
|
|
||||||
* @param deviceId of the device to be deleted
|
|
||||||
* @throws DeviceManagerException
|
|
||||||
* if unable to find the device group or delete it from the
|
|
||||||
* database
|
|
||||||
*/
|
|
||||||
void deleteDeviceById(UUID deviceId) throws DeviceManagerException;
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,8 @@ import java.util.UUID;
|
|||||||
* support for the basic create, read, update, and delete methods.
|
* support for the basic create, read, update, and delete methods.
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class DeviceServiceImpl implements DeviceService, OrderedQuery<Device> {
|
public class DeviceServiceImpl implements DefaultService<Device>,
|
||||||
|
DeviceService, OrderedQuery<Device> {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -34,12 +35,6 @@ public class DeviceServiceImpl implements DeviceService, OrderedQuery<Device> {
|
|||||||
return deviceRepository.save(device);
|
return deviceRepository.save(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final List<Device> getDeviceList() {
|
|
||||||
LOGGER.debug("Getting all devices...");
|
|
||||||
return deviceRepository.findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Device updateDevice(final Device device, final UUID deviceId)
|
public final Device updateDevice(final Device device, final UUID deviceId)
|
||||||
throws DeviceManagerException {
|
throws DeviceManagerException {
|
||||||
@ -72,14 +67,19 @@ public class DeviceServiceImpl implements DeviceService, OrderedQuery<Device> {
|
|||||||
this.updateDevice(device, device.getId());
|
this.updateDevice(device, device.getId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void deleteDeviceById(final UUID deviceId)
|
public final List<Device> getList() {
|
||||||
|
LOGGER.debug("Getting all devices...");
|
||||||
|
return deviceRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void deleteObjectById(final UUID uuid)
|
||||||
throws DeviceManagerException {
|
throws DeviceManagerException {
|
||||||
LOGGER.debug("Deleting deviceById: {}", deviceId);
|
LOGGER.debug("Deleting deviceById: {}", uuid);
|
||||||
deviceRepository.deleteById(deviceId);
|
deviceRepository.deleteById(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
package hirs.attestationca.service;
|
||||||
|
|
||||||
|
import hirs.data.persist.ReferenceDigestValue;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A <code>ReferenceDigestValue</code> manages <code>ReferenceDigestValue</code>s. A
|
||||||
|
* <code>ReferenceDigestValue</code> is used to store and manage digest events. It has
|
||||||
|
* support for the basic create, read, update, and delete methods.
|
||||||
|
*/
|
||||||
|
public interface ReferenceDigestValueService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the <code>ReferenceDigestValue</code> in the database. This creates a new
|
||||||
|
* database session and saves the device.
|
||||||
|
*
|
||||||
|
* @param digestValue Certificate to save
|
||||||
|
* @return reference to saved reference digest value
|
||||||
|
*/
|
||||||
|
ReferenceDigestValue saveDigestValue(ReferenceDigestValue digestValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a <code>ReferenceDigestValue</code>. This updates the database entries to
|
||||||
|
* reflect the new values that should be set.
|
||||||
|
*
|
||||||
|
* @param digestValue Certificate object to save
|
||||||
|
* @param uuid UUID for the database object
|
||||||
|
* @return a ReferenceDigestValue object
|
||||||
|
*/
|
||||||
|
ReferenceDigestValue updateDigestValue(ReferenceDigestValue digestValue, UUID uuid);
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package hirs.attestationca.service;
|
||||||
|
|
||||||
|
import hirs.attestationca.repository.ReferenceDigestValueRepository;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A <code>ReferenceDigestValueServiceImpl</code> manages <code>Digest Value Event</code>s. A
|
||||||
|
* <code>ReferenceDigestValueServiceImpl</code> is used to store and manage digest events. It has
|
||||||
|
* support for the basic create, read, update, and delete methods.
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ReferenceDigestValueServiceImpl {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
@Autowired
|
||||||
|
private ReferenceDigestValueRepository referenceDigestValueRepository;
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package hirs.attestationca.service;
|
||||||
|
|
||||||
|
import hirs.data.persist.ReferenceManifest;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A <code>ReferenceManifestService</code> manages <code>ReferenceManifest</code>s. A
|
||||||
|
* <code>ReferenceManifestService</code> is used to store and manage reference manifests. It has
|
||||||
|
* support for the basic create, read, update, and delete methods.
|
||||||
|
*/
|
||||||
|
public interface ReferenceManifestService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the <code>ReferenceManifest</code> in the database. This creates a new
|
||||||
|
* database session and saves the device.
|
||||||
|
*
|
||||||
|
* @param rim ReferenceManifest to save
|
||||||
|
* @return reference to saved rim
|
||||||
|
*/
|
||||||
|
ReferenceManifest saveRIM(ReferenceManifest rim);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a <code>ReferenceManifest</code>. This updates the database entries to
|
||||||
|
* reflect the new values that should be set.
|
||||||
|
*
|
||||||
|
* @param rim ReferenceManifest object to save
|
||||||
|
* @param uuid UUID for the database object
|
||||||
|
* @return a ReferenceManifest object
|
||||||
|
*/
|
||||||
|
ReferenceManifest updateReferenceManifest(ReferenceManifest rim, UUID uuid);
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
package hirs.attestationca.service;
|
||||||
|
|
||||||
|
import hirs.FilteredRecordsList;
|
||||||
|
import hirs.attestationca.repository.ReferenceManifestRepository;
|
||||||
|
import hirs.data.persist.ReferenceManifest;
|
||||||
|
import hirs.persist.CriteriaModifier;
|
||||||
|
import hirs.persist.DBManagerException;
|
||||||
|
import hirs.persist.OrderedQuery;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A <code>ReferenceManifestServiceImpl</code> manages <code>ReferenceManifestService</code>s. A
|
||||||
|
* <code>ReferenceManifestServiceImpl</code> is used to store and manage reference manifest. It has
|
||||||
|
* support for the basic create, read, update, and delete methods.
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ReferenceManifestServiceImpl implements DefaultService<ReferenceManifest>,
|
||||||
|
ReferenceManifestService, OrderedQuery<ReferenceManifest> {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
@Autowired
|
||||||
|
private ReferenceManifestRepository referenceManifestRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReferenceManifest saveRIM(final ReferenceManifest rim) {
|
||||||
|
LOGGER.debug("Saving reference manifest: {}", rim);
|
||||||
|
return referenceManifestRepository.save(rim);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReferenceManifest updateReferenceManifest(final ReferenceManifest rim,
|
||||||
|
final UUID uuid) {
|
||||||
|
LOGGER.debug("Updating reference manifest: {}", rim);
|
||||||
|
ReferenceManifest dbRim;
|
||||||
|
|
||||||
|
if (uuid == null) {
|
||||||
|
LOGGER.debug("Reference Manifest not found: {}", rim);
|
||||||
|
dbRim = rim;
|
||||||
|
} else {
|
||||||
|
// will not return null, throws and exception
|
||||||
|
dbRim = referenceManifestRepository.getReferenceById(uuid);
|
||||||
|
|
||||||
|
// run through things that aren't equal and update
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
referenceManifestRepository.save(dbRim);
|
||||||
|
|
||||||
|
return dbRim;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ReferenceManifest> getList() {
|
||||||
|
LOGGER.debug("Getting all reference manifest...");
|
||||||
|
return this.referenceManifestRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteObjectById(final UUID uuid) {
|
||||||
|
LOGGER.debug("Deleting reference manifest by id: {}", uuid);
|
||||||
|
this.referenceManifestRepository.deleteById(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FilteredRecordsList getOrderedList(
|
||||||
|
final Class<ReferenceManifest> clazz, final String columnToOrder,
|
||||||
|
final boolean ascending, final int firstResult, final int maxResults,
|
||||||
|
final String search, final Map<String, Boolean> searchableColumns)
|
||||||
|
throws DBManagerException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FilteredRecordsList<ReferenceManifest> getOrderedList(
|
||||||
|
final Class<ReferenceManifest> clazz, final String columnToOrder,
|
||||||
|
final boolean ascending, final int firstResult, final int maxResults,
|
||||||
|
final String search, final Map<String, Boolean> searchableColumns,
|
||||||
|
final CriteriaModifier criteriaModifier)
|
||||||
|
throws DBManagerException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user