1
2
3
4
5
6
7
8
9
10
11
12
13
14 package uk.nhs.interoperability.service;
15
16 import java.text.SimpleDateFormat;
17 import java.util.Calendar;
18 import java.util.Date;
19
20 import uk.nhs.interoperability.capabilities.AuditException;
21 import uk.nhs.interoperability.capabilities.AuditService;
22 import uk.nhs.interoperability.infrastructure.ITKMessageProperties;
23
24 import com.xmlsolutions.annotation.Requirement;
25
26
27
28
29
30
31
32
33 @Requirement(traceTo={"IFA-SEC-02"}, status="in-progress")
34 public class ITKSimpleAudit implements AuditService {
35
36
37 private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
38
39
40 private static final Calendar CAL = Calendar.getInstance();
41
42
43 private static final ITKSimpleAudit _INSTANCE = new ITKSimpleAudit();
44
45
46
47
48 @Override
49 @Requirement(traceTo={"COR-DEH-04"}, status="in-progress")
50 public void auditEvent(String event, long eventTime, ITKMessageProperties itkMessageProperties) throws AuditException {
51 if (itkMessageProperties == null && event == null) {
52 throw new AuditException("Could not write audit as either the ITKMessageProperties and/or event was not provided");
53 }
54 System.out.println(DATE_FORMAT.format(CAL.getTime())
55 + " [AUDIT] " + event + " at " + DATE_FORMAT.format(new Date(eventTime))
56 + " from " + itkMessageProperties.getAuditIdentity());
57
58 }
59
60
61
62
63
64
65 public static final AuditService getInstance() {
66 return _INSTANCE;
67 }
68
69 }