01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26: package com.sun.midp.jsr238;
27:
28: import com.sun.midp.security.SecurityToken;
29: import com.sun.midp.security.ImplicitlyTrustedClass;
30: import com.sun.midp.security.SecurityInitializerImpl;
31:
32: /**
33: * A utility class that initializes internal security token for
34: * JSR 238 implemenation classes. Modify this class instead of
35: * com.sun.midp.security.SecurityInitializer each time another
36: * JSR 238 implementation class requires initializing security token.
37: */
38: public final class SecurityInitializer {
39:
40: /** List of trusted class names for JSR 238 */
41: final static private String[] trustedClasses = new String[] {
42: "com.sun.j2me.global.DevResourceBundleReader$SecurityTrusted",
43: "com.sun.j2me.global.DevResourceManagerFactory$SecurityTrusted",
44: "com.sun.j2me.global.NormalizationTableImpl$SecurityTrusted",
45: "com.sun.j2me.global.CollationElementTableImpl$SecurityTrusted" };
46:
47: /**
48: * Inner class to request security token from SecurityInitializer.
49: * SecurityInitializer should be able to check this inner class name.
50: */
51: static private class SecurityTrusted implements
52: ImplicitlyTrustedClass {
53: };
54:
55: /**
56: * Internal implementation of the JSR security initializer
57: * redispatching security token requested from the core
58: * security initializer
59: */
60: private static SecurityInitializerImpl impl = new SecurityInitializerImpl(
61: com.sun.midp.security.SecurityInitializer
62: .requestToken(new SecurityTrusted()),
63: trustedClasses);
64:
65: /**
66: * Hand out internal security token to trusted requesters
67: *
68: * @param trusted object to check whether token can be given to caller
69: * @return if the object is really trusted to requested
70: */
71: final public static SecurityToken requestToken(
72: ImplicitlyTrustedClass trusted) {
73: return impl.requestToken(trusted);
74: }
75: }
|