~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/ikvm/openjdk/sun/misc/SharedSecrets.java

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
 
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
4
 *
 
5
 * This code is free software; you can redistribute it and/or modify it
 
6
 * under the terms of the GNU General Public License version 2 only, as
 
7
 * published by the Free Software Foundation.  Oracle designates this
 
8
 * particular file as subject to the "Classpath" exception as provided
 
9
 * by Oracle in the LICENSE file that accompanied this code.
 
10
 *
 
11
 * This code is distributed in the hope that it will be useful, but WITHOUT
 
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
14
 * version 2 for more details (a copy is included in the LICENSE file that
 
15
 * accompanied this code).
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License version
 
18
 * 2 along with this work; if not, write to the Free Software Foundation,
 
19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
20
 *
 
21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 
22
 * or visit www.oracle.com if you need additional information or have any
 
23
 * questions.
 
24
 */
 
25
 
 
26
package sun.misc;
 
27
 
 
28
import java.util.jar.JarFile;
 
29
import java.io.Console;
 
30
import java.security.ProtectionDomain;
 
31
import javax.security.auth.kerberos.KeyTab;
 
32
 
 
33
import java.security.AccessController;
 
34
 
 
35
/** A repository of "shared secrets", which are a mechanism for
 
36
    calling implementation-private methods in another package without
 
37
    using reflection. A package-private class implements a public
 
38
    interface and provides the ability to call package-private methods
 
39
    within that package; the object implementing that interface is
 
40
    provided through a third package to which access is restricted.
 
41
    This framework avoids the primary disadvantage of using reflection
 
42
    for this purpose, namely the loss of compile-time checking. */
 
43
 
 
44
public class SharedSecrets {
 
45
    private static final Unsafe unsafe = Unsafe.getUnsafe();
 
46
    private static JavaUtilJarAccess javaUtilJarAccess;
 
47
    private static JavaLangAccess javaLangAccess = LangHelper.getJavaLangAccess();
 
48
    private static JavaIOAccess javaIOAccess;
 
49
    private static JavaNetAccess javaNetAccess;
 
50
    private static JavaNetHttpCookieAccess javaNetHttpCookieAccess;
 
51
    private static JavaNioAccess javaNioAccess;
 
52
    private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess;
 
53
    private static JavaSecurityAccess javaSecurityAccess;
 
54
    private static JavaxSecurityAuthKerberosAccess javaxSecurityAuthKerberosAccess;
 
55
 
 
56
    public static JavaUtilJarAccess javaUtilJarAccess() {
 
57
        if (javaUtilJarAccess == null) {
 
58
            // Ensure JarFile is initialized; we know that that class
 
59
            // provides the shared secret
 
60
            unsafe.ensureClassInitialized(JarFile.class);
 
61
        }
 
62
        return javaUtilJarAccess;
 
63
    }
 
64
 
 
65
    public static void setJavaUtilJarAccess(JavaUtilJarAccess access) {
 
66
        javaUtilJarAccess = access;
 
67
    }
 
68
 
 
69
    public static JavaLangAccess getJavaLangAccess() {
 
70
        return javaLangAccess;
 
71
    }
 
72
 
 
73
    public static void setJavaNetAccess(JavaNetAccess jna) {
 
74
        javaNetAccess = jna;
 
75
    }
 
76
 
 
77
    public static JavaNetAccess getJavaNetAccess() {
 
78
        return javaNetAccess;
 
79
    }
 
80
 
 
81
    public static void setJavaNetHttpCookieAccess(JavaNetHttpCookieAccess a) {
 
82
        javaNetHttpCookieAccess = a;
 
83
    }
 
84
 
 
85
    public static JavaNetHttpCookieAccess getJavaNetHttpCookieAccess() {
 
86
        if (javaNetHttpCookieAccess == null)
 
87
            unsafe.ensureClassInitialized(java.net.HttpCookie.class);
 
88
        return javaNetHttpCookieAccess;
 
89
    }
 
90
 
 
91
    public static void setJavaNioAccess(JavaNioAccess jna) {
 
92
        javaNioAccess = jna;
 
93
    }
 
94
 
 
95
    public static JavaNioAccess getJavaNioAccess() {
 
96
        if (javaNioAccess == null) {
 
97
            // [IKVM] OpenJDK initializes java.nio.ByteOrder here, but that doesn't work
 
98
            java.nio.ByteOrder.nativeOrder();
 
99
        }
 
100
        return javaNioAccess;
 
101
    }
 
102
 
 
103
    public static void setJavaIOAccess(JavaIOAccess jia) {
 
104
        javaIOAccess = jia;
 
105
    }
 
106
 
 
107
    public static JavaIOAccess getJavaIOAccess() {
 
108
        if (javaIOAccess == null) {
 
109
            unsafe.ensureClassInitialized(Console.class);
 
110
        }
 
111
        return javaIOAccess;
 
112
    }
 
113
 
 
114
    public static void setJavaSecurityProtectionDomainAccess
 
115
        (JavaSecurityProtectionDomainAccess jspda) {
 
116
            javaSecurityProtectionDomainAccess = jspda;
 
117
    }
 
118
 
 
119
    public static JavaSecurityProtectionDomainAccess
 
120
        getJavaSecurityProtectionDomainAccess() {
 
121
            if (javaSecurityProtectionDomainAccess == null)
 
122
                unsafe.ensureClassInitialized(ProtectionDomain.class);
 
123
            return javaSecurityProtectionDomainAccess;
 
124
    }
 
125
 
 
126
    public static void setJavaSecurityAccess(JavaSecurityAccess jsa) {
 
127
        javaSecurityAccess = jsa;
 
128
    }
 
129
 
 
130
    public static JavaSecurityAccess getJavaSecurityAccess() {
 
131
        if (javaSecurityAccess == null) {
 
132
            // [IKVM] OpenJDK initializes AccessController here, but that's a bug
 
133
            unsafe.ensureClassInitialized(ProtectionDomain.class);
 
134
        }
 
135
        return javaSecurityAccess;
 
136
    }
 
137
 
 
138
    public static void setJavaxSecurityAuthKerberosAccess
 
139
            (JavaxSecurityAuthKerberosAccess jsaka) {
 
140
        javaxSecurityAuthKerberosAccess = jsaka;
 
141
    }
 
142
 
 
143
    public static JavaxSecurityAuthKerberosAccess
 
144
            getJavaxSecurityAuthKerberosAccess() {
 
145
        if (javaxSecurityAuthKerberosAccess == null)
 
146
            unsafe.ensureClassInitialized(KeyTab.class);
 
147
        return javaxSecurityAuthKerberosAccess;
 
148
    }
 
149
}