OLD | NEW |
| (Empty) |
1 /* | |
2 * Licensed to the Apache Software Foundation (ASF) under one or more | |
3 * contributor license agreements. See the NOTICE file distributed with | |
4 * this work for additional information regarding copyright ownership. | |
5 * The ASF licenses this file to You under the Apache License, Version 2.0 | |
6 * (the "License"); you may not use this file except in compliance with | |
7 * the License. You may obtain a copy of the License at | |
8 * | |
9 * http://www.apache.org/licenses/LICENSE-2.0 | |
10 * | |
11 * Unless required by applicable law or agreed to in writing, software | |
12 * distributed under the License is distributed on an "AS IS" BASIS, | |
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 * See the License for the specific language governing permissions and | |
15 * limitations under the License. | |
16 */ | |
17 | |
18 package org.apache.tomcat.jni; | |
19 | |
20 /** | |
21 * Session Ticket Key | |
22 */ | |
23 public final class SessionTicketKey { | |
24 /** | |
25 * Size of session ticket key name | |
26 */ | |
27 public static final int NAME_SIZE = 16; | |
28 /** | |
29 * Size of session ticket key HMAC key | |
30 */ | |
31 public static final int HMAC_KEY_SIZE = 16; | |
32 /** | |
33 * Size of session ticket key AES key | |
34 */ | |
35 public static final int AES_KEY_SIZE = 16; | |
36 /** | |
37 * Size of session ticker key | |
38 */ | |
39 public static final int TICKET_KEY_SIZE = NAME_SIZE + HMAC_KEY_SIZE + AES_KE
Y_SIZE; | |
40 | |
41 private final byte[] name; | |
42 private final byte[] hmacKey; | |
43 private final byte[] aesKey; | |
44 | |
45 /** | |
46 * Construct SesionTicketKey. | |
47 * @param name the name of the session ticket key | |
48 * @param hmacKey the HMAC key of the session ticket key | |
49 * @param aesKey the AES key of the session ticket key | |
50 */ | |
51 public SessionTicketKey(byte[] name, byte[] hmacKey, byte[] aesKey) { | |
52 if (name == null || name.length != NAME_SIZE) { | |
53 throw new IllegalArgumentException("Length of name should be 16"); | |
54 } | |
55 if (hmacKey == null || hmacKey.length != HMAC_KEY_SIZE) { | |
56 throw new IllegalArgumentException("Length of hmacKey should be 16")
; | |
57 } | |
58 if (aesKey == null || aesKey.length != AES_KEY_SIZE) { | |
59 throw new IllegalArgumentException("Length of aesKey should be 16"); | |
60 } | |
61 this.name = name; | |
62 this.hmacKey = hmacKey; | |
63 this.aesKey = aesKey; | |
64 } | |
65 | |
66 /** | |
67 * Get name. | |
68 * @return the name of the session ticket key | |
69 */ | |
70 public byte[] getName() { | |
71 return name; | |
72 } | |
73 | |
74 /** | |
75 * Get HMAC key. | |
76 * @return the HMAC key of the session ticket key | |
77 */ | |
78 public byte[] getHmacKey() { | |
79 return hmacKey; | |
80 } | |
81 | |
82 /** | |
83 * Get AES Key. | |
84 * @return the AES key of the session ticket key | |
85 */ | |
86 public byte[] getAesKey() { | |
87 return aesKey; | |
88 } | |
89 } | |
OLD | NEW |