code optimization for "HisTpmProvisioner"
      -incorrect error message
      -redundant and dead code
      -known issue existed with bouncy castle
      -hard coding
      -unformatted code
TODO: track the message in client's log file instead of print out in console directly.

Signed-off-by: Dave Chen <wei.d.chen@intel.com>
code optimization for part of client files: HisIdentityProvisioner.java, HisRegisterIdentity.java, StandaloneHIS.java
Signed-off-by: Dave Chen <wei.d.chen@intel.com>
Installer: Added configuration properties for storing the IR on file

This patch introduces two configuration variables used by the
functions for reading and writing the report on file.

The property 'IR_DIR' permits the user to define the directory where
the integrity report will be stored; if not set (default) the IR
is stored on DB.

The property 'IR_DIGEST_METHOD' permits the user to chose the digest
method used to check the integrity of the IR; SHA-256 is its default
value.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Installer: Added validation of OAT.properties to tomcat6 service scripts

This patch updates tomcat6 service scripts introducing the validation
of the new property IR_DIR, placed in file OAT.properties. If the
property is set, the IR will be placed in the given directory, then
if the directory doesn't exist tomcat won't start.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
HisAppraiser: Implemented functions for reading/writing IR on file

This patch adds functions for reading and writing IR on file instead
of storing it in table AuditLog. The reading function receives the ID
of the report on table AuditLog and the content of the corresponding
field Report. The function retrieves the report file, computes the hash
using the digest method read from the field Report and returns the XML
report string if the computed hash and the received one match.

The writing function receives the ID of the report on table AuditLog
and the report string; it computes the hash of the string using
the digest method read from configuration file, writes the report in
file and returns report string to be written on DB.

The new syntax of the field Report in table AuditLog is as follows:

	report_digest:<digest_method>:<digest_value>

It's still possible to save IR on DB. The writing function returns
the received reportString if the property 'IR_DIR' is not set; in
this case the field 'Report' contains the XML integirty report and
the reading function returns its content as is.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
HisAppraiser: Added fetchReport() to retrieve report string from ID

This patch adds to the Appraiser a new function fetchReport() that
receives the ID of the report and returns its content.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
HisWebServices: Implemented new web service HisDownloadReportService

This patch adds a new web service (called HisDownloadReportService)
whose function fetchReport() returns the XML string of the integrity
report.

The introduction of this new web service is needed because,
since reports will be stored into the filesystem, the Portal
would have no means to obtain them if it is not running on
the same machine that executes the Appraiser tasks (currently,
the Portal connects directly to the DB).

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
HisWebServices: Updated html files describing available services

Each web service in OAT comes with a html file describing available
web services; this patch updates that files with information about
the new service HisDownloadReportService.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Portal: Used HisDownloadReportService to obtain IR

This patch updates the Portal behaviour, obtaining the integrity
report through the new web service HisDownloadReportService instead
of using DB. This change is required in order to maintain Portal
functionality.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
HisAppraiser: Added function updateAuditLog() to HisAuditDao

This patch adds the new function updateAuditLog() to HisAuditDao.
It updates an existing AuditLog and it will be used to update the
field 'Report' with the output of the writing function previously
implemented.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
HisAppraiser: using readIR() and writeIR() to respectively
read and write integrity reports

This patch replaces functions used by the Appraiser to read
and write the integrity report with readIR() and writeIR().

The benefit of using these functions is that callers
will not need to know how a report is stored in the
machine that executes Appraiser tasks but instead
they have only to pass the ID of the AuditLog record
and the report string as arguments.

A failure during writeIR() execution (e.g. given IR_DIR
does not exist) will result in the timeout of the attestation
request.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
AttestationService: Added element "url" in attestation response

This patch adds to the attestation response a new element ("url")
that contains the URL of report on Portal.

The new structure of attestation result is as follows:
{
	"hosts": [{
		"host_name": "host1",
		"trust_lvl": "untrusted",
		"url": "http://server/OAT/report.php?id=34",
		"vtime": "2013-10-07T11:50:29.715+02:00"
	}]
}

The address of portal is read from a new property ("portal_address")
in OpenAttestationWebServices.properties; its default value is the
localhost hostname and it's set at installation time.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Added documentation for new file-based storage method for IR

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Installer, HisAppraiser: Added field reportCompareErrors

This patch introduces a distinction between errors related to
the report validation and errors related to the comparison with
last report received.
The first type of errors are still stored in the field
reportErrors of table AuditLog, while comparison-related
errors are stored in the new field compareReportErrors of
the same table.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Installer, HisAppraiser: Field reportErrors renamed to validationErrors

Last patch has introduced a new field reportCompareErrors to
table AttestRequest, and now the former field reportErrors only
contains errors related to report validation. Then this patch
renames the field reportErrors to a more meaningful validationErrors.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
HisAppraiser: Updated error messages of function comparePreviousReport()

This patch updates error messages that function comparePreviousReport()
writes in the field compareReportErrors. The new syntax is as follows:
 - "PCR #0 new": PCR not found in last report;
 - "PCR #0 absent": PCR not found in current report;
 - "PCR #0 differs": PCR values don't match.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
AttestationService: Added element "report_is_valid" in attest response

This patch adds a new element ("report_is_valid") to the attestation
response. It contains the result of signature validation performed by
the constructor of class HisReportValidator.

The new structure of the attestation result is as follows:
{
	"hosts": [{
		"host_name": "host1",
		"report_is_valid": "[true|false]",
		"trust_lvl": "untrusted",
		"vtime": "2013-10-07T11:50:29.715+02:00"
	}]
}

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Installer, HisAppraiser: Added field analysisRequest to AttestRequest

This patch adds a new field (analysisRequest) to table AttestRequest.
It contains the analyses requested by the user and that will be
introduced by next patches.
In order to permit the user to write the field analysisRequest,
the attestation request will be properly updated later.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Installer, HisAppraiser: Added field analysisResults to AttestRequest

This patch adds a new field (analysisResults) to table AttestRequest. It
will contain the result of analyses requested by the user and its syntax
is as follows:

	analysis_id|result|status|output_length|output;

where: "result" can be "true" or "false"; "status" contains the
status of the analysis execution; "output" is the output of the
analysis, if it exists.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
HisAppraiser: Updated position of setResult() and setValidateTime()

This patch modifies the function validatePCRReport() so that
it will be compatible with the new extension that adds support
for multiple analyses.

With the new extension, first the overall verification result
is set to 'trusted' if the report validation is completed successfully.
Then, each analysis only sets the overall result to 'untrusted' if the
result of the analysis itself is negative. With this change, the
'result' field of an attestation response is obtained by the AND
(logic operator) of partial results of the analyses (and the result
of the report validation).

Finally, since there could be multiple analyses, the validate
time of an attestation response is determined after all analyses are
completed.

Signed-off-by: Nicola Barresi <nicola.barresi@polito.it>
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>