View Javadoc

1   /*
2    * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.properties.api.core.security;
17  
18  import java.io.Serializable;
19  
20  import de.smartics.properties.api.core.domain.PropertyDescriptor;
21  
22  /**
23   * Helper to en- and decrypt property values.
24   */
25  public interface PropertyValueSecurity extends Serializable
26  {
27    // ********************************* Fields *********************************
28  
29    // --- constants ------------------------------------------------------------
30  
31    // ****************************** Initializer *******************************
32  
33    // ****************************** Inner Classes *****************************
34  
35    // ********************************* Methods ********************************
36  
37    // --- get&set --------------------------------------------------------------
38  
39    // --- business -------------------------------------------------------------
40  
41    /**
42     * Decrypts the given property value.
43     *
44     * @param descriptor the descriptor of the property.
45     * @param encryptedValue the encrypted value of the property to be decrypted.
46     * @return the decrypted value.
47     * @throws NullPointerException may be thrown if {@code descriptor} is
48     *           <code>null</code>.
49     * @throws SecurityException if the value cannot be decrypted.
50     */
51    String decrypt(PropertyDescriptor descriptor, String encryptedValue)
52      throws NullPointerException, SecurityException;
53  
54    /**
55     * Encrypts the given property value.
56     *
57     * @param descriptor the descriptor of the property.
58     * @param plainValue the plain value of the property to be encrypted.
59     * @return the encrypted value.
60     * @throws NullPointerException may be thrown if {@code descriptor} is
61     *           <code>null</code>.
62     * @throws SecurityException if the value cannot be encrypted.
63     */
64    String encrypt(PropertyDescriptor descriptor, String plainValue)
65      throws NullPointerException, SecurityException;
66  
67    // --- object basics --------------------------------------------------------
68  
69  }