1/*
2 * reserved comment block
3 * DO NOT REMOVE OR ALTER!
4 */
5/**
6 * Licensed to the Apache Software Foundation (ASF) under one
7 * or more contributor license agreements. See the NOTICE file
8 * distributed with this work for additional information
9 * regarding copyright ownership. The ASF licenses this file
10 * to you under the Apache License, Version 2.0 (the
11 * "License"); you may not use this file except in compliance
12 * with the License. You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing,
17 * software distributed under the License is distributed on an
18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 * KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations
21 * under the License.
22 */
23package com.sun.org.apache.xml.internal.security.encryption;
24
25/**
26 * {@code CipherData} provides encrypted data. It must either contain the
27 * encrypted octet sequence as base64 encoded text of the
28 * {@code CipherValue} element, or provide a reference to an external
29 * location containing the encrypted octet sequence via the
30 * {@code CipherReference} element.
31 * <p>
32 * The schema definition is as follows:
33 * <pre>{@code
34 * <element name='CipherData' type='xenc:CipherDataType'/>
35 * <complexType name='CipherDataType'>
36 *     <choice>
37 *         <element name='CipherValue' type='base64Binary'/>
38 *         <element ref='xenc:CipherReference'/>
39 *     </choice>
40 * </complexType>
41 * }</pre>
42 *
43 * @author Axl Mattheus
44 */
45public interface CipherData {
46
47    /** VALUE_TYPE ASN */
48    int VALUE_TYPE = 0x00000001;
49
50    /** REFERENCE_TYPE ASN */
51    int REFERENCE_TYPE = 0x00000002;
52
53    /**
54     * Returns the type of encrypted data contained in the
55     * {@code CipherData}.
56     *
57     * @return {@code VALUE_TYPE} if the encrypted data is contained as
58     *   {@code CipherValue} or {@code REFERENCE_TYPE} if the
59     *   encrypted data is contained as {@code CipherReference}.
60     */
61    int getDataType();
62
63    /**
64     * Returns the cipher value as a base64 encoded {@code byte} array.
65     *
66     * @return the {@code CipherData}'s value.
67     */
68    CipherValue getCipherValue();
69
70    /**
71     * Sets the {@code CipherData}'s value.
72     *
73     * @param value the value of the {@code CipherData}.
74     * @throws XMLEncryptionException
75     */
76    void setCipherValue(CipherValue value) throws XMLEncryptionException;
77
78    /**
79     * Returns a reference to an external location containing the encrypted
80     * octet sequence ({@code byte} array).
81     *
82     * @return the reference to an external location containing the encrypted
83     * octet sequence.
84     */
85    CipherReference getCipherReference();
86
87    /**
88     * Sets the {@code CipherData}'s reference.
89     *
90     * @param reference an external location containing the encrypted octet sequence.
91     * @throws XMLEncryptionException
92     */
93    void setCipherReference(CipherReference reference) throws XMLEncryptionException;
94}
95
96