001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel.model.dataformat; 018 019import javax.xml.bind.annotation.XmlAccessType; 020import javax.xml.bind.annotation.XmlAccessorType; 021import javax.xml.bind.annotation.XmlAttribute; 022import javax.xml.bind.annotation.XmlRootElement; 023 024import org.apache.camel.model.DataFormatDefinition; 025import org.apache.camel.spi.Metadata; 026 027/** 028 * PGP data format is used for encrypting and decrypting of messages using Java 029 * Cryptographic Extension and PGP. 030 */ 031@Metadata(firstVersion = "2.9.0", label = "dataformat,transformation,security", title = "PGP") 032@XmlRootElement(name = "pgp") 033@XmlAccessorType(XmlAccessType.FIELD) 034public class PGPDataFormat extends DataFormatDefinition { 035 @XmlAttribute 036 private String keyUserid; 037 @XmlAttribute 038 private String signatureKeyUserid; 039 @XmlAttribute 040 private String password; 041 @XmlAttribute 042 private String signaturePassword; 043 @XmlAttribute 044 private String keyFileName; 045 @XmlAttribute 046 private String signatureKeyFileName; 047 @XmlAttribute 048 private String signatureKeyRing; 049 @XmlAttribute 050 @Metadata(defaultValue = "false", javaType = "java.lang.Boolean") 051 private String armored; 052 @XmlAttribute 053 @Metadata(defaultValue = "true", javaType = "java.lang.Boolean") 054 private String integrity; 055 @XmlAttribute 056 private String provider; 057 @XmlAttribute 058 @Metadata(javaType = "java.lang.Integer") 059 private String algorithm; 060 @XmlAttribute 061 @Metadata(javaType = "java.lang.Integer") 062 private String compressionAlgorithm; 063 @XmlAttribute 064 @Metadata(javaType = "java.lang.Integer") 065 private String hashAlgorithm; 066 @XmlAttribute 067 private String signatureVerificationOption; 068 069 public PGPDataFormat() { 070 super("pgp"); 071 } 072 073 public String getSignatureKeyUserid() { 074 return signatureKeyUserid; 075 } 076 077 /** 078 * User ID of the key in the PGP keyring used for signing (during 079 * encryption) or signature verification (during decryption). During the 080 * signature verification process the specified User ID restricts the public 081 * keys from the public keyring which can be used for the verification. If 082 * no User ID is specified for the signature verficiation then any public 083 * key in the public keyring can be used for the verification. Can also be 084 * only a part of a user ID. For example, if the user ID is "Test User 085 * <test@camel.com>" then you can use the part "Test User" or 086 * "<test@camel.com>" to address the User ID. 087 */ 088 public void setSignatureKeyUserid(String signatureKeyUserid) { 089 this.signatureKeyUserid = signatureKeyUserid; 090 } 091 092 public String getSignaturePassword() { 093 return signaturePassword; 094 } 095 096 /** 097 * Password used when opening the private key used for signing (during 098 * encryption). 099 */ 100 public void setSignaturePassword(String signaturePassword) { 101 this.signaturePassword = signaturePassword; 102 } 103 104 public String getSignatureKeyFileName() { 105 return signatureKeyFileName; 106 } 107 108 /** 109 * Filename of the keyring to use for signing (during encryption) or for 110 * signature verification (during decryption); must be accessible as a 111 * classpath resource (but you can specify a location in the file system by 112 * using the "file:" prefix). 113 */ 114 public void setSignatureKeyFileName(String signatureKeyFileName) { 115 this.signatureKeyFileName = signatureKeyFileName; 116 } 117 118 public String getSignatureKeyRing() { 119 return signatureKeyRing; 120 } 121 122 /** 123 * Keyring used for signing/verifying as byte array. You can not set the 124 * signatureKeyFileName and signatureKeyRing at the same time. 125 */ 126 public void setSignatureKeyRing(String signatureKeyRing) { 127 this.signatureKeyRing = signatureKeyRing; 128 } 129 130 public String getHashAlgorithm() { 131 return hashAlgorithm; 132 } 133 134 /** 135 * Signature hash algorithm; possible values are defined in 136 * org.bouncycastle.bcpg.HashAlgorithmTags; for example 2 (= SHA1), 8 (= 137 * SHA256), 9 (= SHA384), 10 (= SHA512), 11 (=SHA224). Only relevant for 138 * signing. 139 */ 140 public void setHashAlgorithm(String hashAlgorithm) { 141 this.hashAlgorithm = hashAlgorithm; 142 } 143 144 public String getArmored() { 145 return armored; 146 } 147 148 /** 149 * This option will cause PGP to base64 encode the encrypted text, making it 150 * available for copy/paste, etc. 151 */ 152 public void setArmored(String armored) { 153 this.armored = armored; 154 } 155 156 public String getIntegrity() { 157 return integrity; 158 } 159 160 /** 161 * Adds an integrity check/sign into the encryption file. 162 * <p/> 163 * The default value is true. 164 */ 165 public void setIntegrity(String integrity) { 166 this.integrity = integrity; 167 } 168 169 public String getKeyFileName() { 170 return keyFileName; 171 } 172 173 /** 174 * Filename of the keyring; must be accessible as a classpath resource (but 175 * you can specify a location in the file system by using the "file:" 176 * prefix). 177 */ 178 public void setKeyFileName(String keyFileName) { 179 this.keyFileName = keyFileName; 180 } 181 182 public String getKeyUserid() { 183 return keyUserid; 184 } 185 186 /** 187 * The user ID of the key in the PGP keyring used during encryption. Can 188 * also be only a part of a user ID. For example, if the user ID is "Test 189 * User <test@camel.com>" then you can use the part "Test User" or 190 * "<test@camel.com>" to address the user ID. 191 */ 192 public void setKeyUserid(String keyUserid) { 193 this.keyUserid = keyUserid; 194 } 195 196 public String getPassword() { 197 return password; 198 } 199 200 public String getAlgorithm() { 201 return algorithm; 202 } 203 204 /** 205 * Symmetric key encryption algorithm; possible values are defined in 206 * org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags; for example 2 (= TRIPLE 207 * DES), 3 (= CAST5), 4 (= BLOWFISH), 6 (= DES), 7 (= AES_128). Only 208 * relevant for encrypting. 209 */ 210 public void setAlgorithm(String algorithm) { 211 this.algorithm = algorithm; 212 } 213 214 public String getCompressionAlgorithm() { 215 return compressionAlgorithm; 216 } 217 218 /** 219 * Compression algorithm; possible values are defined in 220 * org.bouncycastle.bcpg.CompressionAlgorithmTags; for example 0 (= 221 * UNCOMPRESSED), 1 (= ZIP), 2 (= ZLIB), 3 (= BZIP2). Only relevant for 222 * encrypting. 223 */ 224 public void setCompressionAlgorithm(String compressionAlgorithm) { 225 this.compressionAlgorithm = compressionAlgorithm; 226 } 227 228 /** 229 * Password used when opening the private key (not used for encryption). 230 */ 231 public void setPassword(String password) { 232 this.password = password; 233 } 234 235 public String getProvider() { 236 return provider; 237 } 238 239 /** 240 * Java Cryptography Extension (JCE) provider, default is Bouncy Castle 241 * ("BC"). Alternatively you can use, for example, the IAIK JCE provider; in 242 * this case the provider must be registered beforehand and the Bouncy 243 * Castle provider must not be registered beforehand. The Sun JCE provider 244 * does not work. 245 */ 246 public void setProvider(String provider) { 247 this.provider = provider; 248 } 249 250 public String getSignatureVerificationOption() { 251 return signatureVerificationOption; 252 } 253 254 /** 255 * Controls the behavior for verifying the signature during unmarshaling. 256 * There are 4 values possible: "optional": The PGP message may or may not 257 * contain signatures; if it does contain signatures, then a signature 258 * verification is executed. "required": The PGP message must contain at 259 * least one signature; if this is not the case an exception (PGPException) 260 * is thrown. A signature verification is executed. "ignore": Contained 261 * signatures in the PGP message are ignored; no signature verification is 262 * executed. "no_signature_allowed": The PGP message must not contain a 263 * signature; otherwise an exception (PGPException) is thrown. 264 */ 265 public void setSignatureVerificationOption(String signatureVerificationOption) { 266 this.signatureVerificationOption = signatureVerificationOption; 267 } 268}