24 */
25
26 package com.oracle.security.ucrypto;
27
28 import java.nio.ByteBuffer;
29 import java.util.Set;
30 import java.util.Arrays;
31 import java.util.concurrent.ConcurrentSkipListSet;
32 import java.lang.ref.*;
33
34 import java.security.*;
35 import java.security.spec.*;
36 import javax.crypto.*;
37
38 import javax.crypto.spec.SecretKeySpec;
39 import javax.crypto.spec.IvParameterSpec;
40
41 /**
42 * Internal class for context resource clean up.
43 *
44 * @since 1.9
45 */
46 final class CipherContextRef extends PhantomReference<NativeCipher>
47 implements Comparable<CipherContextRef> {
48
49 private static ReferenceQueue<NativeCipher> refQueue =
50 new ReferenceQueue<NativeCipher>();
51
52 // Needed to keep these references from being GC'ed until when their
53 // referents are GC'ed so we can do post-mortem processing
54 private static Set<CipherContextRef> refList =
55 new ConcurrentSkipListSet<CipherContextRef>();
56
57 final long id;
58 final boolean encrypt;
59
60 private static void drainRefQueueBounded() {
61 while (true) {
62 CipherContextRef next = (CipherContextRef) refQueue.poll();
63 if (next == null) break;
64 next.dispose(true);
|
24 */
25
26 package com.oracle.security.ucrypto;
27
28 import java.nio.ByteBuffer;
29 import java.util.Set;
30 import java.util.Arrays;
31 import java.util.concurrent.ConcurrentSkipListSet;
32 import java.lang.ref.*;
33
34 import java.security.*;
35 import java.security.spec.*;
36 import javax.crypto.*;
37
38 import javax.crypto.spec.SecretKeySpec;
39 import javax.crypto.spec.IvParameterSpec;
40
41 /**
42 * Internal class for context resource clean up.
43 *
44 * @since 9
45 */
46 final class CipherContextRef extends PhantomReference<NativeCipher>
47 implements Comparable<CipherContextRef> {
48
49 private static ReferenceQueue<NativeCipher> refQueue =
50 new ReferenceQueue<NativeCipher>();
51
52 // Needed to keep these references from being GC'ed until when their
53 // referents are GC'ed so we can do post-mortem processing
54 private static Set<CipherContextRef> refList =
55 new ConcurrentSkipListSet<CipherContextRef>();
56
57 final long id;
58 final boolean encrypt;
59
60 private static void drainRefQueueBounded() {
61 while (true) {
62 CipherContextRef next = (CipherContextRef) refQueue.poll();
63 if (next == null) break;
64 next.dispose(true);
|