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 * Encrypt and decrypt messages using Java Cryptography Extension (JCE). 029 */ 030@Metadata(firstVersion = "2.3.0", label = "dataformat,transformation,security", title = "Crypto (Java Cryptographic Extension)") 031@XmlRootElement(name = "crypto") 032@XmlAccessorType(XmlAccessType.FIELD) 033public class CryptoDataFormat extends DataFormatDefinition { 034 @XmlAttribute 035 private String algorithm; 036 @XmlAttribute 037 private String cryptoProvider; 038 @XmlAttribute 039 private String keyRef; 040 @XmlAttribute 041 private String initVectorRef; 042 @XmlAttribute 043 private String algorithmParameterRef; 044 @XmlAttribute 045 @Metadata(javaType = "java.lang.Integer") 046 private String buffersize; 047 @XmlAttribute 048 @Metadata(defaultValue = "HmacSHA1") 049 private String macAlgorithm = "HmacSHA1"; 050 @XmlAttribute 051 @Metadata(defaultValue = "true", javaType = "java.lang.Boolean") 052 private String shouldAppendHMAC; 053 @XmlAttribute 054 @Metadata(defaultValue = "false", javaType = "java.lang.Boolean") 055 private String inline; 056 057 public CryptoDataFormat() { 058 super("crypto"); 059 } 060 061 public String getAlgorithm() { 062 return algorithm; 063 } 064 065 /** 066 * The JCE algorithm name indicating the cryptographic algorithm that will 067 * be used. 068 * <p/> 069 */ 070 public void setAlgorithm(String algorithm) { 071 this.algorithm = algorithm; 072 } 073 074 public String getCryptoProvider() { 075 return cryptoProvider; 076 } 077 078 /** 079 * The name of the JCE Security Provider that should be used. 080 */ 081 public void setCryptoProvider(String cryptoProvider) { 082 this.cryptoProvider = cryptoProvider; 083 } 084 085 public String getKeyRef() { 086 return keyRef; 087 } 088 089 /** 090 * Refers to the secret key to lookup from the register to use. 091 */ 092 public void setKeyRef(String keyRef) { 093 this.keyRef = keyRef; 094 } 095 096 public String getInitVectorRef() { 097 return initVectorRef; 098 } 099 100 /** 101 * Refers to a byte array containing the Initialization Vector that will be 102 * used to initialize the Cipher. 103 */ 104 public void setInitVectorRef(String initVectorRef) { 105 this.initVectorRef = initVectorRef; 106 } 107 108 public String getAlgorithmParameterRef() { 109 return algorithmParameterRef; 110 } 111 112 /** 113 * A JCE AlgorithmParameterSpec used to initialize the Cipher. 114 * <p/> 115 * Will lookup the type using the given name as a 116 * {@link java.security.spec.AlgorithmParameterSpec} type. 117 */ 118 public void setAlgorithmParameterRef(String algorithmParameterRef) { 119 this.algorithmParameterRef = algorithmParameterRef; 120 } 121 122 public String getBuffersize() { 123 return buffersize; 124 } 125 126 /** 127 * The size of the buffer used in the signature process. 128 */ 129 public void setBuffersize(String buffersize) { 130 this.buffersize = buffersize; 131 } 132 133 public String getMacAlgorithm() { 134 return macAlgorithm; 135 } 136 137 /** 138 * The JCE algorithm name indicating the Message Authentication algorithm. 139 */ 140 public void setMacAlgorithm(String macAlgorithm) { 141 this.macAlgorithm = macAlgorithm; 142 } 143 144 public String getShouldAppendHMAC() { 145 return shouldAppendHMAC; 146 } 147 148 /** 149 * Flag indicating that a Message Authentication Code should be calculated 150 * and appended to the encrypted data. 151 */ 152 public void setShouldAppendHMAC(String shouldAppendHMAC) { 153 this.shouldAppendHMAC = shouldAppendHMAC; 154 } 155 156 public String getInline() { 157 return inline; 158 } 159 160 /** 161 * Flag indicating that the configured IV should be inlined into the 162 * encrypted data stream. 163 * <p/> 164 * Is by default false. 165 */ 166 public void setInline(String inline) { 167 this.inline = inline; 168 } 169}