use of org.bytedeco.javacpp.FlyCapture2.Error in project javacv by bytedeco.
the class FlyCapture2FrameGrabber method getDeviceDescriptions.
public static String[] getDeviceDescriptions() throws FrameGrabber.Exception {
tryLoad();
BusManager busMgr = new BusManager();
int[] numCameras = new int[1];
busMgr.GetNumOfCameras(numCameras);
String[] descriptions = new String[numCameras[0]];
for (int i = 0; i < numCameras[0]; i++) {
PGRGuid guid = new PGRGuid();
Error error = busMgr.GetCameraFromIndex(i, guid);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
System.exit(-1);
}
Camera cam = new Camera();
// Connect to a camera
error = cam.Connect(guid);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
}
// Get the camera information
CameraInfo camInfo = new CameraInfo();
error = cam.GetCameraInfo(camInfo);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
}
descriptions[i] = CameraInfo(camInfo);
}
return descriptions;
}
use of org.bytedeco.javacpp.FlyCapture2.Error in project ovirt-engine-sdk-java by oVirt.
the class ConnectionBuilder42 method createConnectionSocketFactoryRegistry.
private SchemeRegistry createConnectionSocketFactoryRegistry() {
SchemeRegistry schemeRegistry = new SchemeRegistry();
SSLSocketFactory sf;
// Create SSL/TLS or plain connection:
if (HTTP_PROTOCOL.equals(getProtocol())) {
schemeRegistry.register(new Scheme(HTTP_PROTOCOL, getPort(), PlainSocketFactory.getSocketFactory()));
} else if (HTTPS_PROTOCOL.equals(getProtocol())) {
try {
if (this.insecure) {
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, new TrustManager[] { noCaTrustManager }, null);
sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
} else {
KeyStore truststore = null;
InputStream in = null;
if (this.trustStoreFile != null) {
truststore = KeyStore.getInstance(KeyStore.getDefaultType());
try {
in = new FileInputStream(this.trustStoreFile);
truststore.load(in, this.trustStorePassword != null ? this.trustStorePassword.toCharArray() : null);
} finally {
if (in != null) {
in.close();
}
}
}
sf = new SSLSocketFactory(SSLSocketFactory.TLS, null, null, truststore, null, null, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
}
schemeRegistry.register(new Scheme(HTTPS_PROTOCOL, getPort(), sf));
} catch (NoSuchAlgorithmException e) {
throw new Error(NO_TLS_ERROR, e);
} catch (KeyManagementException e) {
throw new Error(BAD_KEY_ERROR, e);
} catch (KeyStoreException e) {
throw new Error(KEY_STORE_ERROR, e);
} catch (FileNotFoundException e) {
throw new Error(KEY_STORE_FILE_NOT_FOUND_ERROR, e);
} catch (CertificateException e) {
throw new Error(CERTIFICATE_ERROR, e);
} catch (IOException e) {
throw new Error(IO_ERROR, e);
} catch (UnrecoverableKeyException e) {
throw new Error(UNRECOVERABLE_KEY_ERROR, e);
}
}
return schemeRegistry;
}
use of org.bytedeco.javacpp.FlyCapture2.Error in project ovirt-engine-sdk-java by oVirt.
the class HttpConnection method checkContentType.
/**
* Checks the given content type and raises an exception if it isn't the
* expected one.
*
* @param pattern The regular expression used to check the expected content type.
* @param expectedName The name of the expected content type.
* @param actual The actual value of the `Content-Type` header.
* @throws MalformedURLException When URL isn't correct.
*/
private void checkContentType(Pattern pattern, String expectedName, String actual) throws MalformedURLException {
if (!pattern.matcher(actual).matches()) {
StringBuilder sb = new StringBuilder();
sb.append(String.format("The response content type '%1$s' isn't the expected %2$s", actual, expectedName));
URL url = new URL(getUrl());
if (!url.getPath().equals(TYPICAL_PATH)) {
sb.append(String.format(". Is the path '%1$s' included in the 'url' parameter correct?", url.getPath()));
sb.append(String.format(" The typical one is '%1$s'", TYPICAL_PATH));
}
throw new Error(sb.toString());
}
}
use of org.bytedeco.javacpp.FlyCapture2.Error in project ovirt-engine-sdk-java by oVirt.
the class HttpConnection method getSsoResponse.
private JsonNode getSsoResponse(URI uri, List<NameValuePair> params) {
HttpResponse response = null;
try {
// Send request and parse token:
HttpPost requestToken = new HttpPost(uri);
requestToken.addHeader("User-Agent", "JavaSDK");
requestToken.addHeader("Accept", "application/json");
requestToken.setEntity(new UrlEncodedFormEntity(params));
response = client.execute(requestToken);
checkContentType(JSON_CONTENT_TYPE_RE, "JSON", response.getFirstHeader("content-type").getValue());
ObjectMapper mapper = new ObjectMapper();
return mapper.readTree(response.getEntity().getContent());
} catch (IOException ex) {
throw new Error("Failed to parse JSON response", ex);
} catch (Exception ex) {
throw new Error("Failed to send SSO request", ex);
} finally {
if (response != null) {
EntityUtils.consumeQuietly(response.getEntity());
}
}
}
use of org.bytedeco.javacpp.FlyCapture2.Error in project ovirt-engine-sdk-java by oVirt.
the class SsoUtils method buildSsoUrlKerberos.
/**
* Construct SSO URL to obtain token from kerberos authentication.
*
* @param url oVirt engine URL
* @return URI to be used to obtain token
*/
public static URI buildSsoUrlKerberos(String url) {
try {
URI uri = new URI(url);
URIBuilder uriBuilder = new URIBuilder(String.format("%1$s://%2$s/ovirt-engine/sso/oauth/%3$s", uri.getScheme(), uri.getAuthority(), ENTRY_POINT_HTTP));
return uriBuilder.build();
} catch (URISyntaxException ex) {
throw new Error("Failed to build SSO authentication URL", ex);
}
}
Aggregations