Ignore:
Timestamp:
Feb 13, 2012, 10:07:12 PM (14 years ago)
Author:
dmik
Message:

trunk: Merged in openjdk6 b24 from branches/vendor/oracle.

Location:
trunk/openjdk
Files:
58 edited

Legend:

Unmodified
Added
Removed
  • trunk/openjdk

  • trunk/openjdk/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java

    r278 r309  
    11/*
    2  * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java

    r278 r309  
    11/*
    2  * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java

    r278 r309  
    11/*
    2  * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java

    r278 r309  
    11/*
    2  * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/com/sun/net/ssl/HttpsURLConnection.java

    r278 r309  
    11/*
    2  * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    180180                "no SSLSocketFactory specified");
    181181        }
     182
     183        SecurityManager sm = System.getSecurityManager();
     184        if (sm != null) {
     185            sm.checkSetFactory();
     186        }
     187
    182188        sslSocketFactory = sf;
    183189    }
  • trunk/openjdk/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java

    r278 r309  
    11/*
    2  * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    3030import java.lang.reflect.Method;
    3131import java.io.*;
     32import java.security.*;
    3233import java.util.*;
    3334
     
    4647    private static final boolean DEBUG = false;
    4748
     49    private AccessControlContext accCtxt;
     50
    4851    /* Scope where standard JavaScript objects and our
    4952     * extensions to it are stored. Note that these are not
     
    6467    static {
    6568        ContextFactory.initGlobal(new ContextFactory() {
     69            /**
     70             * Create new Context instance to be associated with the current thread.
     71             */
     72            @Override
    6673            protected Context makeContext() {
    6774                Context cx = super.makeContext();
     
    6976                cx.setWrapFactory(RhinoWrapFactory.getInstance());
    7077                return cx;
     78            }
     79
     80
     81            /**
     82             * Execute top call to script or function. When the runtime is about to
     83             * execute a script or function that will create the first stack frame
     84             * with scriptable code, it calls this method to perform the real call.
     85             * In this way execution of any script happens inside this function.
     86             */
     87            @Override
     88            protected Object doTopCall(final Callable callable,
     89                               final Context cx, final Scriptable scope,
     90                               final Scriptable thisObj, final Object[] args) {
     91                AccessControlContext accCtxt = null;
     92                Scriptable global = ScriptableObject.getTopLevelScope(scope);
     93                Scriptable globalProto = global.getPrototype();
     94                if (globalProto instanceof RhinoTopLevel) {
     95                    accCtxt = ((RhinoTopLevel)globalProto).getAccessContext();
     96                }
     97
     98                if (accCtxt != null) {
     99                    return AccessController.doPrivileged(new PrivilegedAction<Object>() {
     100                        public Object run() {
     101                            return superDoTopCall(callable, cx, scope, thisObj, args);
     102                        }
     103                    }, accCtxt);
     104                } else {
     105                    return superDoTopCall(callable, cx, scope, thisObj, args);
     106                }
     107            }
     108
     109            private  Object superDoTopCall(Callable callable,
     110                               Context cx, Scriptable scope,
     111                               Scriptable thisObj, Object[] args) {
     112                return super.doTopCall(callable, cx, scope, thisObj, args);
    71113            }
    72114
     
    87129     */
    88130    public RhinoScriptEngine() {
     131
     132        if (System.getSecurityManager() != null) {
     133            accCtxt = AccessController.getContext();
     134        }
    89135
    90136        Context cx = enterContext();
     
    315361    }
    316362
     363    AccessControlContext getAccessContext() {
     364        return accCtxt;
     365    }
     366
    317367    Object[] wrapArguments(Object[] args) {
    318368        if (args == null) {
  • trunk/openjdk/jdk/src/share/classes/com/sun/script/javascript/RhinoTopLevel.java

    r278 r309  
    11/*
    2  * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    4848
    4949    RhinoTopLevel(Context cx, RhinoScriptEngine engine) {
    50         super(cx);
     50        // second boolean parameter to super constructor tells whether
     51        // to seal standard JavaScript objects or not. If security manager
     52        // is present, we seal the standard objects.
     53        super(cx, System.getSecurityManager() != null);
    5154        this.engine = engine;
    5255
     
    165168    }
    166169
     170    AccessControlContext getAccessContext() {
     171        return engine.getAccessContext();
     172    }
     173
    167174    private RhinoScriptEngine engine;
    168175}
  • trunk/openjdk/jdk/src/share/classes/java/awt/AWTEvent.java

    r278 r309  
    11/*
    2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/java/awt/AWTKeyStroke.java

    r278 r309  
    2626
    2727import java.awt.event.KeyEvent;
     28import sun.awt.AppContext;
    2829import java.awt.event.InputEvent;
    2930import java.util.Collections;
     
    6768    static final long serialVersionUID = -6430539691155161871L;
    6869
    69     private static Map cache;
    70     private static AWTKeyStroke cacheKey;
    71     private static Constructor ctor = getCtor(AWTKeyStroke.class);
    7270    private static Map modifierKeywords;
    7371    /**
     
    7775     */
    7876    private static VKCollection vks;
     77
     78    //A key for the collection of AWTKeyStrokes within AppContext.
     79    private static Object APP_CONTEXT_CACHE_KEY = new Object();
     80    //A key withing the cache
     81    private static AWTKeyStroke APP_CONTEXT_KEYSTROKE_KEY = new AWTKeyStroke();
     82
     83    /*
     84     * Reads keystroke class from AppContext and if null, puts there the
     85     * AWTKeyStroke class.
     86     * Must be called under locked AWTKeyStroke.class
     87     */
     88    private static Class getAWTKeyStrokeClass() {
     89        Class clazz = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
     90        if (clazz == null) {
     91            clazz = AWTKeyStroke.class;
     92            AppContext.getAppContext().put(AWTKeyStroke.class, AWTKeyStroke.class);
     93        }
     94        return clazz;
     95    }
    7996
    8097    private char keyChar = KeyEvent.CHAR_UNDEFINED;
     
    165182            throw new IllegalArgumentException("subclass cannot be null");
    166183        }
    167         if (AWTKeyStroke.ctor.getDeclaringClass().equals(subclass)) {
    168             // Already registered
    169             return;
     184        synchronized (AWTKeyStroke.class) {
     185            Class keyStrokeClass = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
     186            if (keyStrokeClass != null && keyStrokeClass.equals(subclass)){
     187                // Already registered
     188                return;
     189            }
    170190        }
    171191        if (!AWTKeyStroke.class.isAssignableFrom(subclass)) {
     
    198218
    199219        synchronized (AWTKeyStroke.class) {
    200             AWTKeyStroke.ctor = ctor;
    201             cache = null;
    202             cacheKey = null;
     220            AppContext.getAppContext().put(AWTKeyStroke.class, subclass);
     221            AppContext.getAppContext().remove(APP_CONTEXT_CACHE_KEY);
     222            AppContext.getAppContext().remove(APP_CONTEXT_KEYSTROKE_KEY);
    203223        }
    204224    }
     
    230250        (char keyChar, int keyCode, int modifiers, boolean onKeyRelease)
    231251    {
     252        Map cache = (Map)AppContext.getAppContext().get(APP_CONTEXT_CACHE_KEY);
     253        AWTKeyStroke cacheKey = (AWTKeyStroke)AppContext.getAppContext().get(APP_CONTEXT_KEYSTROKE_KEY);
     254
    232255        if (cache == null) {
    233256            cache = new HashMap();
     257            AppContext.getAppContext().put(APP_CONTEXT_CACHE_KEY, cache);
    234258        }
    235259
    236260        if (cacheKey == null) {
    237261            try {
    238                 cacheKey = (AWTKeyStroke)ctor.newInstance((Object[]) null);
     262                Class clazz = getAWTKeyStrokeClass();
     263                cacheKey = (AWTKeyStroke)getCtor(clazz).newInstance((Object[]) null);
     264                AppContext.getAppContext().put(APP_CONTEXT_KEYSTROKE_KEY, cacheKey);
    239265            } catch (InstantiationException e) {
    240266                assert(false);
     
    254280            stroke = cacheKey;
    255281            cache.put(stroke, stroke);
    256             cacheKey = null;
    257         }
    258 
     282            AppContext.getAppContext().remove(APP_CONTEXT_KEYSTROKE_KEY);
     283        }
    259284        return stroke;
    260285    }
     
    776801        synchronized (AWTKeyStroke.class) {
    777802            Class newClass = getClass();
    778             if (!newClass.equals(ctor.getDeclaringClass())) {
     803            Class awtKeyStrokeClass = getAWTKeyStrokeClass();
     804            if (!newClass.equals(awtKeyStrokeClass)) {
    779805                registerSubclass(newClass);
    780806            }
  • trunk/openjdk/jdk/src/share/classes/java/awt/Component.java

    r278 r309  
    11/*
    2  * Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/java/awt/EventDispatchThread.java

    r278 r309  
    11/*
    2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/java/awt/EventQueue.java

    r278 r309  
    11/*
    2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/java/awt/MenuComponent.java

    r278 r309  
    11/*
    2  * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/java/awt/TrayIcon.java

    r278 r309  
    11/*
    2  * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/java/io/InputStream.java

    r278 r309  
    11/*
    2  * Copyright (c) 1994, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    4545public abstract class InputStream implements Closeable {
    4646
    47     // SKIP_BUFFER_SIZE is used to determine the size of skipBuffer
    48     private static final int SKIP_BUFFER_SIZE = 2048;
    49     // skipBuffer is initialized in skip(long), if needed.
    50     private static byte[] skipBuffer;
     47    // MAX_SKIP_BUFFER_SIZE is used to determine the maximum buffer skip to
     48    // use when skipping.
     49    private static final int MAX_SKIP_BUFFER_SIZE = 2048;
    5150
    5251    /**
     
    213212        long remaining = n;
    214213        int nr;
    215         if (skipBuffer == null)
    216             skipBuffer = new byte[SKIP_BUFFER_SIZE];
    217 
    218         byte[] localSkipBuffer = skipBuffer;
    219214
    220215        if (n <= 0) {
     
    222217        }
    223218
     219        int size = (int)Math.min(MAX_SKIP_BUFFER_SIZE, remaining);
     220        byte[] skipBuffer = new byte[size];
    224221        while (remaining > 0) {
    225             nr = read(localSkipBuffer, 0,
    226                       (int) Math.min(SKIP_BUFFER_SIZE, remaining));
     222            nr = read(skipBuffer, 0, (int)Math.min(size, remaining));
    227223            if (nr < 0) {
    228224                break;
  • trunk/openjdk/jdk/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java

    r278 r309  
    11/*
    2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java

    r278 r309  
    11/*
    2  * Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/java/net/NetworkInterface.java

    r278 r309  
    531531            result += " (" + displayName + ")";
    532532        }
    533         result += " index: "+index+" addresses:\n";
    534         for (Enumeration e = getInetAddresses(); e.hasMoreElements(); ) {
    535             InetAddress addr = (InetAddress)e.nextElement();
    536             result += addr+";\n";
    537         }
    538533        return result;
    539534    }
     535
    540536    private static native void init();
    541 
    542537}
  • trunk/openjdk/jdk/src/share/classes/java/security/AccessControlContext.java

    r278 r309  
    11/*
    2  * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/java/security/SignedObject.java

    r278 r309  
    11/*
    2  * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    250250     */
    251251    private void readObject(java.io.ObjectInputStream s)
    252          throws java.io.IOException, ClassNotFoundException
    253     {
    254         s.defaultReadObject();
    255         content = content.clone();
    256         signature = signature.clone();
     252        throws java.io.IOException, ClassNotFoundException {
     253            java.io.ObjectInputStream.GetField fields = s.readFields();
     254            content = ((byte[])fields.get("content", null)).clone();
     255            signature = ((byte[])fields.get("signature", null)).clone();
     256            thealgorithm = (String)fields.get("thealgorithm", null);
    257257    }
    258258}
  • trunk/openjdk/jdk/src/share/classes/java/sql/Timestamp.java

    r278 r309  
    489489     */
    490490    public int compareTo(Timestamp ts) {
    491         int i = super.compareTo(ts);
     491        long thisTime = this.getTime();
     492        long anotherTime = ts.getTime();
     493        int i = (thisTime<anotherTime ? -1 :(thisTime==anotherTime?0 :1));
    492494        if (i == 0) {
    493495            if (nanos > ts.nanos) {
  • trunk/openjdk/jdk/src/share/classes/javax/net/ssl/HttpsURLConnection.java

    r278 r309  
    11/*
    2  * Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    369369        }
    370370
     371        SecurityManager sm = System.getSecurityManager();
     372        if (sm != null) {
     373            sm.checkSetFactory();
     374        }
    371375        sslSocketFactory = sf;
    372376    }
  • trunk/openjdk/jdk/src/share/classes/javax/swing/ImageIcon.java

    r278 r309  
    3737import javax.accessibility.*;
    3838
     39import sun.awt.AppContext;
     40import java.lang.reflect.Field;
     41import java.security.*;
    3942
    4043/**
     
    7679    String description = null;
    7780
    78     protected final static Component component = new Component() {};
    79     protected final static MediaTracker tracker = new MediaTracker(component);
     81   // Fields for twisted backward compatibility only. DO NOT USE.
     82    protected final static Component component;
     83    protected final static MediaTracker tracker;
     84
     85    static {
     86        component = AccessController.doPrivileged(new PrivilegedAction<Component>() {
     87            public Component run() {
     88
     89                try {
     90                    final Component component = createNoPermsComponent();
     91
     92                    // 6482575 - clear the appContext field so as not to leak it
     93                    Field appContextField =
     94
     95                            Component.class.getDeclaredField("appContext");
     96                    appContextField.setAccessible(true);
     97                    appContextField.set(component, null);
     98
     99                    return component;
     100                } catch (Throwable e) {
     101                    // We don't care about component.
     102                    // So don't prevent class initialisation.
     103                    e.printStackTrace();
     104
     105                    return null;
     106                }
     107            }
     108        });
     109        tracker = new MediaTracker(component);
     110    }
     111
     112    private static Component createNoPermsComponent() {
     113        // 7020198 - set acc field to no permissions and no subject
     114        // Note, will have appContext set.
     115        return AccessController.doPrivileged(
     116                new PrivilegedAction<Component>() {
     117                    public Component run() {
     118                        return new Component() {
     119                        };
     120                    }
     121                },
     122                new AccessControlContext(new ProtectionDomain[]{
     123                        new ProtectionDomain(null, null)
     124                })
     125        );
     126    }
    80127
    81128    /**
     
    83130     */
    84131    private static int mediaTrackerID;
     132
     133    private final static Object TRACKER_KEY = new StringBuilder("TRACKER_KEY");
    85134
    86135    int width = -1;
     
    244293     */
    245294    protected void loadImage(Image image) {
    246         synchronized(tracker) {
     295        MediaTracker mTracker = getTracker();
     296        synchronized(mTracker) {
    247297            int id = getNextID();
    248298
    249             tracker.addImage(image, id);
     299            mTracker.addImage(image, id);
    250300            try {
    251                 tracker.waitForID(id, 0);
     301                mTracker.waitForID(id, 0);
    252302            } catch (InterruptedException e) {
    253303                System.out.println("INTERRUPTED while loading Image");
    254304            }
    255             loadStatus = tracker.statusID(id, false);
    256             tracker.removeImage(image, id);
     305            loadStatus = mTracker.statusID(id, false);
     306            mTracker.removeImage(image, id);
    257307
    258308            width = image.getWidth(imageObserver);
     
    265315     */
    266316    private int getNextID() {
    267         synchronized(tracker) {
     317        synchronized(getTracker()) {
    268318            return ++mediaTrackerID;
    269319        }
     320    }
     321
     322    /**
     323     * Returns the MediaTracker for the current AppContext, creating a new
     324     * MediaTracker if necessary.
     325     */
     326    private MediaTracker getTracker() {
     327        Object trackerObj;
     328        AppContext ac = AppContext.getAppContext();
     329        // Opt: Only synchronize if trackerObj comes back null?
     330        // If null, synchronize, re-check for null, and put new tracker
     331        synchronized (ac) {
     332            trackerObj = ac.get(TRACKER_KEY);
     333            if (trackerObj == null) {
     334                Component comp = new Component() {
     335                };
     336                trackerObj = new MediaTracker(comp);
     337                ac.put(TRACKER_KEY, trackerObj);
     338            }
     339        }
     340        return (MediaTracker) trackerObj;
    270341    }
    271342
  • trunk/openjdk/jdk/src/share/classes/javax/swing/Timer.java

    r278 r309  
    11/*
    2  * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/javax/swing/TransferHandler.java

    r278 r309  
    11/*
    2  * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/sun/awt/SunToolkit.java

    r278 r309  
    7171    /* Load debug settings for native code */
    7272    static {
    73         String nativeDebug = System.getProperty("sun.awt.nativedebug");
    74         if ("true".equalsIgnoreCase(nativeDebug)) {
     73        if (AccessController.doPrivileged(new GetBooleanAction("sun.awt.nativedebug"))) {
    7574            DebugSettings.init();
    7675        }
  • trunk/openjdk/jdk/src/share/classes/sun/font/FileFont.java

    r278 r309  
    11/*
    2  * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/sun/font/TrueTypeFont.java

    r278 r309  
    11/*
    2  * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/sun/font/Type1Font.java

    r278 r309  
    11/*
    2  * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/sun/java2d/pipe/DrawImage.java

    r278 r309  
    510510         */
    511511        int edges[] = new int[(dy2-dy1)*2+2];
     512        // It is important that edges[0]=edges[1]=0 when we call
     513        // Transform in case it must return early and we would
     514        // not want to render anything on an error condition.
    512515        helper.Transform(tmpmaskblit, srcData, tmpData,
    513516                         AlphaComposite.Src, null,
  • trunk/openjdk/jdk/src/share/classes/sun/misc/FloatingDecimal.java

    r278 r309  
    11/*
    2  * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/sun/misc/SharedSecrets.java

    r278 r309  
    11/*
    2  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/sun/net/ResourceManager.java

    r278 r309  
    4242    /* default maximum number of udp sockets per VM
    4343     * when a security manager is enabled.
    44      * The default is 1024 which is high enough to be useful
     44     * The default is 25 which is high enough to be useful
    4545     * but low enough to be well below the maximum number
    46      * of port numbers actually available on all OSes for
    47      * such sockets (5000 on some versions of windows)
     46     * of port numbers actually available on all OSes
     47     * when multiplied by the maximum feasible number of VM processes
     48     * that could practically be spawned.
    4849     */
    4950
    50     private static final int DEFAULT_MAX_SOCKETS = 1024;
     51    private static final int DEFAULT_MAX_SOCKETS = 25;
    5152    private static final int maxSockets;
    5253    private static final AtomicInteger numSockets;
  • trunk/openjdk/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java

    r278 r309  
    11/*
    2  * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/sun/nio/ch/Net.java

    r278 r309  
    11/*
    2  * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java

    r278 r309  
    11/*
    2  * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    4141 */
    4242class AnnotationInvocationHandler implements InvocationHandler, Serializable {
     43    private static final long serialVersionUID = 6182022883658399397L;
    4344    private final Class type;
    4445    private final Map<String, Object> memberValues;
  • trunk/openjdk/jdk/src/share/classes/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java

    r278 r309  
    11/*
    2  * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    3535 */
    3636class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy {
     37    private static final long serialVersionUID = 7844069490309503934L;
    3738    private Method member;
    3839    private String foundType;
  • trunk/openjdk/jdk/src/share/classes/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java

    r278 r309  
    11/*
    2  * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    3434 */
    3535public class EnumConstantNotPresentExceptionProxy extends ExceptionProxy {
     36    private static final long serialVersionUID = -604662101303187330L;
    3637    Class<? extends Enum> enumType;
    3738    String constName;
  • trunk/openjdk/jdk/src/share/classes/sun/reflect/annotation/TypeNotPresentExceptionProxy.java

    r278 r309  
    11/*
    2  * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    3434 */
    3535public class TypeNotPresentExceptionProxy extends ExceptionProxy {
     36    private static final long serialVersionUID = 5565925172427947573L;
    3637    String typeName;
    3738    Throwable cause;
  • trunk/openjdk/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java

    r278 r309  
    11/*
    2  * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    3939import java.rmi.server.RMIClientSocketFactory;
    4040import java.rmi.server.RMIServerSocketFactory;
     41import java.security.AccessControlContext;
     42import java.security.AccessController;
     43import java.security.CodeSource;
     44import java.security.Policy;
    4145import java.security.PrivilegedActionException;
     46import java.security.PrivilegedExceptionAction;
     47import java.security.PermissionCollection;
     48import java.security.Permissions;
     49import java.security.ProtectionDomain;
    4250import java.text.MessageFormat;
     51import sun.rmi.server.LoaderHandler;
    4352import sun.rmi.server.UnicastServerRef;
    4453import sun.rmi.server.UnicastServerRef2;
     
    4655import sun.rmi.transport.ObjectTable;
    4756import sun.rmi.transport.Target;
     57import sun.security.action.GetPropertyAction;
    4858
    4959/**
     
    325335            ClassLoader cl = new URLClassLoader(urls);
    326336
     337            String codebaseProperty = null;
     338            String prop = java.security.AccessController.doPrivileged(
     339                new GetPropertyAction("java.rmi.server.codebase"));
     340                if (prop != null && prop.trim().length() > 0) {
     341                    codebaseProperty = prop;
     342                }
     343            URL[] codebaseURLs = null;
     344            if (codebaseProperty != null) {
     345                codebaseURLs = sun.misc.URLClassPath.pathToURLs(codebaseProperty);
     346            } else {
     347                codebaseURLs = new URL[0];
     348            }
     349
    327350            /*
    328351             * Fix bugid 4242317: Classes defined by this class loader should
     
    334357            Thread.currentThread().setContextClassLoader(cl);
    335358
    336             int regPort = Registry.REGISTRY_PORT;
    337             if (args.length >= 1) {
    338                 regPort = Integer.parseInt(args[0]);
    339             }
    340             registry = new RegistryImpl(regPort);
     359            final int regPort = (args.length >= 1) ? Integer.parseInt(args[0])
     360                                                   : Registry.REGISTRY_PORT;
     361            try {
     362                registry = AccessController.doPrivileged(
     363                    new PrivilegedExceptionAction<RegistryImpl>() {
     364                        public RegistryImpl run() throws RemoteException {
     365                            return new RegistryImpl(regPort);
     366                        }
     367                    }, getAccessControlContext(codebaseURLs));
     368            } catch (PrivilegedActionException ex) {
     369                throw (RemoteException) ex.getException();
     370            }
     371
    341372            // prevent registry from exiting
    342373            while (true) {
     
    358389        System.exit(1);
    359390    }
     391
     392    /**
     393     * Generates an AccessControlContext from several URLs.
     394     * The approach used here is taken from the similar method
     395     * getAccessControlContext() in the sun.applet.AppletPanel class.
     396     */
     397    private static AccessControlContext getAccessControlContext(URL[] urls) {
     398        // begin with permissions granted to all code in current policy
     399        PermissionCollection perms = AccessController.doPrivileged(
     400            new java.security.PrivilegedAction<PermissionCollection>() {
     401                public PermissionCollection run() {
     402                    CodeSource codesource = new CodeSource(null,
     403                        (java.security.cert.Certificate[]) null);
     404                    Policy p = java.security.Policy.getPolicy();
     405                    if (p != null) {
     406                        return p.getPermissions(codesource);
     407                    } else {
     408                        return new Permissions();
     409                    }
     410                }
     411            });
     412
     413        /*
     414         * Anyone can connect to the registry and the registry can connect
     415         * to and possibly download stubs from anywhere. Downloaded stubs and
     416         * related classes themselves are more tightly limited by RMI.
     417         */
     418        perms.add(new SocketPermission("*", "connect,accept"));
     419
     420        perms.add(new RuntimePermission("accessClassInPackage.sun.*"));
     421
     422        // add permissions required to load from codebase URL path
     423        LoaderHandler.addPermissionsForURLs(urls, perms, false);
     424
     425        /*
     426         * Create an AccessControlContext that consists of a single
     427         * protection domain with only the permissions calculated above.
     428         */
     429        ProtectionDomain pd = new ProtectionDomain(
     430            new CodeSource((urls.length > 0 ? urls[0] : null),
     431                (java.security.cert.Certificate[]) null),
     432            perms);
     433        return new AccessControlContext(new ProtectionDomain[] { pd });
     434    }
    360435}
  • trunk/openjdk/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java

    r278 r309  
    11/*
    2  * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    10291029     * it is not already implied by the collection.
    10301030     */
    1031     private static void addPermissionsForURLs(URL[] urls,
     1031    public static void addPermissionsForURLs(URL[] urls,
    10321032                                              PermissionCollection perms,
    10331033                                              boolean forLoader)
  • trunk/openjdk/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java

    r278 r309  
    11/*
    2  * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    391391            try {
    392392                in = call.getInputStream();
     393                try {
     394                    Class<?> clazz = Class.forName("sun.rmi.transport.DGCImpl_Skel");
     395                    if (clazz.isAssignableFrom(skel.getClass())) {
     396                        ((MarshalInputStream)in).useCodebaseOnly();
     397                    }
     398                } catch (ClassNotFoundException ignore) { }
    393399                hash = in.readLong();
    394400            } catch (Exception readEx) {
  • trunk/openjdk/jdk/src/share/classes/sun/security/jgss/spi/GSSContextSpi.java

    r278 r309  
    2525
    2626/*
    27  * ===========================================================================
    28  *  IBM Confidential
    29  *  OCO Source Materials
    30  *  Licensed Materials - Property of IBM
    3127 *
    3228 *  (C) Copyright IBM Corp. 1999 All Rights Reserved.
    33  *
    34  *  The source code for this program is not published or otherwise divested of
    35  *  its trade secrets, irrespective of what has been deposited with the U.S.
    36  *  Copyright Office.
    37  *
    3829 *  Copyright 1997 The Open Group Research Institute.  All rights reserved.
    39  * ===========================================================================
    40  *
    4130 */
    42 
    4331package sun.security.jgss.spi;
    4432
  • trunk/openjdk/jdk/src/share/classes/sun/security/jgss/spnego/NegTokenInit.java

    r278 r309  
    11/*
    2  * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    6767    private Oid[] mechTypeList = null;
    6868
    69     private byte[] reqFlags = null;
     69    private BitArray reqFlags = null;
    7070    private byte[] mechToken = null;
    7171    private byte[] mechListMIC = null;
    7272
    73     NegTokenInit(byte[] mechTypes, byte[] flags,
     73    NegTokenInit(byte[] mechTypes, BitArray flags,
    7474                byte[] token, byte[] mechListMIC)
    7575    {
     
    102102            if (reqFlags != null) {
    103103                DerOutputStream flags = new DerOutputStream();
    104                 flags.putBitString(reqFlags);
     104                flags.putUnalignedBitString(reqFlags);
    105105                initToken.write(DerValue.createTag(DerValue.TAG_CONTEXT,
    106106                                                true, (byte) 0x01), flags);
     
    238238    }
    239239
    240     byte[] getReqFlags() {
     240    BitArray getReqFlags() {
    241241        return reqFlags;
    242242    }
  • trunk/openjdk/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java

    r278 r309  
    11/*
    2  * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    5454    private int state = STATE_NEW;
    5555
    56     private static final int CHECKSUM_DELEG_FLAG    = 1;
    57     private static final int CHECKSUM_MUTUAL_FLAG   = 2;
    58     private static final int CHECKSUM_REPLAY_FLAG   = 4;
    59     private static final int CHECKSUM_SEQUENCE_FLAG = 8;
    60     private static final int CHECKSUM_CONF_FLAG     = 16;
    61     private static final int CHECKSUM_INTEG_FLAG    = 32;
    62 
    6356    /*
    6457     * Optional features that the application can set and their default
     
    701694     * get the context flags
    702695     */
    703     private byte[] getContextFlags() {
    704         int flags = 0;
    705 
    706         if (getCredDelegState())
    707             flags |= CHECKSUM_DELEG_FLAG;
    708         if (getMutualAuthState())
    709             flags |= CHECKSUM_MUTUAL_FLAG;
    710         if (getReplayDetState())
    711             flags |= CHECKSUM_REPLAY_FLAG;
    712         if (getSequenceDetState())
    713             flags |= CHECKSUM_SEQUENCE_FLAG;
    714         if (getIntegState())
    715             flags |= CHECKSUM_INTEG_FLAG;
    716         if (getConfState())
    717             flags |= CHECKSUM_CONF_FLAG;
    718 
    719         byte[] temp = new byte[1];
    720         temp[0] = (byte)(flags & 0xff);
    721         return temp;
     696    private BitArray getContextFlags() {
     697        BitArray out = new BitArray(7);
     698
     699        if (getCredDelegState()) out.set(0, true);
     700        if (getMutualAuthState()) out.set(1, true);
     701        if (getReplayDetState()) out.set(2, true);
     702        if (getSequenceDetState()) out.set(3, true);
     703        if (getConfState()) out.set(5, true);
     704        if (getIntegState()) out.set(6, true);
     705
     706        return out;
    722707    }
    723708
  • trunk/openjdk/jdk/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java

    r278 r309  
    248248    }
    249249
    250     Ticket readData() throws IOException, RealmException, KrbApErrException, Asn1Exception {
     250    byte[] readData() throws IOException {
    251251        int length;
    252252        length = read(4);
    253         if (length > 0) {
     253        if (length == 0) {
     254            return null;
     255        } else {
    254256            byte[] bytes = new byte[length];
    255257            read(bytes, 0, length);
    256             Ticket ticket = new Ticket(bytes);
    257             return ticket;
    258         }
    259         else return null;
     258            return bytes;
     259        }
    260260    }
    261261
     
    326326        return flags;
    327327    }
     328
     329    /**
     330     * Reads the next cred in stream.
     331     * @return the next cred, null if ticket or second_ticket unparseable.
     332     *
     333     * Note: MIT krb5 1.8.1 might generate a config entry with server principal
     334     * X-CACHECONF:/krb5_ccache_conf_data/fast_avail/krbtgt/REALM@REALM. The
     335     * entry is used by KDC to inform the client that it support certain
     336     * features. Its ticket is not a valid krb5 ticket and thus this method
     337     * returns null.
     338     */
    328339    Credentials readCred(int version) throws IOException,RealmException, KrbApErrException, Asn1Exception {
    329340        PrincipalName cpname = readPrincipal(version);
     
    361372            auData = new AuthorizationData(auDataEntry);
    362373        }
    363         Ticket ticket = readData();
    364         if (DEBUG) {
    365             System.out.println(">>>DEBUG <CCacheInputStream>");
    366             if (ticket == null) {
    367                 System.out.println("///ticket is null");
    368             }
    369         }
    370         Ticket secTicket = readData();
    371         Credentials cred = new Credentials(cpname, spname, key, authtime, starttime,
    372                                            endtime, renewTill, skey, tFlags,
    373                                            addrs, auData, ticket, secTicket);
    374         return cred;
     374        byte[] ticketData = readData();
     375        byte[] ticketData2 = readData();
     376
     377        try {
     378            return new Credentials(cpname, spname, key, authtime, starttime,
     379                endtime, renewTill, skey, tFlags,
     380                addrs, auData,
     381                ticketData != null ? new Ticket(ticketData) : null,
     382                ticketData2 != null ? new Ticket(ticketData2) : null);
     383        } catch (Exception e) {     // If any of new Ticket(*) fails.
     384            return null;
     385        }
    375386    }
    376387}
  • trunk/openjdk/jdk/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java

    r278 r309  
    11/*
    2  * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    187187        credentialsList = new Vector<Credentials> ();
    188188        while (cis.available() > 0) {
    189             credentialsList.addElement(cis.readCred(version));
     189            Credentials cred = cis.readCred(version);
     190            if (cred != null) {
     191                credentialsList.addElement(cred);
     192            }
    190193        }
    191194        cis.close();
  • trunk/openjdk/jdk/src/share/classes/sun/security/provider/SeedGenerator.java

    r278 r309  
    11/*
    2  * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    136136    }
    137137
    138     void getSeedBytes(byte[] result) {
    139         for (int i = 0; i < result.length; i++) {
    140           result[i] = getSeedByte();
    141         }
    142     }
    143 
    144     abstract byte getSeedByte();
     138    abstract void getSeedBytes(byte[] result);
    145139
    146140    /**
     
    337331            }
    338332        }
     333
     334        @Override
     335        void getSeedBytes(byte[] result) {
     336            for (int i = 0; i < result.length; i++) {
     337                result[i] = getSeedByte();
     338            }
     339        }
    339340
    340341        byte getSeedByte() {
     
    424425
    425426        private String deviceName;
    426         private BufferedInputStream devRandom;
    427 
     427        private InputStream devRandom;
    428428
    429429        /**
     
    447447        private void init() throws IOException {
    448448            final URL device = new URL(deviceName);
    449             devRandom = java.security.AccessController.doPrivileged
    450                 (new java.security.PrivilegedAction<BufferedInputStream>() {
    451                         public BufferedInputStream run() {
    452                             try {
    453                                 return new BufferedInputStream(device.openStream());
    454                             } catch (IOException ioe) {
    455                                 return null;
     449            try {
     450                devRandom = java.security.AccessController.doPrivileged
     451                    (new java.security.PrivilegedExceptionAction<InputStream>() {
     452                        public InputStream run() throws IOException {
     453                            /*
     454                             * return a FileInputStream for file URLs and
     455                             * avoid buffering. The openStream() call wraps
     456                             * InputStream in a BufferedInputStream which
     457                             * can buffer up to 8K bytes. This read is a
     458                             * performance issue for entropy sources which
     459                             * can be slow to replenish.
     460                             */
     461                            if (device.getProtocol().equalsIgnoreCase("file")) {
     462                                File deviceFile = getDeviceFile(device);
     463                                return new FileInputStream(deviceFile);
     464                            } else {
     465                                return device.openStream();
    456466                            }
    457467                        }
    458468                    });
    459 
    460             if (devRandom == null) {
    461                 throw new IOException("failed to open " + device);
    462             }
    463         }
    464 
    465         byte getSeedByte() {
    466             byte b[] = new byte[1];
    467             int stat;
    468             try {
    469                 stat = devRandom.read(b, 0, b.length);
     469            } catch (Exception e) {
     470                throw new IOException("Failed to open " + deviceName, e.getCause());
     471            }
     472        }
     473
     474        /*
     475         * Use a URI to access this File. Previous code used a URL
     476         * which is less strict on syntax. If we encounter a
     477         * URISyntaxException we make best efforts for backwards
     478         * compatibility. e.g. space character in deviceName string.
     479         *
     480         * Method called within PrivilegedExceptionAction block.
     481         */
     482        private File getDeviceFile(URL device) throws IOException {
     483            try {
     484                URI deviceURI = device.toURI();
     485                if(deviceURI.isOpaque()) {
     486                    // File constructor does not accept opaque URI
     487                    URI localDir = new File(System.getProperty("user.dir")).toURI();
     488                    String uriPath = localDir.toString() +
     489                                         deviceURI.toString().substring(5);
     490                    return new File(URI.create(uriPath));
     491                } else {
     492                    return new File(deviceURI);
     493                }
     494            } catch (URISyntaxException use) {
     495                /*
     496                 * Make best effort to access this File.
     497                 * We can try using the URL path.
     498                 */
     499                return new File(device.getPath());
     500            }
     501        }
     502
     503        @Override
     504        void getSeedBytes(byte[] result) {
     505            int len = result.length;
     506            int read = 0;
     507            try {
     508                while (read < len) {
     509                    int count = devRandom.read(result, read, len - read);
     510                    // /dev/random blocks - should never have EOF
     511                    if (count < 0)
     512                        throw new InternalError("URLSeedGenerator " + deviceName +
     513                                        " reached end of file");
     514                    read += count;
     515                }
    470516            } catch (IOException ioe) {
    471517                throw new InternalError("URLSeedGenerator " + deviceName +
     
    473519                                        ioe.getMessage());
    474520            }
    475             if (stat == b.length) {
    476                 return b[0];
    477             } else if (stat == -1) {
    478                 throw new InternalError("URLSeedGenerator " + deviceName +
    479                                            " reached end of file");
    480             } else {
    481                 throw new InternalError("URLSeedGenerator " + deviceName +
    482                                            " failed read");
    483             }
    484         }
    485 
     521        }
    486522    }
    487523
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java

    r278 r309  
    11/*
    2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 20111 Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    6161        // check if the Socket is invalid (error or closed)
    6262        c.checkWrite();
    63         //
    64         // Always flush at the end of each application level record.
    65         // This lets application synchronize read and write streams
    66         // however they like; if we buffered here, they couldn't.
    67         //
    68         // NOTE: *must* call c.writeRecord() even for len == 0
     63
     64        /*
     65         * By default, we counter chosen plaintext issues on CBC mode
     66         * ciphersuites in SSLv3/TLS1.0 by sending one byte of application
     67         * data in the first record of every payload, and the rest in
     68         * subsequent record(s). Note that the issues have been solved in
     69         * TLS 1.1 or later.
     70         *
     71         * It is not necessary to split the very first application record of
     72         * a freshly negotiated TLS session, as there is no previous
     73         * application data to guess.  To improve compatibility, we will not
     74         * split such records.
     75         *
     76         * This avoids issues in the outbound direction.  For a full fix,
     77         * the peer must have similar protections.
     78         */
     79        boolean isFirstRecordOfThePayload = true;
     80
     81        /*
     82         * Always flush at the end of each application level record.
     83         * This lets application synchronize read and write streams
     84         * however they like; if we buffered here, they couldn't.
     85         *
     86         * NOTE: *must* call c.writeRecord() even for len == 0
     87         */
     88
    6989        try {
    7090            do {
    71                 int howmuch = Math.min(len, r.availableDataBytes());
     91                int howmuch;
     92                if (isFirstRecordOfThePayload && c.needToSplitPayload()) {
     93                    howmuch = Math.min(0x01, r.availableDataBytes());
     94                } else {
     95                    howmuch = Math.min(len, r.availableDataBytes());
     96                }
     97
     98                if (isFirstRecordOfThePayload && howmuch != 0) {
     99                    isFirstRecordOfThePayload = false;
     100                }
    72101
    73102                if (howmuch > 0) {
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/CipherBox.java

    r278 r309  
    11/*
    2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    7777
    7878    /**
     79     * Is the cipher of CBC mode?
     80     */
     81     private final boolean isCBCMode;
     82
     83    /**
    7984     * NULL cipherbox. Identity operation, no encryption.
    8085     */
     
    8287        this.protocolVersion = ProtocolVersion.DEFAULT;
    8388        this.cipher = null;
     89        this.isCBCMode = false;
    8490    }
    8591
     
    97103            this.cipher = JsseJce.getCipher(bulkCipher.transformation);
    98104            int mode = encrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE;
     105            this.isCBCMode = bulkCipher.isCBCMode;
    99106            cipher.init(mode, key, iv);
    100107            // do not call getBlockSize until after init()
     
    487494        return newlen;
    488495    }
     496
     497    /*
     498     * Does the cipher use CBC mode?
     499     *
     500     * @return true if the cipher use CBC mode, false otherwise.
     501     */
     502    boolean isCBCMode() {
     503        return isCBCMode;
     504    }
    489505}
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/CipherSuite.java

    r278 r309  
    11/*
    2  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    341341        final boolean exportable;
    342342
     343        // Is the cipher algorithm of Cipher Block Chaining (CBC) mode?
     344        final boolean isCBCMode;
     345
    343346        BulkCipher(String transformation, int keySize,
    344347                int expandedKeySize, int ivSize, boolean allowed) {
    345348            this.transformation = transformation;
    346             this.algorithm = transformation.split("/")[0];
     349            String[] splits = transformation.split("/");
     350            this.algorithm = splits[0];
     351            this.isCBCMode =
     352                splits.length <= 1 ? false : "CBC".equalsIgnoreCase(splits[1]);
    347353            this.description = this.algorithm + "/" + (keySize << 3);
    348354            this.keySize = keySize;
     
    357363                int ivSize, boolean allowed) {
    358364            this.transformation = transformation;
    359             this.algorithm = transformation.split("/")[0];
     365            String[] splits = transformation.split("/");
     366            this.algorithm = splits[0];
     367            this.isCBCMode =
     368                splits.length <= 1 ? false : "CBC".equalsIgnoreCase(splits[1]);
    360369            this.description = this.algorithm + "/" + (keySize << 3);
    361370            this.keySize = keySize;
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java

    r278 r309  
    11/*
    2  * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    4747final class EngineOutputRecord extends OutputRecord {
    4848
     49    private SSLEngineImpl engine;
    4950    private EngineWriter writer;
    5051
     
    6364    EngineOutputRecord(byte type, SSLEngineImpl engine) {
    6465        super(type, recordSize(type));
     66        this.engine = engine;
    6567        writer = engine.writer;
    6668    }
     
    228230         * records, so this increases robustness.
    229231         */
    230         int length = Math.min(ea.getAppRemaining(), maxDataSize);
    231         if (length == 0) {
     232        if (ea.getAppRemaining() == 0) {
    232233            return;
    233234        }
    234235
     236        /*
     237         * By default, we counter chosen plaintext issues on CBC mode
     238         * ciphersuites in SSLv3/TLS1.0 by sending one byte of application
     239         * data in the first record of every payload, and the rest in
     240         * subsequent record(s). Note that the issues have been solved in
     241         * TLS 1.1 or later.
     242         *
     243         * It is not necessary to split the very first application record of
     244         * a freshly negotiated TLS session, as there is no previous
     245         * application data to guess.  To improve compatibility, we will not
     246         * split such records.
     247         *
     248         * Because of the compatibility, we'd better produce no more than
     249         * SSLSession.getPacketBufferSize() net data for each wrap. As we
     250         * need a one-byte record at first, the 2nd record size should be
     251         * equal to or less than Record.maxDataSizeMinusOneByteRecord.
     252         *
     253         * This avoids issues in the outbound direction.  For a full fix,
     254         * the peer must have similar protections.
     255         */
     256        int length;
     257        if (engine.needToSplitPayload(writeCipher, protocolVersion)) {
     258            write(ea, writeMAC, writeCipher, 0x01);
     259            ea.resetLim();      // reset application data buffer limit
     260            length = Math.min(ea.getAppRemaining(),
     261                        maxDataSizeMinusOneByteRecord);
     262        } else {
     263            length = Math.min(ea.getAppRemaining(), maxDataSize);
     264        }
     265
     266        // Don't bother to really write empty records.
     267        if (length > 0) {
     268            write(ea, writeMAC, writeCipher, length);
     269        }
     270
     271        return;
     272    }
     273
     274    void write(EngineArgs ea, MAC writeMAC, CipherBox writeCipher,
     275            int length) throws IOException {
    235276        /*
    236277         * Copy out existing buffer values.
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/Record.java

    r278 r309  
    11/*
    2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    6666                                    + trailerSize;      // MAC
    6767
     68    static final boolean enableCBCProtection =
     69            Debug.getBooleanProperty("jsse.enableCBCProtection", true);
     70
     71    /*
     72     * For CBC protection in SSL3/TLS1, we break some plaintext into two
     73     * packets.  Max application data size for the second packet.
     74     */
     75    static final int    maxDataSizeMinusOneByteRecord =
     76                                  maxDataSize       // max data size
     77                                - (                 // max one byte record size
     78                                      headerSize    // header
     79                                    + 1             // one byte data
     80                                    + maxPadding    // padding
     81                                    + trailerSize   // MAC
     82                                  );
     83
    6884    /*
    6985     * The maximum large record size.
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/SSLEngineImpl.java

    r278 r309  
    11/*
    2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    307307
    308308    /*
     309     * Is it the first application record to write?
     310     */
     311    private boolean isFirstAppOutputRecord = true;
     312
     313    /*
    309314     * Class and subclass dynamic debugging support
    310315     */
     
    596601                                ("Algorithm missing:  ").initCause(e);
    597602        }
     603
     604        // reset the flag of the first application record
     605        isFirstAppOutputRecord = true;
    598606    }
    599607
     
    12131221
    12141222        // eventually compress as well.
    1215         return writer.writeRecord(eor, ea, writeMAC, writeCipher);
     1223        HandshakeStatus hsStatus =
     1224                writer.writeRecord(eor, ea, writeMAC, writeCipher);
     1225
     1226        /*
     1227         * turn off the flag of the first application record if we really
     1228         * consumed at least byte.
     1229         */
     1230        if (isFirstAppOutputRecord && ea.deltaApp() > 0) {
     1231            isFirstAppOutputRecord = false;
     1232        }
     1233
     1234        return hsStatus;
     1235    }
     1236
     1237    /*
     1238     * Need to split the payload except the following cases:
     1239     *
     1240     * 1. protocol version is TLS 1.1 or later;
     1241     * 2. bulk cipher does not use CBC mode, including null bulk cipher suites.
     1242     * 3. the payload is the first application record of a freshly
     1243     *    negotiated TLS session.
     1244     * 4. the CBC protection is disabled;
     1245     *
     1246     * More details, please refer to
     1247     * EngineOutputRecord.write(EngineArgs, MAC, CipherBox).
     1248     */
     1249    boolean needToSplitPayload(CipherBox cipher, ProtocolVersion protocol) {
     1250        return (protocol.v <= ProtocolVersion.TLS10.v) &&
     1251                cipher.isCBCMode() && !isFirstAppOutputRecord &&
     1252                Record.enableCBCProtection;
    12161253    }
    12171254
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java

    r278 r309  
    11/*
    2  * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    359359    private static final Debug debug = Debug.getInstance("ssl");
    360360
     361    /*
     362     * Is it the first application record to write?
     363     */
     364    private boolean isFirstAppOutputRecord = true;
     365
    361366    //
    362367    // CONSTRUCTORS AND INITIALIZATION CODE
     
    762767        r.encrypt(writeCipher);
    763768        r.write(sockOutput);
    764     }
    765 
     769
     770        // turn off the flag of the first application record
     771        if (isFirstAppOutputRecord &&
     772                r.contentType() == Record.ct_application_data) {
     773            isFirstAppOutputRecord = false;
     774        }
     775    }
     776 
     777    /*
     778     * Need to split the payload except the following cases:
     779     *
     780     * 1. protocol version is TLS 1.1 or later;
     781     * 2. bulk cipher does not use CBC mode, including null bulk cipher suites.
     782     * 3. the payload is the first application record of a freshly
     783     *    negotiated TLS session.
     784     * 4. the CBC protection is disabled;
     785     *
     786     * More details, please refer to AppOutputStream.write(byte[], int, int).
     787     */
     788    boolean needToSplitPayload() {
     789        writeLock.lock();
     790        try {
     791            return (protocolVersion.v <= ProtocolVersion.TLS10.v) &&
     792                    writeCipher.isCBCMode() && !isFirstAppOutputRecord &&
     793                    Record.enableCBCProtection;
     794        } finally {
     795            writeLock.unlock();
     796        }
     797    }
    766798
    767799    /*
     
    18301862                                ("Algorithm missing:  ").initCause(e);
    18311863        }
     1864
     1865        // reset the flag of the first application record
     1866        isFirstAppOutputRecord = true;
    18321867    }
    18331868
  • trunk/openjdk/jdk/src/share/classes/sun/security/validator/EndEntityChecker.java

    r278 r309  
    11/*
    2  * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java

    r278 r309  
    11/*
    2  * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2525package sun.swing.table;
    2626
     27import sun.swing.DefaultLookup;
     28
    2729import java.awt.Component;
    2830import java.awt.Color;
     
    3234import java.awt.Point;
    3335import java.awt.Rectangle;
     36import java.io.Serializable;
    3437import javax.swing.*;
    3538import javax.swing.plaf.UIResource;
    3639import javax.swing.border.Border;
    3740import javax.swing.table.*;
    38 import sun.swing.DefaultLookup;
    39 
    4041
    4142public class DefaultTableCellHeaderRenderer extends DefaultTableCellRenderer
     
    187188    }
    188189
    189     private class EmptyIcon implements Icon {
     190    private class EmptyIcon implements Icon, Serializable {
    190191        int width = 0;
    191192        int height = 0;
Note: See TracChangeset for help on using the changeset viewer.