Ejemplo n.º 1
0
        /// <exception cref="System.IO.IOException"/>
        private bool CheckStorageInfoOrSendError(JNStorage storage, HttpServletRequest request
                                                 , HttpServletResponse response)
        {
            int    myNsId                 = storage.GetNamespaceID();
            string myClusterId            = storage.GetClusterID();
            string theirStorageInfoString = StringEscapeUtils.EscapeHtml(request.GetParameter
                                                                             (StorageinfoParam));

            if (theirStorageInfoString != null)
            {
                int theirNsId = StorageInfo.GetNsIdFromColonSeparatedString(theirStorageInfoString
                                                                            );
                string theirClusterId = StorageInfo.GetClusterIdFromColonSeparatedString(theirStorageInfoString
                                                                                         );
                if (myNsId != theirNsId || !myClusterId.Equals(theirClusterId))
                {
                    string msg = "This node has namespaceId '" + myNsId + " and clusterId '" + myClusterId
                                 + "' but the requesting node expected '" + theirNsId + "' and '" + theirClusterId
                                 + "'";
                    response.SendError(HttpServletResponse.ScForbidden, msg);
                    Log.Warn("Received an invalid request file transfer request from " + request.GetRemoteAddr
                                 () + ": " + msg);
                    return(false);
                }
            }
            return(true);
        }