6945178: SecurityException upon drag-and-drop

A flag added to distinguish drop action handling.

Reviewed-by: uta, art
diff --git a/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java b/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java
index db92e68..19c2206 100644
--- a/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java
+++ b/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java
@@ -94,6 +94,11 @@
     protected int                     dropStatus   = STATUS_NONE;
     protected boolean                 dropComplete = false;
 
+    // The flag is used to monitor whether the drop action is
+    // handled by a user. That allows to distinct during
+    // which operation getTransferData() method is invoked.
+    boolean                           dropInProcess = false;
+
     /*
      * global lock
      */
@@ -220,7 +225,7 @@
 
         SecurityManager sm = System.getSecurityManager();
         try {
-            if (!dropComplete && sm != null) {
+            if (!dropInProcess && sm != null) {
                 sm.checkSystemClipboardAccess();
             }
         } catch (Exception e) {
@@ -526,6 +531,8 @@
                     setCurrentJVMLocalSourceTransferable(null);
             }
 
+            dropInProcess = true;
+
             try {
                 ((DropTargetListener)dt).drop(new DropTargetDropEvent(dtc,
                                                                       hots,
@@ -538,6 +545,7 @@
                 } else if (dropComplete == false) {
                     dropComplete(false);
                 }
+                dropInProcess = false;
             }
         } else {
             rejectDrop();