Java安全管理器(奇怪的行为)

时间:2018-10-28 19:56:49

标签: java security properties file-permissions java-security-manager

我正在一个简单的Java应用程序中测试<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="col-md-4" class="form-control" id="Type"> <select> <option value=""></option> <option value="Deal">Deal</option> <option value="Price">Price</option> <option value="Promo">Promo</option> <option value="Listing">Listing</option> <option value="LTD">Long term Deal</option> </select> </div> <div class="col-md-4" class="form-control" id="Category"> <select> <option class=""></option> <option class="Deal">Exceptional / Clearance</option> <option class="Promo">Invoice</option> <option class="Promo">Retro</option> <option class="Listing">New</option> <option class="Listing">Delisting</option> <option class="Price">Increase</option> <option class="Price">Decrease</option> <option class="LTD">Off Invoice (ZXPN Only)</option> <option class="LTD">Retro (No ZR88)</option> </select> </div>

我写属性// Cart Items $num_cart_items = isset($_POST['num_cart_items']) ? $_POST['num_cart_items'] : ''; $i = 1; $cart_items = array(); while(isset($_POST['item_number' . $i])) { $item_number = isset($_POST['item_number' . $i]) ? $_POST['item_number' . $i] : ''; $item_name = isset($_POST['item_name' . $i]) ? $_POST['item_name' . $i] : ''; $quantity = isset($_POST['quantity' . $i]) ? $_POST['quantity' . $i] : ''; $mc_gross = isset($_POST['mc_gross_' . $i]) ? $_POST['mc_gross_' . $i] : 0; $mc_handling = isset($_POST['mc_handling' . $i]) ? $_POST['mc_handling' . $i] : 0; $mc_shipping = isset($_POST['mc_shipping' . $i]) ? $_POST['mc_shipping' . $i] : 0; $custom = isset($_POST['custom' . $i]) ? $_POST['custom' . $i] : ''; $option_name1 = isset($_POST['option_name1_' . $i]) ? $_POST['option_name1_' . $i] : ''; $option_selection1 = isset($_POST['option_selection1_' . $i]) ? $_POST['option_selection1_' . $i] : ''; $option_name2 = isset($_POST['option_name2_' . $i]) ? $_POST['option_name2_' . $i] : ''; $option_selection2 = isset($_POST['option_selection2_' . $i]) ? $_POST['option_selection2_' . $i] : ''; $option_name3 = isset($_POST['option_name3_' . $i]) ? $_POST['option_name3_' . $i] : ''; $option_selection3 = isset($_POST['option_selection3_' . $i]) ? $_POST['option_selection3_' . $i] : ''; $option_name4 = isset($_POST['option_name4_' . $i]) ? $_POST['option_name4_' . $i] : ''; $option_selection4 = isset($_POST['option_selection4_' . $i]) ? $_POST['option_selection4_' . $i] : ''; $option_name5 = isset($_POST['option_name5_' . $i]) ? $_POST['option_name5_' . $i] : ''; $option_selection5 = isset($_POST['option_selection5_' . $i]) ? $_POST['option_selection5_' . $i] : ''; $option_name6 = isset($_POST['option_name6_' . $i]) ? $_POST['option_name6_' . $i] : ''; $option_selection6 = isset($_POST['option_selection6_' . $i]) ? $_POST['option_selection6_' . $i] : ''; $option_name7 = isset($_POST['option_name7_' . $i]) ? $_POST['option_name7_' . $i] : ''; $option_selection7 = isset($_POST['option_selection7_' . $i]) ? $_POST['option_selection7_' . $i] : ''; $option_name8 = isset($_POST['option_name8_' . $i]) ? $_POST['option_name8_' . $i] : ''; $option_selection8 = isset($_POST['option_selection8_' . $i]) ? $_POST['option_selection8_' . $i] : ''; $option_name9 = isset($_POST['option_name9_' . $i]) ? $_POST['option_name9_' . $i] : ''; $option_selection9 = isset($_POST['option_selection9_' . $i]) ? $_POST['option_selection9_' . $i] : ''; $btn_id = isset($_POST['btn_id' . $i]) ? $_POST['btn_id' . $i] : ''; $current_item = array( 'item_number' => $item_number, 'item_name' => $item_name, 'quantity' => $quantity, 'mc_gross' => $mc_gross, 'mc_handling' => $mc_handling, 'mc_shipping' => $mc_shipping, 'custom' => $custom, 'option_name1' => $option_name1, 'option_selection1' => $option_selection1, 'option_name2' => $option_name2, 'option_selection2' => $option_selection2, 'option_name3' => $option_name3, 'option_selection3' => $option_selection3, 'option_name4' => $option_name4, 'option_selection4' => $option_selection4, 'option_name5' => $option_name5, 'option_selection5' => $option_selection5, 'option_name6' => $option_name6, 'option_selection6' => $option_selection6, 'option_name7' => $option_name7, 'option_selection7' => $option_selection7, 'option_name8' => $option_name8, 'option_selection8' => $option_selection8, 'option_name9' => $option_name9, 'option_selection9' => $option_selection9, 'btn_id' => $btn_id ); array_push($cart_items, $current_item); $i++; } // Loop through cart items and add each to related order_items table foreach($cart_items as $cart_item) { $cart_item_data['order_id'] = $order_id; $cart_item_data['subscr_id'] = $subscr_id; $cart_item_data['item_name'] = $cart_item['item_name']; $cart_item_data['item_number'] = $cart_item['item_number']; $cart_item_data['os0'] = $cart_item['option_selection1']; $cart_item_data['on0'] = $cart_item['option_name1']; $cart_item_data['os1'] = $cart_item['option_selection2']; $cart_item_data['on1'] = $cart_item['option_name2']; $cart_item_data['os2'] = $cart_item['option_selection3']; $cart_item_data['on2'] = $cart_item['option_name3']; $cart_item_data['os3'] = $cart_item['option_selection4']; $cart_item_data['on3'] = $cart_item['option_name4']; $cart_item_data['os4'] = $cart_item['option_selection5']; $cart_item_data['on4'] = $cart_item['option_name5']; $cart_item_data['os5'] = $cart_item['option_selection6']; $cart_item_data['on5'] = $cart_item['option_name6']; $cart_item_data['os6'] = $cart_item['option_selection7']; $cart_item_data['on6'] = $cart_item['option_name7']; $cart_item_data['os7'] = $cart_item['option_selection8']; $cart_item_data['on7'] = $cart_item['option_name8']; $cart_item_data['os8'] = $cart_item['option_selection9']; $cart_item_data['on8'] = $cart_item['option_name9']; $cart_item_data['quantity'] = $cart_item['quantity']; $cart_item_data['custom'] = $cart_item['custom']; $cart_item_data['mc_gross'] = $cart_item['mc_gross']; $cart_item_data['mc_handling'] = $cart_item['mc_handling']; $cart_item_data['mc_shipping'] = $cart_item['mc_shipping']; $cart_item_data['raw_log_id'] = $ipn_log_data_id; $cart_item_data['btn_id'] = $cart_item['btn_id']; $cart_item_id = $db -> query_insert('order_items', $cart_item_data); }

我读取了属性Java Security Manager"user.home"

我设置了一个允许在"user.info""user.home"上读写的策略文件。

我开始"user.info"

在策略文件给予许可后,我仍然应该能够读写"user.home""user.info"

但是我遇到了安全异常。

怎么了?

我的Java代码是:

Security Manager

我的政策文件:

"user.home"

xxx

1 个答案:

答案 0 :(得分:0)

您没有正确设置安全策略系统属性。应该是:

System.setProperty("java.security.policy", securityPolicyFile);

如果在设置此选项后仍不起作用,请使用-Djava.security.debug=policy标志打开调试,并检查文件是否被正确读取。您应该看到这样的一行:

  

策略:读取文件:/path/to/your/properties_permissions.policy