2017-01-03 57 views
0

觸發Nessus的掃描我有通過SoftLayer的API觸發Nessus的掃描問題,我使用Java和利用這裏的圖書館:https://github.com/softlayer/softlayer-java有問題通過API

這是我使用的方法:

RestApiClient client = new RestApiClient().withCredentials(xxxxxx, xxxxxxx); 
Account.Service accountService = Account.service(client); 
Account account = accountService.getObject(); 

Request.Service requestService = Request.service(client); 

Request request = new Request(); 
request.setAccount(account); 
request.setIpAddress(ipAddress); 

Request scan = requestService.createObject(request); 

我收到擊退這個問題:

你不允許在其他 比你自己的帳戶啓動安全掃描請求。

我使用的是我用來通過API配置多個主機的相同憑據,所以我不確定它爲什麼會在這裏下降。

任何幫助將不勝感激。

謝謝

回答

0

當帳戶被設置而不是帳戶ID時引發錯誤。 你可以試試這個Java例子。

package SoftLayer_Java_Scripts.Examples; 

import com.google.gson.Gson; 
import com.softlayer.api.*; 
import com.softlayer.api.service.Account; 
import com.softlayer.api.service.network.security.scanner.Request; 

public class CreateNetworkSecurityScannerRequest { 

    private static String user = "set me"; 
    private static String apiKey = "set me"; 

    private static ApiClient client = new RestApiClient().withCredentials(user, apiKey); 

    public static void main(String[] args) { 
    Account.Service accountService = Account.service(client); 
    Request.Service requestService = Request.service(client); 
    String ipAddress = "168.1.11.156"; 
    Long virtualGuestId = 22358591L; 

    Account account = null; 
    try { 
     account = accountService.getObject(); 
    } catch (Exception e) { 
     System.out.println("Error retrieving account object.\nError message: " + e.getMessage()); 
    } 
    Request request = new Request(); 
    request.setAccountId(account.getId()); 
    request.setGuestId(virtualGuestId); 
    request.setIpAddress(ipAddress); 
    Request scan = null; 
    try { 
     scan = requestService.createObject(request); 
     Gson gson = new Gson(); 
     System.out.println(gson.toJson(scan)); 
    } 
    catch (Exception e) { 
     System.out.println("Error creating Network Security Scanner Request.\nError message: " + e.getMessage()); 
    } 
    } 
} 

更改您的示例數據。