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