public class SecurityLabelDemo extends java.lang.Object
SecurityLabel
attribute may be
included as signed attribute in a SignerInfo
for
providing some kind of "access control" mechanism for the contents of a message.
This demo uses a simple SecurityLabelHandler
that only implements a simple security policy based on
the default security classifications "unmarked", "unclassified", "restricted",
"confidential", "secret", "top-secret". Since the SignedData message created
by this demo only contains an ESS SecurityLabel
attribute with classification "confidential", only this
classification is processed by the demo handler
. "unmarked" and "unclassified" are handled as "not critical"
content (i.e. the content can be accessed by any one), "secret", "top-secret"
lock the content (i.e. it is not displayed), and "restricted" and
"confidential" popup a confirmation dialog reminding the recipient about
the confidentiality of the message content.
To run this demo the following packages are required:
iaik_cms.jar
iaik_jce(_full).jar
(IAIK-JCE Core Crypto Library).
MySecurityLabelHandler
,
ESSSecurityLabel
Constructor and Description |
---|
SecurityLabelDemo()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
jakarta.mail.Message |
createMessage(jakarta.mail.Session session,
java.lang.String subject)
Creates a MIME message container with the given subject for the given session.
|
jakarta.mail.Message |
createSignedMessage(jakarta.mail.Session session)
Creates a signed message containing an ESS SecurityLabel attribute.
|
static void |
main(java.lang.String[] argv)
The main method.
|
void |
parseMessage(jakarta.mail.Message msg)
Parses the signed message, verifies the signature and processes the SecurityLabel
attribute.
|
void |
start()
Starts the demo.
|
public SecurityLabelDemo()
public void start() throws java.io.IOException
java.io.IOException
- if an I/O related error occurspublic jakarta.mail.Message createMessage(jakarta.mail.Session session, java.lang.String subject) throws jakarta.mail.MessagingException
session
- the mail sesionsubject
- the subject of the messagejakarta.mail.MessagingException
- if the message cannot be createdpublic jakarta.mail.Message createSignedMessage(jakarta.mail.Session session) throws java.lang.Exception
session
- the mail sessionjava.lang.Exception
- if an error occurs when creating the messagepublic void parseMessage(jakarta.mail.Message msg) throws java.io.IOException, jakarta.mail.MessagingException, java.security.SignatureException
msg
- the message to be parsedjava.io.IOException
- if an I/O related problem occursjakarta.mail.MessagingException
- if there is a problem with the message formatjava.security.SignatureException
- if the signature verification failespublic static void main(java.lang.String[] argv) throws java.io.IOException
java.io.IOException