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 * Crypto data format is used for encrypting and decrypting of messages using 029 * Java Cryptographic Extension. 030 */ 031@Metadata(firstVersion = "2.3.0", label = "dataformat,transformation,security", title = "Crypto (Java Cryptographic Extension)") 032@XmlRootElement(name = "crypto") 033@XmlAccessorType(XmlAccessType.FIELD) 034public class CryptoDataFormat extends DataFormatDefinition { 035 @XmlAttribute 036 @Metadata(defaultValue = "DES/CBC/PKCS5Padding") 037 private String algorithm; 038 @XmlAttribute 039 private String cryptoProvider; 040 @XmlAttribute 041 private String keyRef; 042 @XmlAttribute 043 private String initVectorRef; 044 @XmlAttribute 045 private String algorithmParameterRef; 046 @XmlAttribute 047 private Integer buffersize; 048 @XmlAttribute 049 @Metadata(defaultValue = "HmacSHA1") 050 private String macAlgorithm = "HmacSHA1"; 051 @XmlAttribute 052 private Boolean shouldAppendHMAC; 053 @XmlAttribute 054 private Boolean inline; 055 056 public CryptoDataFormat() { 057 super("crypto"); 058 } 059 060 public String getAlgorithm() { 061 return algorithm; 062 } 063 064 /** 065 * The JCE algorithm name indicating the cryptographic algorithm that will 066 * be used. 067 * <p/> 068 * Is by default DES/CBC/PKCS5Padding. 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 Integer getBuffersize() { 123 return buffersize; 124 } 125 126 /** 127 * The size of the buffer used in the signature process. 128 */ 129 public void setBuffersize(Integer 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 Boolean 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(Boolean shouldAppendHMAC) { 153 this.shouldAppendHMAC = shouldAppendHMAC; 154 } 155 156 public Boolean 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(Boolean inline) { 167 this.inline = inline; 168 } 169}