use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.
the class OemBO method getAllOem.
/**
*
* @return
*/
public List<OemData> getAllOem() {
List<OemData> allOemData = new ArrayList<OemData>();
try {
List<TblOem> allRecords = tblOemJpaController.findTblOemEntities();
for (TblOem tblOem : allRecords) {
OemData oemData = new OemData(tblOem.getName(), tblOem.getDescription());
allOemData.add(oemData);
}
} catch (ASException ase) {
throw ase;
} catch (Exception e) {
throw new ASException(e);
}
return allOemData;
}
use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.
the class OsBO method getAllOs.
/**
*
* @return
*/
public List<OsData> getAllOs() {
List<OsData> allOsData = new ArrayList<OsData>();
try {
List<TblOs> allRecords = tblOsJpaController.findTblOsEntities();
for (TblOs tblOs : allRecords) {
OsData osData = new OsData(tblOs.getName(), tblOs.getVersion(), tblOs.getDescription());
allOsData.add(osData);
}
} catch (ASException ase) {
throw ase;
} catch (Exception e) {
throw new ASException(e);
}
return allOsData;
}
use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.
the class CitrixClient method connect.
public void connect() throws NoSuchAlgorithmException, KeyManagementException, BadServerResponse, XenAPIException, XmlRpcException, XmlRpcException {
URL url = null;
try {
url = new URL("https://" + hostIpAddress + ":" + port);
} catch (MalformedURLException e) {
throw new ASException(e, ErrorCode.AS_HOST_COMMUNICATION_ERROR, hostIpAddress);
}
TrustManager[] trustAllCerts = new TrustManager[] { tlsConnection.getTlsPolicy().getTrustManager() };
// Install the all-trusting trust manager
SSLContext sc = SSLContext.getInstance("SSL");
// Create empty HostnameVerifier
HostnameVerifier hv = tlsConnection.getTlsPolicy().getHostnameVerifier();
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(hv);
connection = new Connection(url);
Session.loginWithPassword(connection, userName, password, APIVersion.latest().toString());
}
use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.
the class CitrixClient method getQuoteInformationForHost.
public HashMap<String, PcrManifest> getQuoteInformationForHost(String pcrList) {
log.debug("getQuoteInformationForHost pcrList == " + pcrList);
try {
// We cannot reuse the connections across different calls since they are tied to a particular host.
if (!isConnected()) {
connect();
}
String nonce = generateNonce();
String sessionId = generateSessionId();
// We do not need to connect again. So, commenting it out.
// System.err.println("stdalex-error connecting with " + userName + " " + password);
// Session.loginWithPassword(connection, userName, password, APIVersion.latest().toString());
// System.err.println( "CitrixClient: connected to server ["+hostIpAddress+"]");
Map<String, String> myMap = new HashMap<String, String>();
Set<Host> hostList = Host.getAll(connection);
Iterator iter = hostList.iterator();
// hasNext() will always be valid otherwise we will get an exception from the getAll method. So, we not need
// to throw an exception if the hasNext is false.
Host h = null;
if (iter.hasNext()) {
h = (Host) iter.next();
}
String aik = h.callPlugin(connection, "tpm", "tpm_get_attestation_identity", myMap);
int startP = aik.indexOf("<xentxt:TPM_Attestation_KEY_PEM>");
int endP = aik.indexOf("</xentxt:TPM_Attestation_KEY_PEM>");
// 32 is the size of the opening tag <xentxt:TPM_Attestation_KEY_PEM>
String cert = aik.substring(startP + "<xentxt:TPM_Attestation_KEY_PEM>".length(), endP);
keys key = new keys();
// This is the actual value for AIK!!!!!
key.tpmAttKeyPEM = cert;
String aikCertificate = key.tpmAttKeyPEM;
myMap = new HashMap<String, String>();
myMap.put("nonce", nonce);
String quote = h.callPlugin(connection, "tpm", "tpm_get_quote", myMap);
log.debug("extracted quote from response: " + quote);
//saveFile(getCertFileName(sessionId), Base64.decodeBase64(aikCertificate));
saveFile(getCertFileName(sessionId), aikCertificate.getBytes());
log.debug("saved certificate with session id: " + sessionId);
saveQuote(quote, sessionId);
log.debug("saved quote with session id: " + sessionId);
saveNonce(nonce, sessionId);
log.debug("saved nonce with session id: " + sessionId);
//createRSAKeyFile(sessionId);
log.debug("created RSA key file for session id: " + sessionId);
HashMap<String, PcrManifest> pcrMap = verifyQuoteAndGetPcr(sessionId, pcrList);
log.debug("Got PCR map");
return pcrMap;
} catch (ASException e) {
throw e;
// } catch(UnknownHostException e) {
// throw new ASException(e,ErrorCode.AS_HOST_COMMUNICATION_ERROR, hostIpAddress);
} catch (Exception e) {
log.debug("caught exception during login: " + e.toString() + " class: " + e.getClass());
throw new ASException(e, ErrorCode.AS_CITRIX_ERROR, e.toString());
}
}
use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.
the class OsBO method updateOs.
/**
*
* @param osData
* @return
*/
public String updateOs(OsData osData) {
try {
TblOs tblOs = tblOsJpaController.findTblOsByNameVersion(osData.getName(), osData.getVersion());
if (tblOs == null) {
throw new ASException(ErrorCode.WS_OS_DOES_NOT_EXIST, osData.getName(), osData.getVersion());
}
tblOs.setDescription(osData.getDescription());
tblOsJpaController.edit(tblOs);
} catch (ASException ase) {
throw ase;
} catch (Exception e) {
throw new ASException(e);
}
return "true";
}
Aggregations