~james-page/ubuntu/natty/rhino/fix-304702

« back to all changes in this revision

Viewing changes to toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan, Marcus Better, Matthias Klose, Damien Raude-Morvan
  • Date: 2009-04-13 02:40:15 UTC
  • mfrom: (11.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090413024015-i21xnoehukpipbcw
Tags: 1.7R2-1
[ Marcus Better ]
* Updated package descriptions.

[ Matthias Klose ]
* (Build-)depend on default-jre-headless/-jdk.
* Drop alternate dependencies on java2-runtime-headless and
  java2-runtime-headless. The binary package is currently built to
  require a java5 runtime.

[ Damien Raude-Morvan ]
* New upstream release.
  - new 02_exclude-jdk15 patch to exclude already compiled classes
    for jdk15 rebuild: gcj doesn't handle compiling classes already
    on its classpath
  - new "rhino-debugger" launcher for Rhino Debugger Swing UI
  - update "rhino" launcher to exclude OpenJDK bundled rhino (Closes: #512498)
* debian/{postinst,prerm }: scripts should take care of errors,
  add set -e before any instruction
* debian/rules: add new get-orig-source target using uscan
* debian/control:
  - Build-Depends on specialized default-jdk-builddep instead of
  default-jdk
  - Bump Standards-Version to 3.8.1: Wrap Uploaders field
  - add Depends on ${misc:Depends}

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
public class JavaPolicySecurity extends SecurityProxy
49
49
{
50
50
 
51
 
    public Class getStaticSecurityDomainClassInternal() {
 
51
    @Override
 
52
    public Class<?> getStaticSecurityDomainClassInternal() {
52
53
        return ProtectionDomain.class;
53
54
    }
54
55
 
62
63
            this.domain = domain;
63
64
        }
64
65
 
65
 
        public Class defineClass(String name, byte[] data) {
 
66
        public Class<?> defineClass(String name, byte[] data) {
66
67
            return super.defineClass(name, data, 0, data.length, domain);
67
68
        }
68
69
 
69
 
        public void linkClass(Class cl) {
 
70
        public void linkClass(Class<?> cl) {
70
71
            resolveClass(cl);
71
72
        }
72
73
    }
86
87
            setReadOnly();
87
88
        }
88
89
 
 
90
        @Override
89
91
        public void add(Permission permission) {
90
92
            throw new RuntimeException("NOT IMPLEMENTED");
91
93
        }
92
94
 
 
95
        @Override
93
96
        public boolean implies(Permission permission) {
94
97
            if (_statisPermissions != null) {
95
98
                if (!_statisPermissions.implies(permission)) {
104
107
            }
105
108
        }
106
109
 
107
 
        public Enumeration elements()
 
110
        @Override
 
111
        public Enumeration<Permission> elements()
108
112
        {
109
 
            return new Enumeration() {
 
113
            return new Enumeration<Permission>() {
110
114
                public boolean hasMoreElements() { return false; }
111
 
                public Object nextElement() { return null; }
 
115
                public Permission nextElement() { return null; }
112
116
            };
113
117
        }
114
118
 
 
119
        @Override
115
120
        public String toString() {
116
121
            StringBuffer sb = new StringBuffer();
117
122
            sb.append(getClass().getName());
135
140
        new CodeSource(null,  (java.security.cert.Certificate[])null);
136
141
    }
137
142
 
 
143
    @Override
138
144
    protected void callProcessFileSecure(final Context cx,
139
145
                                         final Scriptable scope,
140
146
                                         final String filename)
141
147
    {
142
 
        AccessController.doPrivileged(new PrivilegedAction() {
 
148
        AccessController.doPrivileged(new PrivilegedAction<Object>() {
143
149
            public Object run() {
144
150
                URL url = getUrlObj(filename);
145
151
                ProtectionDomain staticDomain = getUrlDomain(url);
183
189
        return new ProtectionDomain(cs, pc);
184
190
    }
185
191
 
 
192
    @Override
186
193
    public GeneratedClassLoader
187
194
    createClassLoader(ClassLoader parentLoader, Object securityDomain)
188
195
    {
190
197
        return new Loader(parentLoader, domain);
191
198
    }
192
199
 
 
200
    @Override
193
201
    public Object getDynamicSecurityDomain(Object securityDomain)
194
202
    {
195
203
        ProtectionDomain staticDomain = (ProtectionDomain)securityDomain;
202
210
        return contextDomain;
203
211
    }
204
212
 
 
213
    @Override
205
214
    public Object callWithDomain(Object securityDomain,
206
215
                                 final Context cx,
207
216
                                 final Callable callable,
210
219
                                 final Object[] args)
211
220
    {
212
221
        ProtectionDomain staticDomain = (ProtectionDomain)securityDomain;
213
 
        // There is no direct way in Java to intersect permitions according
 
222
        // There is no direct way in Java to intersect permissions according
214
223
        // stack context with additional domain.
215
224
        // The following implementation first constructs ProtectionDomain
216
225
        // that allows actions only allowed by both staticDomain and current
229
238
        ProtectionDomain[] tmp = { dynamicDomain };
230
239
        AccessControlContext restricted = new AccessControlContext(tmp);
231
240
 
232
 
        PrivilegedAction action = new PrivilegedAction() {
 
241
        PrivilegedAction<Object> action = new PrivilegedAction<Object>() {
233
242
            public Object run() {
234
243
                return callable.call(cx, scope, thisObj, args);
235
244
            }