com.sap.security.core.server.ssf
Class SsfDataSMIME

java.lang.Object
  |
  +--com.sap.security.core.server.ssf.SsfDataSMIME
All Implemented Interfaces:
ISsfData

public class SsfDataSMIME
extends java.lang.Object
implements ISsfData

Class for representing data to be digitally signed, verified, encrypted or decrypted, using S/MIME as security format.


Fields inherited from interface com.sap.security.api.ssf.ISsfData
ALG_AES128_CBC, ALG_DES_EDE3_CBC, ALG_MD5, ALG_RC2_40_CBC, ALG_RC2_CBC, ALG_SHA, INC_CERT_CHAIN, INC_CERT_CHAIN_ROOT, INC_CERT_NONE, INC_CERT_OWN
 
Constructor Summary
SsfDataSMIME(java.io.InputStream is, javax.mail.Session sess)
          Constructs SsfDataSMIME object from an InputStream
SsfDataSMIME(javax.mail.internet.MimeMessage mess, javax.mail.Session sess)
          Constructs SsfDataSMIME object from a MimeMessage
 
Method Summary
 boolean decrypt(ISsfProfile profile)
          Decrypts the given data.
 boolean encrypt(SsfSigRcpList rcpList, ISsfPab pab)
          Encrypts the given data.
 boolean encrypt(SsfSigRcpList rcpList, ISsfPab pab, java.lang.String symAlg)
          Encrypts the given data.
 javax.mail.internet.MimeMessage getDataSMIME()
          Get message which results from previous operations
 void setNewContentTypes(boolean newContentTypes)
          Sets the parameter newContentTypes.
 boolean sign(ISsfProfile profile)
          Creates a digital siganture of the given data.
 boolean sign(ISsfProfile profile, java.lang.String mdAlg, int incCerts, boolean detached)
          Creates a digital siganture of the given data.
 java.lang.String toString()
          Get information about the S/MIME data
 boolean verify(ISsfPab pab, SsfSigRcpList sigList)
          Verifies a digital signature of the given data.
 boolean verify(ISsfPab pab, SsfSigRcpList sigList, ISsfData input, java.security.cert.X509Certificate cert)
          Verifies a digital signature of the given data.
 boolean verify(ISsfPab pab, SsfSigRcpList sigList, java.security.cert.X509Certificate cert)
          Verifies a digital signature of the given data.
 boolean writeTo(java.io.OutputStream out)
          Writes the changed data to an output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SsfDataSMIME

public SsfDataSMIME(java.io.InputStream is,
                    javax.mail.Session sess)
             throws SsfInvalidDataException
Constructs SsfDataSMIME object from an InputStream
Parameters:
is - InputStream containing the data
sess - Session of MimeMessage (may be null)
Throws:
SsfInvalidDataException - if no MIME data is supplied

SsfDataSMIME

public SsfDataSMIME(javax.mail.internet.MimeMessage mess,
                    javax.mail.Session sess)
             throws SsfInvalidDataException
Constructs SsfDataSMIME object from a MimeMessage
Parameters:
mess - MimeMessage object
sess - Session of MimeMessage (may be null)
Throws:
SsfInvalidDataException - if no MIME data is supplied
Method Detail

sign

public boolean sign(ISsfProfile profile)
             throws SsfInvalidKeyException
Description copied from interface: ISsfData
Creates a digital siganture of the given data.
Specified by:
sign in interface ISsfData
See Also:
ISsfData.sign(com.sap.security.api.ssf.ISsfProfile)

sign

public boolean sign(ISsfProfile profile,
                    java.lang.String mdAlg,
                    int incCerts,
                    boolean detached)
             throws SsfInvalidKeyException,
                    SsfInvalidAlgException
Description copied from interface: ISsfData
Creates a digital siganture of the given data.
Specified by:
sign in interface ISsfData
See Also:
ISsfData.sign(com.sap.security.api.ssf.ISsfProfile)

verify

public boolean verify(ISsfPab pab,
                      SsfSigRcpList sigList)
               throws SsfInvalidDataException
Description copied from interface: ISsfData
Verifies a digital signature of the given data.
Specified by:
verify in interface ISsfData
See Also:
ISsfData.verify(com.sap.security.api.ssf.ISsfPab, com.sap.security.core.server.ssf.SsfSigRcpList)

verify

public boolean verify(ISsfPab pab,
                      SsfSigRcpList sigList,
                      ISsfData input,
                      java.security.cert.X509Certificate cert)
               throws SsfInvalidDataException
Verifies a digital signature of the given data.
Specified by:
verify in interface ISsfData
Parameters:
pab - personal address book containing trusted certificates (if null, all certificates are considered as trusted, i.e. the signer certificates must be validated by the caller)
sigList - list of signer information
input - ignored parameter, pass null)
cert - certificate to be used for verification (if null, use certificate included in signed data)
Returns:
verify(pab, signer, (X509Certificate[]) null)
Throws:
SsfInvalidDataException - if given data is not digitally signed

verify

public boolean verify(ISsfPab pab,
                      SsfSigRcpList sigList,
                      java.security.cert.X509Certificate cert)
               throws SsfInvalidDataException
Verifies a digital signature of the given data.
Parameters:
pab - personal address book containing trusted certificates (if null, all certificates are considered as trusted, i.e. the signer certificates must be validated by the caller)
sigList - list of signer information
cert - certificate to be used for verification (if null, use certificate included in signed data)
Returns:
true if (at least one) signature could be verified
Throws:
SsfInvalidDataException - if given data is not digitally signed

encrypt

public boolean encrypt(SsfSigRcpList rcpList,
                       ISsfPab pab)
                throws SsfInvalidKeyException
Description copied from interface: ISsfData
Encrypts the given data.
Specified by:
encrypt in interface ISsfData
See Also:
ISsfData.encrypt(com.sap.security.core.server.ssf.SsfSigRcpList, com.sap.security.api.ssf.ISsfPab)

encrypt

public boolean encrypt(SsfSigRcpList rcpList,
                       ISsfPab pab,
                       java.lang.String symAlg)
                throws SsfInvalidKeyException,
                       SsfInvalidAlgException
Description copied from interface: ISsfData
Encrypts the given data.
Specified by:
encrypt in interface ISsfData
See Also:
ISsfData.encrypt(com.sap.security.core.server.ssf.SsfSigRcpList, com.sap.security.api.ssf.ISsfPab)

decrypt

public boolean decrypt(ISsfProfile profile)
                throws SsfInvalidKeyException,
                       SsfInvalidDataException
Description copied from interface: ISsfData
Decrypts the given data.
Specified by:
decrypt in interface ISsfData
See Also:
ISsfData.decrypt(com.sap.security.api.ssf.ISsfProfile)

setNewContentTypes

public void setNewContentTypes(boolean newContentTypes)
Sets the parameter newContentTypes. If this parameter is true, use the new content types (application/pkcs7-signature and application/pkcs7-mime). As default the old content types (application/x-pkcs7-signature and application/x-pkcs7-mime) are used.
Parameters:
newContentTypes - boolean that indicates if the new or old content types are used

writeTo

public boolean writeTo(java.io.OutputStream out)
                throws java.io.IOException
Description copied from interface: ISsfData
Writes the changed data to an output stream
Specified by:
writeTo in interface ISsfData
See Also:
ISsfData.writeTo(java.io.OutputStream)

getDataSMIME

public javax.mail.internet.MimeMessage getDataSMIME()
Get message which results from previous operations
Returns:
MimeMessage

toString

public java.lang.String toString()
Get information about the S/MIME data
Overrides:
toString in class java.lang.Object
Returns:
string describing the MailMessage object