Source Code Cross Referenced for SMIMEMailMessageHandler.java in  » Workflow-Engines » shark » org » enhydra » shark » toolagent » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » shark » org.enhydra.shark.toolagent 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:         * 
0003:         */package org.enhydra.shark.toolagent;
0004:
0005:        import java.io.File;
0006:        import java.util.HashSet;
0007:        import java.util.Set;
0008:
0009:        import javax.mail.Address;
0010:        import javax.mail.internet.MimeMessage;
0011:
0012:        import org.enhydra.oyster.cms.consts.CapabilitiesConstants;
0013:        import org.enhydra.oyster.smime.BaseSMIMEObject;
0014:        import org.enhydra.oyster.smime.BaseSignedSMIMEObject;
0015:        import org.enhydra.oyster.smime.EnvelopedSMIME;
0016:        import org.enhydra.oyster.smime.SignedAndEnvelopedSMIME;
0017:        import org.enhydra.oyster.smime.SignedSMIME;
0018:        import org.enhydra.shark.api.client.wfmc.wapi.WMSessionHandle;
0019:        import org.enhydra.shark.api.internal.toolagent.AppParameter;
0020:        import org.enhydra.shark.api.internal.working.CallbackUtilities;
0021:
0022:        /**
0023:         * Class is used to maintain SMIME possibility. This handler is extension of
0024:         * DefaultMailMessageHandler, and all parameters used in configuration of its super class
0025:         * are used in this extension too, whith addition of more parameters.
0026:         * 
0027:         * @author Vladimir Radisic
0028:         */
0029:        public class SMIMEMailMessageHandler extends DefaultMailMessageHandler {
0030:
0031:            // --- common params -------------------------------------------------
0032:            /**
0033:             * Parameter that represents choosen security type for email that should be sent. The
0034:             * parameter is of String type and can take the following values: <br>
0035:             * 1 - SignedSMIME <br>
0036:             * 2 - EnvelopedSMIME <br>
0037:             * 3 - SignedAndEnvelopedSMIME <br>
0038:             * 4 - EnvelopedAndSignedSMIME <br>
0039:             * Anything else means that there is no security issues and pure email will be sent
0040:             */
0041:            public static final String SECURITY_TYPE = "SecurityType";
0042:
0043:            // enveloping params
0044:
0045:            public static final String SMIME_ENVELOP_TO_CERT = "Env_TO_Cert";
0046:
0047:            public static final String SMIME_ENVELOP_TO_KEYSTORE = "Env_TO_Keystore";
0048:
0049:            public static final String SMIME_ENVELOP_TO_KEYSTORE_TYPE = "Env_TO_KeystoreType";
0050:
0051:            public static final String SMIME_ENVELOP_TO_KEYSTORE_PASSWORD = "Env_TO_KeystorePassword";
0052:
0053:            public static final String SMIME_ENVELOP_TO_KEYSTORE_CERT_ALIAS = "Env_TO_KeystoreCertAlias";
0054:
0055:            public static final String SMIME_ENVELOP_CC_CERT = "Env_CC_Cert";
0056:
0057:            public static final String SMIME_ENVELOP_CC_KEYSTORE = "Env_CC_Keystore";
0058:
0059:            public static final String SMIME_ENVELOP_CC_KEYSTORE_TYPE = "Env_CC_KeystoreType";
0060:
0061:            public static final String SMIME_ENVELOP_CC_KEYSTORE_PASSWORD = "Env_CC_KeystorePassword";
0062:
0063:            public static final String SMIME_ENVELOP_CC_KEYSTORE_CERT_ALIAS = "Env_CC_KeystoreCertAlias";
0064:
0065:            public static final String SMIME_ENVELOP_BCC_CERT = "Env_BCC_Cert";
0066:
0067:            public static final String SMIME_ENVELOP_BCC_KEYSTORE = "Env_BCC_Keystore";
0068:
0069:            public static final String SMIME_ENVELOP_BCC_KEYSTORE_TYPE = "Env_BCC_KeystoreType";
0070:
0071:            public static final String SMIME_ENVELOP_BCC_KEYSTORE_PASSWORD = "Env_BCC_KeystorePassword";
0072:
0073:            public static final String SMIME_ENVELOP_BCC_KEYSTORE_CERT_ALIAS = "Env_BCC_KeystoreCertAlias";
0074:
0075:            // common enveloping params
0076:
0077:            public static final String SMIME_ENVELOP_ALGORITHM = "Env_Algorithm";
0078:
0079:            public static final String SMIME_ENVELOP_KEY_LENGTH = "Env_KeyLength";
0080:
0081:            // default enveloping params (available from Shark configuration file)
0082:
0083:            public static final String SMIME_ENVELOP_DEFAULT_PATH = "SMIMEMailMessageHandler.Env.Default.Path";
0084:
0085:            public static final String SMIME_ENVELOP_DEFAULT_KEYSTORE_NAME = "SMIMEMailMessageHandler.Env.Default.KeystoreName";
0086:
0087:            public static final String SMIME_ENVELOP_DEFAULT_KEYSTORE_TYPE = "SMIMEMailMessageHandler.Env.Default.KeystoreType";
0088:
0089:            public static final String SMIME_ENVELOP_DEFAULT_KEYSTORE_PASSWORD = "SMIMEMailMessageHandler.Env.Default.KeystorePassword";
0090:
0091:            public static final String SMIME_ENVELOP_DEFAULT_ALGORITHM = "SMIMEMailMessageHandler.Env.Default.Algorithm";
0092:
0093:            public static final String SMIME_ENVELOP_DEFAULT_KEY_LENGTH = "SMIMEMailMessageHandler.Env.Default.KeyLength";
0094:
0095:            // signing params
0096:
0097:            public static final String SMIME_SIGNED_PFX = "Sig_Pfx";
0098:
0099:            public static final String SMIME_SIGNED_PFX_PASSWORD = "Sig_Pfx_Password";
0100:
0101:            public static final String SMIME_SIGNED_PFX_ALGORITHM = "Sig_Pfx_Algorithm";
0102:
0103:            public static final String SMIME_SIGNED_PFX_INCLUDE_CERT = "Sig_Pfx_IncludeCert";
0104:
0105:            public static final String SMIME_SIGNED_PFX_INCLUDE_SIGN_ATTRIB = "Sig_Pfx_IncludeSignAttrib";
0106:
0107:            public static final String SMIME_SIGNED_KEYSTORE = "Sig_Keystore";
0108:
0109:            public static final String SMIME_SIGNED_KEYSTORE_TYPE = "Sig_KeystoreType";
0110:
0111:            public static final String SMIME_SIGNED_KEYSTORE_PASSWORD = "Sig_KeystorePassword";
0112:
0113:            public static final String SMIME_SIGNED_KEYSTORE_CERT_ALIAS = "Sig_KeystoreCertAlias";
0114:
0115:            public static final String SMIME_SIGNED_KEYSTORE_ALGORITHM = "Sig_Keystore_Algorithm";
0116:
0117:            public static final String SMIME_SIGNED_KEYSTORE_INCLUDE_CERT = "Sig_Keystore_IncludeCert";
0118:
0119:            public static final String SMIME_SIGNED_KEYSTORE_INCLUDE_SIGN_ATTRIB = "Sig_Keystore_IncludeSignAttrib";
0120:
0121:            // common signing params
0122:
0123:            public static final String SMIME_SIGNED_EXTERNAL_SIGNATURE = "Sig_ExternalSignature";
0124:
0125:            public static final String SMIME_SIGNED_CAPABILITIES_SYMMETRIC = "Sig_CapabilSymetric";
0126:
0127:            public static final String SMIME_SIGNED_CAPABILITIES_ENCIPHER = "Sig_CapabilEncipher";
0128:
0129:            public static final String SMIME_SIGNED_CAPABILITIES_SIGNATURE = "Sig_CapabilSignature";
0130:
0131:            // default signing params (available from Shark configuration file)
0132:
0133:            public static final String SMIME_SIGNED_DEFAULT_PATH = "SMIMEMailMessageHandler.Sig.Default.Path";
0134:
0135:            public static final String SMIME_SIGNED_DEFAULT_KEYSTORE_NAME = "SMIMEMailMessageHandler.Sig.Default.KeystoreName";
0136:
0137:            public static final String SMIME_SIGNED_DEFAULT_KEYSTORE_TYPE = "SMIMEMailMessageHandler.Sig.Default.KeystoreType";
0138:
0139:            public static final String SMIME_SIGNED_DEFAULT_KEYSTORE_PASSWORD = "SMIMEMailMessageHandler.Sig.Default.KeystorePassword";
0140:
0141:            public static final String SMIME_SIGNED_DEFAULT_ALGORITHM = "SMIMEMailMessageHandler.Sig.Default.Algorithm";
0142:
0143:            public static final String SMIME_SIGNED_DEFAULT_INCLUDE_CERT = "SMIMEMailMessageHandler.Sig.Default.IncludeCert";
0144:
0145:            public static final String SMIME_SIGNED_DEFAULT_INCLUDE_SIGN_ATTRIB = "SMIMEMailMessageHandler.Sig.Default.IncludeSignAttrib";
0146:
0147:            public static final String SMIME_SIGNED_DEFAULT_EXTERNAL_SIGNATURE = "SMIMEMailMessageHandler.Sig.Default.ExternalSignature";
0148:
0149:            /**
0150:             * Security identifier can can take the following values: <br>
0151:             * 1 - SignedSMIME <br>
0152:             * 2 - EnvelopedSMIME <br>
0153:             * 3 - SignedAndEnvelopedSMIME <br>
0154:             * 4 - EnvelopedAndSignedSMIME <br>
0155:             * Anything else means that there is no security issues and pure email will be sent.
0156:             */
0157:            protected int securityType = -1;
0158:
0159:            protected String envDefaultPath;
0160:
0161:            protected String envDefaultKeystoreName;
0162:
0163:            protected String envDefaultKeystoreType;
0164:
0165:            protected String envDefaultKeystorePassword;
0166:
0167:            protected String envDefaultAlgorithm;
0168:
0169:            protected String envDefaultKeyLength;
0170:
0171:            protected String sigDefaultPath;
0172:
0173:            protected String sigDefaultKeystoreName;
0174:
0175:            protected String sigDefaultKeystoreType;
0176:
0177:            protected String sigDefaultKeystorePassword;
0178:
0179:            protected String sigDefaultAlgorithm;
0180:
0181:            protected boolean sigDefaultIncludeCert;
0182:
0183:            protected boolean sigDefaultIncludeSignAttrib;
0184:
0185:            protected boolean sigDefaultExternalSignature;
0186:
0187:            public void configure(CallbackUtilities cus,
0188:                    WMSessionHandle shandle, String procId, String assId,
0189:                    AppParameter[] aps) throws Exception {
0190:
0191:                super .configure(cus, shandle, procId, assId, aps);
0192:
0193:                String parValue = AbstractToolAgent
0194:                        .getParameterString(this .sharkParams,
0195:                                SMIMEMailMessageHandler.SECURITY_TYPE);
0196:                if (parValue != null && parValue.matches("[0-9]+"))
0197:                    this .securityType = Integer.parseInt(parValue);
0198:
0199:                this .envDefaultPath = cus
0200:                        .getProperty(SMIMEMailMessageHandler.SMIME_ENVELOP_DEFAULT_PATH);
0201:                if (this .envDefaultPath != null
0202:                        && this .envDefaultPath.trim().length() != 0) {
0203:                    this .envDefaultPath = this .envDefaultPath
0204:                            .replace('\\', '/');
0205:                    if (!this .envDefaultPath.endsWith("/"))
0206:                        this .envDefaultPath = this .envDefaultPath + "/";
0207:                }
0208:
0209:                this .envDefaultKeystoreName = cus
0210:                        .getProperty(SMIMEMailMessageHandler.SMIME_ENVELOP_DEFAULT_KEYSTORE_NAME);
0211:                this .envDefaultKeystoreType = cus
0212:                        .getProperty(SMIMEMailMessageHandler.SMIME_ENVELOP_DEFAULT_KEYSTORE_TYPE);
0213:                this .envDefaultKeystorePassword = cus
0214:                        .getProperty(SMIMEMailMessageHandler.SMIME_ENVELOP_DEFAULT_KEYSTORE_PASSWORD);
0215:                this .envDefaultAlgorithm = cus
0216:                        .getProperty(SMIMEMailMessageHandler.SMIME_ENVELOP_DEFAULT_ALGORITHM);
0217:                this .envDefaultKeyLength = cus
0218:                        .getProperty(SMIMEMailMessageHandler.SMIME_ENVELOP_DEFAULT_KEY_LENGTH);
0219:
0220:                this .sigDefaultPath = cus
0221:                        .getProperty(SMIMEMailMessageHandler.SMIME_SIGNED_DEFAULT_PATH);
0222:                if (this .sigDefaultPath != null
0223:                        && this .sigDefaultPath.trim().length() != 0) {
0224:                    this .sigDefaultPath = this .sigDefaultPath
0225:                            .replace('\\', '/');
0226:                    if (!this .sigDefaultPath.endsWith("/"))
0227:                        this .sigDefaultPath = this .sigDefaultPath + "/";
0228:                }
0229:
0230:                this .sigDefaultKeystoreName = cus
0231:                        .getProperty(SMIMEMailMessageHandler.SMIME_SIGNED_DEFAULT_KEYSTORE_NAME);
0232:                this .sigDefaultKeystoreType = cus
0233:                        .getProperty(SMIMEMailMessageHandler.SMIME_SIGNED_DEFAULT_KEYSTORE_TYPE);
0234:                this .sigDefaultKeystorePassword = cus
0235:                        .getProperty(SMIMEMailMessageHandler.SMIME_SIGNED_DEFAULT_KEYSTORE_PASSWORD);
0236:                this .sigDefaultAlgorithm = cus
0237:                        .getProperty(SMIMEMailMessageHandler.SMIME_SIGNED_DEFAULT_ALGORITHM);
0238:
0239:                String tmp = cus
0240:                        .getProperty(SMIMEMailMessageHandler.SMIME_SIGNED_DEFAULT_INCLUDE_CERT);
0241:                if (tmp == null || tmp.trim().length() == 0)
0242:                    this .sigDefaultIncludeCert = true;
0243:                else
0244:                    this .sigDefaultIncludeCert = Boolean.valueOf(tmp)
0245:                            .booleanValue();
0246:
0247:                tmp = cus
0248:                        .getProperty(SMIMEMailMessageHandler.SMIME_SIGNED_DEFAULT_INCLUDE_SIGN_ATTRIB);
0249:                if (tmp == null || tmp.trim().length() == 0)
0250:                    this .sigDefaultIncludeSignAttrib = true;
0251:                else
0252:                    this .sigDefaultIncludeSignAttrib = Boolean.valueOf(tmp)
0253:                            .booleanValue();
0254:
0255:                tmp = cus
0256:                        .getProperty(SMIMEMailMessageHandler.SMIME_SIGNED_DEFAULT_EXTERNAL_SIGNATURE);
0257:                if (tmp == null || tmp.trim().length() == 0)
0258:                    this .sigDefaultExternalSignature = true;
0259:                else
0260:                    this .sigDefaultExternalSignature = Boolean.valueOf(tmp)
0261:                            .booleanValue();
0262:
0263:            }
0264:
0265:            public MimeMessage createMail() throws Exception {
0266:
0267:                MimeMessage mm = super .createMail();
0268:
0269:                // if pure mime message
0270:                if (!("" + this .securityType).matches("[1234]"))
0271:                    return mm;
0272:
0273:                // Currently Oyster can have only one FROM address
0274:                {
0275:                    Address[] tmpAdr = mm.getFrom();
0276:                    if (tmpAdr != null && tmpAdr.length != 1)
0277:                        throw new Exception(
0278:                                "FROM header attribute in SMIME email should be unique!.");
0279:                }
0280:
0281:                // Adding recipients with necessary data for criptography
0282:                String[] tos = AbstractToolAgent.getParameterStringArray(
0283:                        this .sharkParams,
0284:                        DefaultMailMessageHandler.TO_ADDRESSES_NAME,
0285:                        AbstractToolAgent.COMMA_SEPARATOR_STR);
0286:                String[] ccs = AbstractToolAgent.getParameterStringArray(
0287:                        this .sharkParams,
0288:                        DefaultMailMessageHandler.CC_ADDRESSES_NAME,
0289:                        AbstractToolAgent.COMMA_SEPARATOR_STR);
0290:                String[] bccs = AbstractToolAgent.getParameterStringArray(
0291:                        this .sharkParams,
0292:                        DefaultMailMessageHandler.BCC_ADDRESSES_NAME,
0293:                        AbstractToolAgent.COMMA_SEPARATOR_STR);
0294:
0295:                // SignedSMIME
0296:                if (this .securityType == 1) {
0297:
0298:                    SignedSMIME ss = new SignedSMIME(mm);
0299:
0300:                    // add TO recipients
0301:                    if (tos != null && tos.length > 0) {
0302:                        for (int i = 0; i < tos.length; i++) {
0303:                            ss.addRecipient(tos[i], "TO");
0304:                        }
0305:                    }
0306:
0307:                    // add CC recipients
0308:                    if (ccs != null && ccs.length > 0) {
0309:                        for (int i = 0; i < ccs.length; i++) {
0310:                            ss.addRecipient(ccs[i], "CC");
0311:                        }
0312:                    }
0313:
0314:                    // add BCC recipients
0315:                    if (bccs != null && bccs.length > 0) {
0316:                        for (int i = 0; i < bccs.length; i++) {
0317:                            ss.addRecipient(bccs[i], "BCC");
0318:
0319:                        }
0320:                    }
0321:
0322:                    ss = (SignedSMIME) this .addSigners(ss);
0323:
0324:                    String tmpExtSig = AbstractToolAgent
0325:                            .getParameterString(
0326:                                    this .sharkParams,
0327:                                    SMIMEMailMessageHandler.SMIME_SIGNED_EXTERNAL_SIGNATURE);
0328:                    if (tmpExtSig == null || tmpExtSig.trim().length() == 0) {
0329:                        ss.signing(this .sigDefaultExternalSignature);
0330:                    } else {
0331:                        ss.signing(Boolean.valueOf(tmpExtSig).booleanValue());
0332:                    }
0333:
0334:                    return ss.getMimeMessage();
0335:                }
0336:                // EnvelopedSMIME
0337:                else if (this .securityType == 2) {
0338:                    EnvelopedSMIME es = new EnvelopedSMIME(mm);
0339:
0340:                    es = (EnvelopedSMIME) this 
0341:                            .addRecipients(es, tos, ccs, bccs);
0342:
0343:                    String tmpEnvAlg = AbstractToolAgent.getParameterString(
0344:                            this .sharkParams,
0345:                            SMIMEMailMessageHandler.SMIME_ENVELOP_ALGORITHM);
0346:                    if (tmpEnvAlg == null || tmpEnvAlg.trim().length() == 0)
0347:                        tmpEnvAlg = this .envDefaultAlgorithm;
0348:
0349:                    String tmpKey = AbstractToolAgent.getParameterString(
0350:                            this .sharkParams,
0351:                            SMIMEMailMessageHandler.SMIME_ENVELOP_KEY_LENGTH);
0352:                    if (tmpKey == null || tmpKey.trim().length() == 0)
0353:                        tmpKey = this .envDefaultKeyLength;
0354:
0355:                    if (tmpEnvAlg == null || tmpEnvAlg.trim().length() == 0
0356:                            || tmpKey == null || tmpKey.trim().length() == 0)
0357:                        es.enveloping();
0358:                    else
0359:                        es.enveloping(tmpEnvAlg, Integer.parseInt(tmpKey));
0360:
0361:                    return es.getMimeMessage();
0362:                }
0363:                // SignedAndEnvelopedSMIME
0364:                // EnvelopedAndSignedSMIME
0365:                else {
0366:                    SignedAndEnvelopedSMIME ses = new SignedAndEnvelopedSMIME(
0367:                            mm);
0368:
0369:                    ses = (SignedAndEnvelopedSMIME) this .addSigners(ses);
0370:                    ses = (SignedAndEnvelopedSMIME) this .addRecipients(ses,
0371:                            tos, ccs, bccs);
0372:
0373:                    String secOrder = "SIGN_FIRST";
0374:                    if (this .securityType == 4)
0375:                        secOrder = "ENCRYPT_FIRST";
0376:
0377:                    String tmpEnvAlg = AbstractToolAgent.getParameterString(
0378:                            this .sharkParams,
0379:                            SMIMEMailMessageHandler.SMIME_ENVELOP_ALGORITHM);
0380:                    if (tmpEnvAlg == null || tmpEnvAlg.trim().length() == 0)
0381:                        tmpEnvAlg = this .envDefaultAlgorithm;
0382:
0383:                    String tmpKey = AbstractToolAgent.getParameterString(
0384:                            this .sharkParams,
0385:                            SMIMEMailMessageHandler.SMIME_ENVELOP_KEY_LENGTH);
0386:                    if (tmpKey == null || tmpKey.trim().length() == 0)
0387:                        tmpKey = this .envDefaultKeyLength;
0388:
0389:                    if (tmpEnvAlg == null || tmpEnvAlg.trim().length() == 0
0390:                            || tmpKey == null || tmpKey.trim().length() == 0)
0391:                        ses.signingAndEnveloping(secOrder);
0392:                    else
0393:                        ses.signingAndEnveloping(tmpEnvAlg, Integer
0394:                                .parseInt(tmpKey), secOrder);
0395:
0396:                    return ses.getMimeMessage();
0397:
0398:                }
0399:
0400:            }
0401:
0402:            private BaseSMIMEObject addRecipients(BaseSMIMEObject bso,
0403:                    String[] tos, String[] ccs, String[] bccs) throws Exception {
0404:
0405:                SignedAndEnvelopedSMIME sesm = null;
0406:                EnvelopedSMIME esm = null;
0407:
0408:                if (this .securityType == 2)
0409:                    esm = (EnvelopedSMIME) bso;
0410:                else if (this .securityType > 2)
0411:                    sesm = (SignedAndEnvelopedSMIME) bso;
0412:
0413:                // TO recipients
0414:                if (tos != null && tos.length > 0) {
0415:
0416:                    Set cerSet = new HashSet();
0417:                    for (int i = 0; i < tos.length; i++) {
0418:                        cerSet.add("" + i);
0419:                    }
0420:
0421:                    String[] cerArray = AbstractToolAgent
0422:                            .getParameterStringArray(
0423:                                    this .sharkParams,
0424:                                    SMIMEMailMessageHandler.SMIME_ENVELOP_TO_CERT,
0425:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
0426:                    if (cerArray != null && cerArray.length != tos.length)
0427:                        throw new Exception(
0428:                                "Invalid number of array items in value for parameter: "
0429:                                        + SMIMEMailMessageHandler.SMIME_ENVELOP_TO_CERT);
0430:                    else if (cerArray != null && cerArray.length == tos.length) {
0431:                        for (int i = 0; i < tos.length; i++) {
0432:                            if (cerArray[i] != null
0433:                                    && cerArray[i].trim().length() != 0) {
0434:                                cerArray[i] = cerArray[i].replace('\\', '/');
0435:
0436:                                File fToCheck = new File(cerArray[i]);
0437:                                if (!fToCheck.exists()) {
0438:                                    if (this .envDefaultPath == null
0439:                                            || this .envDefaultPath.trim()
0440:                                                    .equals(""))
0441:                                        throw new Exception(
0442:                                                "Could not find the defined pfx file: "
0443:                                                        + cerArray[i]);
0444:                                    else {
0445:                                        cerArray[i] = this .envDefaultPath
0446:                                                + cerArray[i];
0447:                                        cerArray[i] = cerArray[i].replaceAll(
0448:                                                "/{2}", "/");
0449:
0450:                                        fToCheck = new File(cerArray[i]);
0451:                                        if (!fToCheck.exists()) {
0452:                                            throw new Exception(
0453:                                                    "Could not find the defined pfx file: "
0454:                                                            + cerArray[i]);
0455:                                        }
0456:                                    }
0457:                                }
0458:
0459:                                cerSet.remove("" + i);
0460:
0461:                                // email, TO|CC|BCC), path to .cer file
0462:                                if (this .securityType == 2)
0463:                                    esm.addRecipient(tos[i], "TO", cerArray[i]);
0464:                                else if (this .securityType > 2)
0465:                                    sesm
0466:                                            .addRecipient(tos[i], "TO",
0467:                                                    cerArray[i]);
0468:
0469:                            }
0470:
0471:                        }
0472:                    }
0473:
0474:                    String[] ksArray = AbstractToolAgent
0475:                            .getParameterStringArray(
0476:                                    this .sharkParams,
0477:                                    SMIMEMailMessageHandler.SMIME_ENVELOP_TO_KEYSTORE,
0478:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
0479:                    if ((ksArray == null || ksArray.length == 0)
0480:                            && cerSet.size() > 0
0481:                            && (this .envDefaultPath != null && this .envDefaultPath
0482:                                    .trim().length() > 0)
0483:                            && (this .envDefaultKeystoreName != null && this .envDefaultKeystoreName
0484:                                    .trim().length() > 0)) {
0485:                        ksArray = new String[tos.length];
0486:                        for (int i = 0; i < ksArray.length; i++) {
0487:                            ksArray[i] = this .envDefaultPath
0488:                                    + this .envDefaultKeystoreName;
0489:                            ksArray[i] = ksArray[i].replaceAll("/{2}", "/");
0490:                        }
0491:                    }
0492:
0493:                    if (ksArray != null && ksArray.length != tos.length)
0494:                        throw new Exception(
0495:                                "Invalid number of array items in value for parameter: "
0496:                                        + SMIMEMailMessageHandler.SMIME_ENVELOP_TO_KEYSTORE);
0497:                    else if (ksArray != null && ksArray.length == tos.length) {
0498:
0499:                        String[] ksTypeArray = AbstractToolAgent
0500:                                .getParameterStringArray(
0501:                                        this .sharkParams,
0502:                                        SMIMEMailMessageHandler.SMIME_ENVELOP_TO_KEYSTORE_TYPE,
0503:                                        AbstractToolAgent.COMMA_SEPARATOR_STR);
0504:                        if (ksTypeArray == null || ksTypeArray.length == 0) {
0505:                            ksTypeArray = new String[ksArray.length];
0506:                            for (int i = 0; i < ksTypeArray.length; i++) {
0507:                                ksTypeArray[i] = this .envDefaultKeystoreType;
0508:                            }
0509:                        } else if (ksTypeArray.length != ksArray.length)
0510:                            throw new Exception(
0511:                                    "Invalid number of array items in value for parameter: "
0512:                                            + SMIMEMailMessageHandler.SMIME_ENVELOP_TO_KEYSTORE);
0513:                        else {
0514:                            for (int i = 0; i < ksTypeArray.length; i++) {
0515:                                if (ksTypeArray[i] == null
0516:                                        || ksTypeArray[i].trim().length() == 0)
0517:                                    ksTypeArray[i] = this .envDefaultKeystoreType;
0518:                            }
0519:                        }
0520:
0521:                        String[] ksPasswArray = AbstractToolAgent
0522:                                .getParameterStringArray(
0523:                                        this .sharkParams,
0524:                                        SMIMEMailMessageHandler.SMIME_ENVELOP_TO_KEYSTORE_PASSWORD,
0525:                                        AbstractToolAgent.COMMA_SEPARATOR_STR);
0526:                        if (ksPasswArray == null || ksPasswArray.length == 0) {
0527:                            ksPasswArray = new String[ksArray.length];
0528:                            for (int i = 0; i < ksPasswArray.length; i++) {
0529:                                ksPasswArray[i] = this .envDefaultKeystorePassword;
0530:                            }
0531:                        } else if (ksPasswArray.length != ksArray.length)
0532:                            throw new Exception(
0533:                                    "Invalid number of array items in value for parameter: "
0534:                                            + SMIMEMailMessageHandler.SMIME_ENVELOP_TO_KEYSTORE_PASSWORD);
0535:                        else {
0536:                            for (int i = 0; i < ksPasswArray.length; i++) {
0537:                                if (ksPasswArray[i] == null
0538:                                        || ksPasswArray[i].trim().length() == 0)
0539:                                    ksPasswArray[i] = this .envDefaultKeystorePassword;
0540:                            }
0541:                        }
0542:
0543:                        String[] ksAliasArray = AbstractToolAgent
0544:                                .getParameterStringArray(
0545:                                        this .sharkParams,
0546:                                        SMIMEMailMessageHandler.SMIME_ENVELOP_TO_KEYSTORE_CERT_ALIAS,
0547:                                        AbstractToolAgent.COMMA_SEPARATOR_STR);
0548:                        if (ksAliasArray == null
0549:                                || ksAliasArray.length != ksArray.length)
0550:                            throw new Exception(
0551:                                    "Invalid number of array items in value for parameter: "
0552:                                            + SMIMEMailMessageHandler.SMIME_ENVELOP_TO_KEYSTORE_CERT_ALIAS);
0553:
0554:                        for (int i = 0; i < tos.length; i++) {
0555:
0556:                            // already performed with .cer file
0557:                            if (!cerSet.contains("" + i))
0558:                                continue;
0559:
0560:                            if (ksArray[i] == null
0561:                                    || ksArray[i].trim().length() == 0)
0562:                                ksArray[i] = this .envDefaultKeystoreName;
0563:
0564:                            if (ksArray[i] != null
0565:                                    && ksArray[i].trim().length() != 0) {
0566:
0567:                                ksArray[i] = ksArray[i].replace('\\', '/');
0568:
0569:                                File fToCheck = new File(ksArray[i]);
0570:                                if (!fToCheck.exists()) {
0571:                                    if (this .envDefaultPath == null
0572:                                            || this .envDefaultPath.trim()
0573:                                                    .equals(""))
0574:                                        throw new Exception(
0575:                                                "Could not find the defined key store file: "
0576:                                                        + ksArray[i]);
0577:                                    else {
0578:                                        ksArray[i] = this .envDefaultPath
0579:                                                + ksArray[i];
0580:                                        ksArray[i] = ksArray[i].replaceAll(
0581:                                                "/{2}", "/");
0582:
0583:                                        fToCheck = new File(ksArray[i]);
0584:                                        if (!fToCheck.exists()) {
0585:                                            throw new Exception(
0586:                                                    "Could not find the defined key store file: "
0587:                                                            + ksArray[i]);
0588:                                        }
0589:                                    }
0590:                                }
0591:
0592:                                cerSet.remove("" + i);
0593:
0594:                                // email, TO|CC|BCC), path to ks file, ks type, ks password, public key
0595:                                // store alias
0596:                                if (this .securityType == 2)
0597:                                    esm.addRecipient(tos[i], "TO", ksArray[i],
0598:                                            ksTypeArray[i], ksPasswArray[i],
0599:                                            ksAliasArray[i]);
0600:                                else if (this .securityType > 2)
0601:                                    sesm.addRecipient(tos[i], "TO", ksArray[i],
0602:                                            ksTypeArray[i], ksPasswArray[i],
0603:                                            ksAliasArray[i]);
0604:                            }
0605:
0606:                        }
0607:
0608:                    }
0609:
0610:                    if (cerSet.size() > 0)
0611:                        throw new Exception(
0612:                                "There is mismatch in number of TO recipients and corresponding SMIME parameters");
0613:
0614:                }
0615:
0616:                // CC recipients
0617:                if (ccs != null && ccs.length > 0) {
0618:
0619:                    Set cerSet = new HashSet();
0620:                    for (int i = 0; i < ccs.length; i++) {
0621:                        cerSet.add("" + i);
0622:                    }
0623:
0624:                    String[] cerArray = AbstractToolAgent
0625:                            .getParameterStringArray(
0626:                                    this .sharkParams,
0627:                                    SMIMEMailMessageHandler.SMIME_ENVELOP_CC_CERT,
0628:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
0629:                    if (cerArray != null && cerArray.length > 0
0630:                            && cerArray.length != ccs.length)
0631:                        throw new Exception(
0632:                                "Invalid number of array items in value for parameter: "
0633:                                        + SMIMEMailMessageHandler.SMIME_ENVELOP_CC_CERT);
0634:                    else if (cerArray != null && cerArray.length == ccs.length) {
0635:                        for (int i = 0; i < ccs.length; i++) {
0636:                            if (cerArray[i] != null
0637:                                    && cerArray[i].trim().length() != 0) {
0638:                                cerArray[i] = cerArray[i].replace('\\', '/');
0639:
0640:                                File fToCheck = new File(cerArray[i]);
0641:                                if (!fToCheck.exists()) {
0642:                                    if (this .envDefaultPath == null
0643:                                            || this .envDefaultPath.trim()
0644:                                                    .equals(""))
0645:                                        throw new Exception(
0646:                                                "Could not find the defined pfx file: "
0647:                                                        + cerArray[i]);
0648:                                    else {
0649:                                        cerArray[i] = this .envDefaultPath
0650:                                                + cerArray[i];
0651:                                        cerArray[i] = cerArray[i].replaceAll(
0652:                                                "/{2}", "/");
0653:
0654:                                        fToCheck = new File(cerArray[i]);
0655:                                        if (!fToCheck.exists()) {
0656:                                            throw new Exception(
0657:                                                    "Could not find the defined pfx file: "
0658:                                                            + cerArray[i]);
0659:                                        }
0660:                                    }
0661:                                }
0662:
0663:                                cerSet.remove("" + i);
0664:
0665:                                // email, TO|CC|BCC), path to .cer file
0666:                                if (this .securityType == 2)
0667:                                    esm.addRecipient(ccs[i], "CC", cerArray[i]);
0668:                                else if (this .securityType == 2)
0669:                                    sesm
0670:                                            .addRecipient(ccs[i], "CC",
0671:                                                    cerArray[i]);
0672:
0673:                            }
0674:
0675:                        }
0676:                    }
0677:
0678:                    String[] ksArray = AbstractToolAgent
0679:                            .getParameterStringArray(
0680:                                    this .sharkParams,
0681:                                    SMIMEMailMessageHandler.SMIME_ENVELOP_CC_KEYSTORE,
0682:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
0683:                    if ((ksArray == null || ksArray.length == 0)
0684:                            && cerSet.size() > 0
0685:                            && (this .envDefaultPath != null && this .envDefaultPath
0686:                                    .trim().length() > 0)
0687:                            && (this .envDefaultKeystoreName != null && this .envDefaultKeystoreName
0688:                                    .trim().length() > 0)) {
0689:                        ksArray = new String[ccs.length];
0690:                        for (int i = 0; i < ksArray.length; i++) {
0691:                            ksArray[i] = this .envDefaultPath
0692:                                    + this .envDefaultKeystoreName;
0693:                            ksArray[i] = ksArray[i].replaceAll("/{2}", "/");
0694:                        }
0695:                    }
0696:
0697:                    if (ksArray != null && ksArray.length > 0
0698:                            && ksArray.length != ccs.length)
0699:                        throw new Exception(
0700:                                "Invalid number of array items in value for parameter: "
0701:                                        + SMIMEMailMessageHandler.SMIME_ENVELOP_CC_KEYSTORE);
0702:                    else if (ksArray != null && ksArray.length == ccs.length) {
0703:
0704:                        String[] ksTypeArray = AbstractToolAgent
0705:                                .getParameterStringArray(
0706:                                        this .sharkParams,
0707:                                        SMIMEMailMessageHandler.SMIME_ENVELOP_CC_KEYSTORE_TYPE,
0708:                                        AbstractToolAgent.COMMA_SEPARATOR_STR);
0709:                        if (ksTypeArray == null || ksTypeArray.length == 0) {
0710:                            ksTypeArray = new String[ksArray.length];
0711:                            for (int i = 0; i < ksTypeArray.length; i++) {
0712:                                ksTypeArray[i] = this .envDefaultKeystoreType;
0713:                            }
0714:                        } else if (ksTypeArray.length != ksArray.length)
0715:                            throw new Exception(
0716:                                    "Invalid number of array items in value for parameter: "
0717:                                            + SMIMEMailMessageHandler.SMIME_ENVELOP_CC_KEYSTORE);
0718:                        else {
0719:                            for (int i = 0; i < ksTypeArray.length; i++) {
0720:                                if (ksTypeArray[i] == null
0721:                                        || ksTypeArray[i].trim().length() == 0)
0722:                                    ksTypeArray[i] = this .envDefaultKeystoreType;
0723:                            }
0724:                        }
0725:
0726:                        String[] ksPasswArray = AbstractToolAgent
0727:                                .getParameterStringArray(
0728:                                        this .sharkParams,
0729:                                        SMIMEMailMessageHandler.SMIME_ENVELOP_CC_KEYSTORE_PASSWORD,
0730:                                        AbstractToolAgent.COMMA_SEPARATOR_STR);
0731:                        if (ksPasswArray == null || ksPasswArray.length == 0) {
0732:                            ksPasswArray = new String[ksArray.length];
0733:                            for (int i = 0; i < ksPasswArray.length; i++) {
0734:                                ksPasswArray[i] = this .envDefaultKeystorePassword;
0735:                            }
0736:                        } else if (ksPasswArray.length != ksArray.length)
0737:                            throw new Exception(
0738:                                    "Invalid number of array items in value for parameter: "
0739:                                            + SMIMEMailMessageHandler.SMIME_ENVELOP_CC_KEYSTORE_PASSWORD);
0740:                        else {
0741:                            for (int i = 0; i < ksPasswArray.length; i++) {
0742:                                if (ksPasswArray[i] == null
0743:                                        || ksPasswArray[i].trim().length() == 0)
0744:                                    ksPasswArray[i] = this .envDefaultKeystorePassword;
0745:                            }
0746:                        }
0747:
0748:                        String[] ksAliasArray = AbstractToolAgent
0749:                                .getParameterStringArray(
0750:                                        this .sharkParams,
0751:                                        SMIMEMailMessageHandler.SMIME_ENVELOP_CC_KEYSTORE_CERT_ALIAS,
0752:                                        AbstractToolAgent.COMMA_SEPARATOR_STR);
0753:                        if (ksAliasArray == null
0754:                                || ksAliasArray.length != ksArray.length)
0755:                            throw new Exception(
0756:                                    "Invalid number of array items in value for parameter: "
0757:                                            + SMIMEMailMessageHandler.SMIME_ENVELOP_CC_KEYSTORE_CERT_ALIAS);
0758:
0759:                        for (int i = 0; i < ccs.length; i++) {
0760:
0761:                            if (!cerSet.contains("" + i))
0762:                                continue;
0763:
0764:                            if (ksArray[i] == null
0765:                                    || ksArray[i].trim().length() == 0)
0766:                                ksArray[i] = this .envDefaultKeystoreName;
0767:
0768:                            if (ksArray[i] != null
0769:                                    && ksArray[i].trim().length() != 0) {
0770:
0771:                                ksArray[i] = ksArray[i].replace('\\', '/');
0772:
0773:                                File fToCheck = new File(ksArray[i]);
0774:                                if (!fToCheck.exists()) {
0775:                                    if (this .envDefaultPath == null
0776:                                            || this .envDefaultPath.trim()
0777:                                                    .equals(""))
0778:                                        throw new Exception(
0779:                                                "Could not find the defined key store file: "
0780:                                                        + ksArray[i]);
0781:                                    else {
0782:                                        ksArray[i] = this .envDefaultPath
0783:                                                + ksArray[i];
0784:                                        ksArray[i] = ksArray[i].replaceAll(
0785:                                                "/{2}", "/");
0786:
0787:                                        fToCheck = new File(ksArray[i]);
0788:                                        if (!fToCheck.exists()) {
0789:                                            throw new Exception(
0790:                                                    "Could not find the defined key store file: "
0791:                                                            + ksArray[i]);
0792:                                        }
0793:                                    }
0794:                                }
0795:
0796:                                cerSet.remove("" + i);
0797:
0798:                                // email, TO|CC|BCC), path to ks file, ks type, ks password, public key
0799:                                // store alias
0800:                                if (this .securityType == 2)
0801:                                    esm.addRecipient(ccs[i], "CC", ksArray[i],
0802:                                            ksTypeArray[i], ksPasswArray[i],
0803:                                            ksAliasArray[i]);
0804:                                if (this .securityType > 2)
0805:                                    sesm.addRecipient(ccs[i], "CC", ksArray[i],
0806:                                            ksTypeArray[i], ksPasswArray[i],
0807:                                            ksAliasArray[i]);
0808:                            }
0809:
0810:                        }
0811:
0812:                    }
0813:
0814:                    if (cerSet.size() > 0)
0815:                        throw new Exception(
0816:                                "There is mismatch in number of CC recipients and corresponding SMIME parameters");
0817:
0818:                }
0819:
0820:                // BCC recipients
0821:                if (bccs != null && bccs.length > 0) {
0822:
0823:                    Set cerSet = new HashSet();
0824:                    for (int i = 0; i < bccs.length; i++) {
0825:                        cerSet.add("" + i);
0826:                    }
0827:
0828:                    String[] cerArray = AbstractToolAgent
0829:                            .getParameterStringArray(
0830:                                    this .sharkParams,
0831:                                    SMIMEMailMessageHandler.SMIME_ENVELOP_BCC_CERT,
0832:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
0833:                    if (cerArray != null && cerArray.length > 0
0834:                            && cerArray.length != bccs.length)
0835:                        throw new Exception(
0836:                                "Invalid number of array items in value for parameter: "
0837:                                        + SMIMEMailMessageHandler.SMIME_ENVELOP_BCC_CERT);
0838:                    else if (cerArray != null && cerArray.length == bccs.length) {
0839:                        for (int i = 0; i < bccs.length; i++) {
0840:                            if (cerArray[i] != null
0841:                                    && cerArray[i].trim().length() != 0) {
0842:                                cerArray[i] = cerArray[i].replace('\\', '/');
0843:
0844:                                File fToCheck = new File(cerArray[i]);
0845:                                if (!fToCheck.exists()) {
0846:                                    if (this .envDefaultPath == null
0847:                                            || this .envDefaultPath.trim()
0848:                                                    .equals(""))
0849:                                        throw new Exception(
0850:                                                "Could not find the defined pfx file: "
0851:                                                        + cerArray[i]);
0852:                                    else {
0853:                                        cerArray[i] = this .envDefaultPath
0854:                                                + cerArray[i];
0855:                                        cerArray[i] = cerArray[i].replaceAll(
0856:                                                "/{2}", "/");
0857:
0858:                                        fToCheck = new File(cerArray[i]);
0859:                                        if (!fToCheck.exists()) {
0860:                                            throw new Exception(
0861:                                                    "Could not find the defined pfx file: "
0862:                                                            + cerArray[i]);
0863:                                        }
0864:                                    }
0865:                                }
0866:
0867:                                cerSet.remove("" + i);
0868:
0869:                                // email, TO|CC|BCC), path to .cer file
0870:                                if (this .securityType == 2)
0871:                                    esm.addRecipient(bccs[i], "BCC",
0872:                                            cerArray[i]);
0873:                                if (this .securityType > 2)
0874:                                    sesm.addRecipient(bccs[i], "BCC",
0875:                                            cerArray[i]);
0876:
0877:                            }
0878:
0879:                        }
0880:                    }
0881:
0882:                    String[] ksArray = AbstractToolAgent
0883:                            .getParameterStringArray(
0884:                                    this .sharkParams,
0885:                                    SMIMEMailMessageHandler.SMIME_ENVELOP_BCC_KEYSTORE,
0886:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
0887:                    if ((ksArray == null || ksArray.length == 0)
0888:                            && cerSet.size() > 0
0889:                            && (this .envDefaultPath != null && this .envDefaultPath
0890:                                    .trim().length() > 0)
0891:                            && (this .envDefaultKeystoreName != null && this .envDefaultKeystoreName
0892:                                    .trim().length() > 0)) {
0893:                        ksArray = new String[bccs.length];
0894:                        for (int i = 0; i < ksArray.length; i++) {
0895:                            ksArray[i] = this .envDefaultPath
0896:                                    + this .envDefaultKeystoreName;
0897:                            ksArray[i] = ksArray[i].replaceAll("/{2}", "/");
0898:                        }
0899:                    }
0900:
0901:                    if (ksArray != null && ksArray.length > 0
0902:                            && ksArray.length != bccs.length)
0903:                        throw new Exception(
0904:                                "Invalid number of array items in value for parameter: "
0905:                                        + SMIMEMailMessageHandler.SMIME_ENVELOP_BCC_KEYSTORE);
0906:                    else if (ksArray != null && ksArray.length == bccs.length) {
0907:
0908:                        String[] ksTypeArray = AbstractToolAgent
0909:                                .getParameterStringArray(
0910:                                        this .sharkParams,
0911:                                        SMIMEMailMessageHandler.SMIME_ENVELOP_BCC_KEYSTORE_TYPE,
0912:                                        AbstractToolAgent.COMMA_SEPARATOR_STR);
0913:                        if (ksTypeArray == null || ksTypeArray.length == 0) {
0914:                            ksTypeArray = new String[ksArray.length];
0915:                            for (int i = 0; i < ksTypeArray.length; i++) {
0916:                                ksTypeArray[i] = this .envDefaultKeystoreType;
0917:                            }
0918:                        } else if (ksTypeArray.length != ksArray.length)
0919:                            throw new Exception(
0920:                                    "Invalid number of array items in value for parameter: "
0921:                                            + SMIMEMailMessageHandler.SMIME_ENVELOP_BCC_KEYSTORE);
0922:                        else {
0923:                            for (int i = 0; i < ksTypeArray.length; i++) {
0924:                                if (ksTypeArray[i] == null
0925:                                        || ksTypeArray[i].trim().length() == 0)
0926:                                    ksTypeArray[i] = this .envDefaultKeystoreType;
0927:                            }
0928:                        }
0929:
0930:                        String[] ksPasswArray = AbstractToolAgent
0931:                                .getParameterStringArray(
0932:                                        this .sharkParams,
0933:                                        SMIMEMailMessageHandler.SMIME_ENVELOP_BCC_KEYSTORE_PASSWORD,
0934:                                        AbstractToolAgent.COMMA_SEPARATOR_STR);
0935:                        if (ksPasswArray == null || ksPasswArray.length == 0) {
0936:                            ksPasswArray = new String[ksArray.length];
0937:                            for (int i = 0; i < ksPasswArray.length; i++) {
0938:                                ksPasswArray[i] = this .envDefaultKeystorePassword;
0939:                            }
0940:                        } else if (ksPasswArray.length != ksArray.length)
0941:                            throw new Exception(
0942:                                    "Invalid number of array items in value for parameter: "
0943:                                            + SMIMEMailMessageHandler.SMIME_ENVELOP_BCC_KEYSTORE_PASSWORD);
0944:                        else {
0945:                            for (int i = 0; i < ksPasswArray.length; i++) {
0946:                                if (ksPasswArray[i] == null
0947:                                        || ksPasswArray[i].trim().length() == 0)
0948:                                    ksPasswArray[i] = this .envDefaultKeystorePassword;
0949:                            }
0950:                        }
0951:
0952:                        String[] ksAliasArray = AbstractToolAgent
0953:                                .getParameterStringArray(
0954:                                        this .sharkParams,
0955:                                        SMIMEMailMessageHandler.SMIME_ENVELOP_BCC_KEYSTORE_CERT_ALIAS,
0956:                                        AbstractToolAgent.COMMA_SEPARATOR_STR);
0957:                        if (ksAliasArray == null
0958:                                || ksAliasArray.length != ksArray.length)
0959:                            throw new Exception(
0960:                                    "Invalid number of array items in value for parameter: "
0961:                                            + SMIMEMailMessageHandler.SMIME_ENVELOP_BCC_KEYSTORE_CERT_ALIAS);
0962:
0963:                        for (int i = 0; i < bccs.length; i++) {
0964:
0965:                            if (!cerSet.contains("" + i))
0966:                                continue;
0967:
0968:                            if (ksArray[i] == null
0969:                                    || ksArray[i].trim().length() == 0)
0970:                                ksArray[i] = this .envDefaultKeystoreName;
0971:
0972:                            if (ksArray[i] != null
0973:                                    && ksArray[i].trim().length() != 0) {
0974:
0975:                                ksArray[i] = ksArray[i].replace('\\', '/');
0976:
0977:                                File fToCheck = new File(ksArray[i]);
0978:                                if (!fToCheck.exists()) {
0979:                                    if (this .envDefaultPath == null
0980:                                            || this .envDefaultPath.trim()
0981:                                                    .equals(""))
0982:                                        throw new Exception(
0983:                                                "Could not find the defined key store file: "
0984:                                                        + ksArray[i]);
0985:                                    else {
0986:                                        ksArray[i] = this .envDefaultPath
0987:                                                + ksArray[i];
0988:                                        ksArray[i] = ksArray[i].replaceAll(
0989:                                                "/{2}", "/");
0990:
0991:                                        fToCheck = new File(ksArray[i]);
0992:                                        if (!fToCheck.exists()) {
0993:                                            throw new Exception(
0994:                                                    "Could not find the defined key store file: "
0995:                                                            + ksArray[i]);
0996:                                        }
0997:                                    }
0998:                                }
0999:
1000:                                cerSet.remove("" + i);
1001:
1002:                                // email, TO|CC|BCC), path to ks file, ks type, ks password, public key
1003:                                // store alias
1004:                                if (this .securityType == 2)
1005:                                    esm.addRecipient(bccs[i], "BCC",
1006:                                            ksArray[i], ksTypeArray[i],
1007:                                            ksPasswArray[i], ksAliasArray[i]);
1008:                                else if (this .securityType > 2)
1009:                                    sesm.addRecipient(bccs[i], "BCC",
1010:                                            ksArray[i], ksTypeArray[i],
1011:                                            ksPasswArray[i], ksAliasArray[i]);
1012:                            }
1013:
1014:                        }
1015:
1016:                    }
1017:
1018:                    if (cerSet.size() > 0)
1019:                        throw new Exception(
1020:                                "There is mismatch in number of BCC recipients and corresponding SMIME parameters");
1021:
1022:                }
1023:
1024:                if (this .securityType == 2)
1025:                    return esm;
1026:                else if (this .securityType > 2)
1027:                    return sesm;
1028:                else
1029:                    return null;
1030:
1031:            }
1032:
1033:            private BaseSignedSMIMEObject addSigners(BaseSignedSMIMEObject ss)
1034:                    throws Exception {
1035:
1036:                String[] capEncArray = AbstractToolAgent
1037:                        .getParameterStringArray(
1038:                                this .sharkParams,
1039:                                SMIMEMailMessageHandler.SMIME_SIGNED_CAPABILITIES_ENCIPHER,
1040:                                AbstractToolAgent.COMMA_SEPARATOR_STR);
1041:                String[] capSigArray = AbstractToolAgent
1042:                        .getParameterStringArray(
1043:                                this .sharkParams,
1044:                                SMIMEMailMessageHandler.SMIME_SIGNED_CAPABILITIES_SIGNATURE,
1045:                                AbstractToolAgent.COMMA_SEPARATOR_STR);
1046:                String[] capSymArray = AbstractToolAgent
1047:                        .getParameterStringArray(
1048:                                this .sharkParams,
1049:                                SMIMEMailMessageHandler.SMIME_SIGNED_CAPABILITIES_SYMMETRIC,
1050:                                AbstractToolAgent.COMMA_SEPARATOR_STR);
1051:
1052:                // signing from pfx files
1053:                String[] pfxArray = AbstractToolAgent.getParameterStringArray(
1054:                        this .sharkParams,
1055:                        SMIMEMailMessageHandler.SMIME_SIGNED_PFX,
1056:                        AbstractToolAgent.COMMA_SEPARATOR_STR);
1057:                if (pfxArray != null && pfxArray.length > 0) {
1058:
1059:                    String[] pfxPasswArray = AbstractToolAgent
1060:                            .getParameterStringArray(
1061:                                    this .sharkParams,
1062:                                    SMIMEMailMessageHandler.SMIME_SIGNED_PFX_PASSWORD,
1063:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
1064:                    if (pfxPasswArray == null
1065:                            || pfxPasswArray.length != pfxArray.length)
1066:                        throw new Exception(
1067:                                "Invalid number of array items in value for parameter: "
1068:                                        + SMIMEMailMessageHandler.SMIME_SIGNED_PFX_PASSWORD);
1069:
1070:                    String[] pfxAlgArray = AbstractToolAgent
1071:                            .getParameterStringArray(
1072:                                    this .sharkParams,
1073:                                    SMIMEMailMessageHandler.SMIME_SIGNED_PFX_ALGORITHM,
1074:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
1075:                    if (pfxAlgArray == null || pfxAlgArray.length == 0) {
1076:                        pfxAlgArray = new String[pfxArray.length];
1077:                        for (int i = 0; i < pfxAlgArray.length; i++) {
1078:                            pfxAlgArray[i] = this .sigDefaultAlgorithm;
1079:                        }
1080:                    } else if (pfxAlgArray.length != pfxArray.length)
1081:                        throw new Exception(
1082:                                "Invalid number of array items in value for parameter: "
1083:                                        + SMIMEMailMessageHandler.SMIME_SIGNED_PFX_ALGORITHM);
1084:                    else {
1085:                        for (int i = 0; i < pfxAlgArray.length; i++) {
1086:                            if (pfxAlgArray[i] == null
1087:                                    || pfxAlgArray[i].trim().length() == 0)
1088:                                pfxAlgArray[i] = this .sigDefaultAlgorithm;
1089:                        }
1090:                    }
1091:
1092:                    boolean[] pfxIncludeCerArray = null;
1093:                    String[] tmpArray = AbstractToolAgent
1094:                            .getParameterStringArray(
1095:                                    this .sharkParams,
1096:                                    SMIMEMailMessageHandler.SMIME_SIGNED_PFX_INCLUDE_CERT,
1097:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
1098:                    if (tmpArray == null || tmpArray.length == 0) {
1099:                        pfxIncludeCerArray = new boolean[pfxArray.length];
1100:                        for (int i = 0; i < pfxIncludeCerArray.length; i++) {
1101:                            pfxIncludeCerArray[i] = this .sigDefaultIncludeCert;
1102:                        }
1103:                    } else if (tmpArray.length != pfxArray.length)
1104:                        throw new Exception(
1105:                                "Invalid number of array items in value for parameter: "
1106:                                        + SMIMEMailMessageHandler.SMIME_SIGNED_PFX_INCLUDE_CERT);
1107:                    else {
1108:                        pfxIncludeCerArray = new boolean[pfxArray.length];
1109:                        for (int i = 0; i < tmpArray.length; i++) {
1110:                            if (tmpArray[i] == null
1111:                                    || tmpArray[i].trim().length() == 0)
1112:                                pfxIncludeCerArray[i] = this .sigDefaultIncludeCert;
1113:                            else
1114:                                pfxIncludeCerArray[i] = Boolean.valueOf(
1115:                                        tmpArray[i]).booleanValue();
1116:                        }
1117:                    }
1118:
1119:                    boolean[] pfxIncludeAttribArray = null;
1120:                    tmpArray = AbstractToolAgent
1121:                            .getParameterStringArray(
1122:                                    this .sharkParams,
1123:                                    SMIMEMailMessageHandler.SMIME_SIGNED_PFX_INCLUDE_SIGN_ATTRIB,
1124:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
1125:                    if (tmpArray == null || tmpArray.length == 0) {
1126:                        pfxIncludeAttribArray = new boolean[pfxArray.length];
1127:                        for (int i = 0; i < pfxIncludeCerArray.length; i++) {
1128:                            pfxIncludeAttribArray[i] = this .sigDefaultIncludeSignAttrib;
1129:                        }
1130:                    } else if (tmpArray.length != pfxArray.length)
1131:                        throw new Exception(
1132:                                "Invalid number of array items in value for parameter: "
1133:                                        + SMIMEMailMessageHandler.SMIME_SIGNED_PFX_INCLUDE_SIGN_ATTRIB);
1134:                    else {
1135:                        pfxIncludeAttribArray = new boolean[pfxArray.length];
1136:                        for (int i = 0; i < tmpArray.length; i++) {
1137:                            if (tmpArray[i] == null
1138:                                    || tmpArray[i].trim().length() == 0)
1139:                                pfxIncludeAttribArray[i] = this .sigDefaultIncludeSignAttrib;
1140:                            else
1141:                                pfxIncludeAttribArray[i] = Boolean.valueOf(
1142:                                        tmpArray[i]).booleanValue();
1143:                        }
1144:                    }
1145:
1146:                    for (int i = 0; i < pfxArray.length; i++) {
1147:
1148:                        if (pfxArray[i] == null
1149:                                || pfxArray[i].trim().length() == 0)
1150:                            throw new Exception("Missing value for parameter: "
1151:                                    + SMIMEMailMessageHandler.SMIME_SIGNED_PFX);
1152:
1153:                        pfxArray[i] = pfxArray[i].replace('\\', '/');
1154:
1155:                        File fToCheck = new File(pfxArray[i]);
1156:                        if (!fToCheck.exists()) {
1157:                            if (this .sigDefaultPath == null
1158:                                    || this .sigDefaultPath.trim().equals(""))
1159:                                throw new Exception(
1160:                                        "Could not find the defined pfx file: "
1161:                                                + pfxArray[i]);
1162:                            else {
1163:                                pfxArray[i] = this .sigDefaultPath + pfxArray[i];
1164:                                pfxArray[i] = pfxArray[i].replaceAll("/{2}",
1165:                                        "/");
1166:
1167:                                fToCheck = new File(pfxArray[i]);
1168:                                if (!fToCheck.exists()) {
1169:                                    throw new Exception(
1170:                                            "Could not find the defined pfx file: "
1171:                                                    + pfxArray[i]);
1172:                                }
1173:                            }
1174:                        }
1175:
1176:                        if (capEncArray != null && capEncArray.length > 0)
1177:                            ss.setCapabilities(CapabilitiesConstants.ENCIPHER,
1178:                                    capEncArray);
1179:                        if (capSigArray != null && capSigArray.length > 0)
1180:                            ss.setCapabilities(CapabilitiesConstants.SIGNATURE,
1181:                                    capSigArray);
1182:                        if (capSymArray != null && capSymArray.length > 0)
1183:                            ss.setCapabilities(CapabilitiesConstants.SYMMETRIC,
1184:                                    capSymArray);
1185:
1186:                        // path to .pfx file, password, signing algorithm, include certs, include sign
1187:                        // attribs
1188:                        ss.addSigner(pfxArray[i], pfxPasswArray[i],
1189:                                pfxAlgArray[i], pfxIncludeCerArray[i],
1190:                                pfxIncludeAttribArray[i]);
1191:
1192:                    }
1193:                }
1194:
1195:                // signing from key store files
1196:                String[] ksArray = AbstractToolAgent.getParameterStringArray(
1197:                        this .sharkParams,
1198:                        SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE,
1199:                        AbstractToolAgent.COMMA_SEPARATOR_STR);
1200:                if (ksArray == null || ksArray.length == 0) {
1201:                    String[] ksAliasArray = AbstractToolAgent
1202:                            .getParameterStringArray(
1203:                                    this .sharkParams,
1204:                                    SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE_CERT_ALIAS,
1205:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
1206:                    if (ksAliasArray != null && ksAliasArray.length > 0) {
1207:                        ksArray = new String[ksAliasArray.length];
1208:                        for (int i = 0; i < ksArray.length; i++) {
1209:                            ksArray[i] = this .sigDefaultPath
1210:                                    + this .sigDefaultKeystoreName;
1211:                            ksArray[i] = ksArray[i].replaceAll("/{2}", "/");
1212:                        }
1213:                    }
1214:                }
1215:
1216:                if (ksArray != null && ksArray.length > 0) {
1217:
1218:                    String[] ksTypeArray = AbstractToolAgent
1219:                            .getParameterStringArray(
1220:                                    this .sharkParams,
1221:                                    SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE_TYPE,
1222:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
1223:                    if (ksTypeArray == null || ksTypeArray.length == 0) {
1224:                        ksTypeArray = new String[ksArray.length];
1225:                        for (int i = 0; i < ksTypeArray.length; i++) {
1226:                            ksTypeArray[i] = this .sigDefaultKeystoreType;
1227:                        }
1228:                    } else if (ksTypeArray.length != ksArray.length)
1229:                        throw new Exception(
1230:                                "Invalid number of array items in value for parameter: "
1231:                                        + SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE_TYPE);
1232:                    else {
1233:                        for (int i = 0; i < ksTypeArray.length; i++) {
1234:                            if (ksTypeArray[i] == null
1235:                                    || ksTypeArray[i].trim().length() == 0)
1236:                                ksTypeArray[i] = this .sigDefaultKeystoreType;
1237:                        }
1238:                    }
1239:
1240:                    String[] ksPasswArray = AbstractToolAgent
1241:                            .getParameterStringArray(
1242:                                    this .sharkParams,
1243:                                    SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE_PASSWORD,
1244:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
1245:                    if (ksPasswArray == null || ksPasswArray.length == 0) {
1246:                        ksPasswArray = new String[ksArray.length];
1247:                        for (int i = 0; i < ksPasswArray.length; i++) {
1248:                            ksPasswArray[i] = this .sigDefaultKeystorePassword;
1249:                        }
1250:                    } else if (ksPasswArray.length != ksArray.length)
1251:                        throw new Exception(
1252:                                "Invalid number of array items in value for parameter: "
1253:                                        + SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE_PASSWORD);
1254:                    else {
1255:                        for (int i = 0; i < ksPasswArray.length; i++) {
1256:                            if (ksPasswArray[i] == null
1257:                                    || ksPasswArray[i].trim().length() == 0)
1258:                                ksPasswArray[i] = this .sigDefaultKeystorePassword;
1259:                        }
1260:                    }
1261:
1262:                    String[] ksAliasArray = AbstractToolAgent
1263:                            .getParameterStringArray(
1264:                                    this .sharkParams,
1265:                                    SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE_CERT_ALIAS,
1266:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
1267:                    if (ksAliasArray == null
1268:                            || ksAliasArray.length != ksArray.length)
1269:                        throw new Exception(
1270:                                "Invalid number of array items in value for parameter: "
1271:                                        + SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE_CERT_ALIAS);
1272:
1273:                    String[] ksAlgArray = AbstractToolAgent
1274:                            .getParameterStringArray(
1275:                                    this .sharkParams,
1276:                                    SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE_ALGORITHM,
1277:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
1278:                    if (ksAlgArray == null || ksAlgArray.length == 0) {
1279:                        ksAlgArray = new String[ksArray.length];
1280:                        for (int i = 0; i < ksAlgArray.length; i++) {
1281:                            ksAlgArray[i] = this .sigDefaultAlgorithm;
1282:                        }
1283:                    } else if (ksAlgArray.length != ksArray.length)
1284:                        throw new Exception(
1285:                                "Invalid number of array items in value for parameter: "
1286:                                        + SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE_ALGORITHM);
1287:                    else {
1288:                        for (int i = 0; i < ksAlgArray.length; i++) {
1289:                            if (ksAlgArray[i] == null
1290:                                    || ksAlgArray[i].trim().length() == 0)
1291:                                ksAlgArray[i] = this .sigDefaultAlgorithm;
1292:                        }
1293:                    }
1294:
1295:                    boolean[] ksIncludeCerArray = null;
1296:                    String[] tmpArray = AbstractToolAgent
1297:                            .getParameterStringArray(
1298:                                    this .sharkParams,
1299:                                    SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE_INCLUDE_CERT,
1300:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
1301:                    if (tmpArray == null || tmpArray.length == 0) {
1302:                        ksIncludeCerArray = new boolean[ksArray.length];
1303:                        for (int i = 0; i < ksIncludeCerArray.length; i++) {
1304:                            ksIncludeCerArray[i] = this .sigDefaultIncludeCert;
1305:                        }
1306:                    } else if (tmpArray.length != ksArray.length)
1307:                        throw new Exception(
1308:                                "Invalid number of array items in value for parameter: "
1309:                                        + SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE_INCLUDE_CERT);
1310:                    else {
1311:                        ksIncludeCerArray = new boolean[ksArray.length];
1312:                        for (int i = 0; i < tmpArray.length; i++) {
1313:                            if (tmpArray[i] == null
1314:                                    || tmpArray[i].trim().length() == 0)
1315:                                ksIncludeCerArray[i] = this .sigDefaultIncludeCert;
1316:                            else
1317:                                ksIncludeCerArray[i] = Boolean.valueOf(
1318:                                        tmpArray[i]).booleanValue();
1319:                        }
1320:                    }
1321:
1322:                    boolean[] ksIncludeAttribArray = null;
1323:                    tmpArray = AbstractToolAgent
1324:                            .getParameterStringArray(
1325:                                    this .sharkParams,
1326:                                    SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE_INCLUDE_SIGN_ATTRIB,
1327:                                    AbstractToolAgent.COMMA_SEPARATOR_STR);
1328:                    if (tmpArray == null || tmpArray.length == 0) {
1329:                        ksIncludeAttribArray = new boolean[ksArray.length];
1330:                        for (int i = 0; i < ksIncludeCerArray.length; i++) {
1331:                            ksIncludeAttribArray[i] = this .sigDefaultIncludeSignAttrib;
1332:                        }
1333:                    } else if (tmpArray.length != ksArray.length)
1334:                        throw new Exception(
1335:                                "Invalid number of array items in value for parameter: "
1336:                                        + SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE_INCLUDE_SIGN_ATTRIB);
1337:                    else {
1338:                        ksIncludeAttribArray = new boolean[ksArray.length];
1339:                        for (int i = 0; i < tmpArray.length; i++) {
1340:                            if (tmpArray[i] == null
1341:                                    || tmpArray[i].trim().length() == 0)
1342:                                ksIncludeAttribArray[i] = this .sigDefaultIncludeSignAttrib;
1343:                            else
1344:                                ksIncludeAttribArray[i] = Boolean.valueOf(
1345:                                        tmpArray[i]).booleanValue();
1346:                        }
1347:                    }
1348:
1349:                    for (int i = 0; i < ksArray.length; i++) {
1350:
1351:                        if (ksArray[i] == null
1352:                                || ksArray[i].trim().length() == 0)
1353:                            ksArray[i] = this .sigDefaultKeystoreName;
1354:
1355:                        if (ksArray[i] == null
1356:                                || ksArray[i].trim().length() == 0)
1357:                            throw new Exception(
1358:                                    "Missing value for parameter: "
1359:                                            + SMIMEMailMessageHandler.SMIME_SIGNED_KEYSTORE);
1360:
1361:                        ksArray[i] = ksArray[i].replace('\\', '/');
1362:
1363:                        File fToCheck = new File(ksArray[i]);
1364:                        if (!fToCheck.exists()) {
1365:                            if (this .sigDefaultPath == null
1366:                                    || this .sigDefaultPath.trim().equals(""))
1367:                                throw new Exception(
1368:                                        "Could not find the defined key store file: "
1369:                                                + ksArray[i]);
1370:                            else {
1371:                                ksArray[i] = this .sigDefaultPath + ksArray[i];
1372:                                ksArray[i] = ksArray[i].replaceAll("/{2}", "/");
1373:
1374:                                fToCheck = new File(ksArray[i]);
1375:                                if (!fToCheck.exists()) {
1376:                                    throw new Exception(
1377:                                            "Could not find the defined key store file: "
1378:                                                    + ksArray[i]);
1379:                                }
1380:                            }
1381:                        }
1382:
1383:                        if (capEncArray != null && capEncArray.length > 0)
1384:                            ss.setCapabilities(CapabilitiesConstants.ENCIPHER,
1385:                                    capEncArray);
1386:                        if (capSigArray != null && capSigArray.length > 0)
1387:                            ss.setCapabilities(CapabilitiesConstants.SIGNATURE,
1388:                                    capSigArray);
1389:                        if (capSymArray != null && capSymArray.length > 0)
1390:                            ss.setCapabilities(CapabilitiesConstants.SYMMETRIC,
1391:                                    capSymArray);
1392:
1393:                        // path to ks file, ks type, ks password, private key store alias, signing
1394:                        // algorithm, include certs, include sign attribs
1395:                        ss.addSigner(ksArray[i], ksTypeArray[i],
1396:                                ksPasswArray[i], ksAliasArray[i],
1397:                                ksAlgArray[i], ksIncludeCerArray[i],
1398:                                ksIncludeAttribArray[i]);
1399:
1400:                    }
1401:                }
1402:
1403:                return ss;
1404:
1405:            }
1406:
1407:            private String getSecurityType() {
1408:                // SignedSMIME
1409:                if (this .securityType == 1) {
1410:                    return "Signed SMIME";
1411:                }
1412:                // EnvelopedSMIME
1413:                else if (this .securityType == 2) {
1414:                    return "Enveloped SMIME";
1415:                }
1416:                // SignedAndEnvelopedSMIME
1417:                else if (this .securityType == 3) {
1418:                    return "Signed And Enveloped SMIME";
1419:                }
1420:                // EnvelopedAndSignedSMIME
1421:                else if (this .securityType == 4) {
1422:                    return "Enveloped And Signed SMIME";
1423:                }
1424:                // Pure MIME
1425:                else {
1426:                    return "Pure MIME";
1427:                }
1428:            }
1429:
1430:            /**
1431:             * @param args
1432:             */
1433:            public static void main(String[] args) {
1434:                // TODO Auto-generated method stub
1435:
1436:            }
1437:
1438:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.