Java реализация AMT (Intel vPro)

http://grapecom.ru/wp-content/uploads/2018/11/intel_vpro.jpg

В результате работы по реализации AMT (Intel vPro), нами было создано
4 java пакета, которые полностью реализуют функции AMT.
Эти пакеты основываются на коде sun, axis, axis2, grapecom.
Три пакета с примерами мы выкладываем в свободный доступ.

SUN

Ссылка для скачивания – http://grapecom.com/download/vpro/amt_sun.zip

/**
* Created on 18.12.2008
* Copyright (C). Grapecom Ltd. All Rights Reserved.
* @author Nayda Gennadiy
*/

import java.net.Authenticator;

import javax.xml.ws.BindingProvider;
import javax.xml.ws.Holder;

import com.intel.schemas.platform.client.generalinfo._2004._01.GeneralInfoService;
import com.intel.schemas.platform.client.generalinfo._2004._01.GeneralInfoSoapPortType;

 

public class TestJavaVPro {

// **********************************************************
public TestJavaVPro() {
try {
String address = "http://192.168.1.98:16992/GeneralInfoService";
Holder<Long> statusCode = new Holder<Long>();
Holder<String> version = new Holder<String>();

   GeneralInfoService gis = new GeneralInfoService();
GeneralInfoSoapPortType port = gis.getGeneralInfoSoapPortType();

   ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);

Authenticator.setDefault(new MyAuthenticator(“Login”, “Password”));
port.getCoreVersion(statusCode, version);

   System.out.println(statusCode.value);
System.out.println(version.value);

  } catch (Exception e) {
System.out.println(e);

StackTraceElement[] elements = e.getStackTrace();
for (int i = 0; i < elements.length; i++) {
System.out.println(elements[i]);
}
}
}
// **********************************************************
public static void main(String[] args) {
new TestJavaVPro();
}
// **********************************************************
class MyAuthenticator   extends Authenticator {
//  **********************************************************
String user;
String password;
//  **********************************************************
public MyAuthenticator(String user, String password) {
this.user = user;
this.password = password;
}
//  **********************************************************
protected java.net.PasswordAuthentication getPasswordAuthentication(){
return new java.net.PasswordAuthentication(user, password.toCharArray());
}
//  **********************************************************
}
// **********************************************************
}

AXIS

Ссылка для скачивания – http://grapecom.com/download/vpro/amt_axis.zip

/**
* Created on 18.12.2008
* Copyright (C). Grapecom Ltd. All Rights Reserved.
* @author Nayda Gennadiy
*/
import java.net.URL;

import javax.xml.rpc.holders.StringHolder;

import org.apache.axis.holders.UnsignedIntHolder;

import com.intel.schemas.platform.client.GeneralInfo._2004._01.GeneralInfoServiceLocator;
import com.intel.schemas.platform.client.GeneralInfo._2004._01.GeneralInfoSoapBindingStub;
import com.intel.schemas.platform.client.GeneralInfo._2004._01.GeneralInfoSoapPortType;

 

public class TestGenVPro {

// **********************************************************
public TestGenVPro() {
try {
String address = "http://192.168.1.98:16992/GeneralInfoService";
GeneralInfoServiceLocator gisl = new GeneralInfoServiceLocator();
GeneralInfoSoapPortType port = gisl.getGeneralInfoSoapPortType(new URL(address));
((GeneralInfoSoapBindingStub)port).setUsername("Login");
((GeneralInfoSoapBindingStub)port).setPassword("Password");

UnsignedIntHolder statusCode =  new UnsignedIntHolder();
StringHolder version = new StringHolder();

   port.getCoreVersion(statusCode, version);
System.out.println("status="+statusCode.value);
System.out.println("version="+version.value);

  } catch (Exception e) {
System.out.println(e);
}
}
// **********************************************************
public static void main(String[] args) {
new TestGenVPro();
}
// ********************************************************** 

}

AXIS2

Ссылка для скачивания – http://grapecom.com/download/vpro/amt_axis2.zip

/**
* Created on 18.12.2008
* Copyright (C). Grapecom Ltd. All Rights Reserved.
* @author Nayda Gennadiy
*/
package test;

import java.util.ArrayList;
import java.util.List;

import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.Stub;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator;

import com.intel.schemas.platform.client.generalinfo._2004._01.GeneralInfoServiceStub;

public class TestWSAxis {


// *********************************************************
public TestWSAxis(){
try {
GeneralInfoServiceStub port = new GeneralInfoServiceStub("http://192.168.1.98:16992/GeneralInfoService");
initInterface(port);
GeneralInfoServiceStub.GetVlanParameters params = new GeneralInfoServiceStub.GetVlanParameters();
params.setInterfaceHandle(null);
GeneralInfoServiceStub.GetVlanParametersResponse response = port.GetVlanParameters(params);
long status = response.getStatusCode().getPT_STATUS().longValue();
System.out.println(status);
} catch (Exception e) {
System.out.println();
}
}
// *********************************************************
protected void initInterface(Stub stub){
try {
ServiceClient client = stub._getServiceClient();
Options options = client.getOptions();
options.setProperty(HTTPConstants.AUTHENTICATE, getAuthenticator());
} catch (Exception e) {
System.out.println(e);
}
}
// *********************************************************
public Authenticator getAuthenticator() {
Authenticator authenticator = new Authenticator();
List<String> auth = new ArrayList<String>();
auth.add(HttpTransportProperties.Authenticator.DIGEST);
authenticator.setAuthSchemes(auth);
authenticator.setUsername("Login");
authenticator.setPassword("Password");
return authenticator;
}
// *********************************************************
public static void main(String[] args) {
new TestWSAxis();
}
// *********************************************************
}

Copyright by Grapecom
Тел: +7 (36562) 33094
Адрес: Республика Крым, г. Феодосия, ул. Украинская, д.46, офис 3