use of com.google.privacy.dlp.v2.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 com.google.privacy.dlp.v2.Error in project ovirt-engine-sdk-java by oVirt.
the class SsoUtils method buildSsoRevokeUrl.
/**
* Construct SSO URL to revoke SSO token
*
* @param url oVirt engine URL
* @return URI to be used to revoke token
*/
public static URI buildSsoRevokeUrl(String url) {
try {
URI uri = new URI(url);
URIBuilder uriBuilder = new URIBuilder(String.format("%1$s://%2$s/ovirt-engine/services/sso-logout", uri.getScheme(), uri.getAuthority()));
return uriBuilder.build();
} catch (URISyntaxException ex) {
throw new Error("Failed to build SSO revoke URL", ex);
}
}
use of com.google.privacy.dlp.v2.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);
}
}
use of com.google.privacy.dlp.v2.Error in project javacpp-presets by bytedeco.
the class FlyCapture2Test method main.
public static void main(String[] args) throws IOException {
PrintBuildInfo();
Error error;
// Since this application saves images in the current folder
// we must ensure that we have permission to write to this folder.
// If we do not have permission, fail right away.
File tempFile = new File("test.txt");
try {
new FileOutputStream(tempFile).close();
} catch (IOException e) {
System.out.println("Failed to create file in current folder. " + "Please check permissions.");
System.exit(-1);
}
tempFile.delete();
BusManager busMgr = new BusManager();
int[] numCameras = new int[1];
error = busMgr.GetNumOfCameras(numCameras);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
System.exit(-1);
}
System.out.println("Number of cameras detected: " + numCameras[0]);
for (int i = 0; i < numCameras[0]; i++) {
PGRGuid guid = new PGRGuid();
error = busMgr.GetCameraFromIndex(i, guid);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
System.exit(-1);
}
RunSingleCamera(guid);
}
System.out.println("Done! Press Enter to exit...");
System.in.read();
}
use of com.google.privacy.dlp.v2.Error in project javacpp-presets by bytedeco.
the class FlyCapture2Test method RunSingleCamera.
static int RunSingleCamera(PGRGuid guid) {
final int k_numImages = 10;
Error error;
Camera cam = new Camera();
// Connect to a camera
error = cam.Connect(guid);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
return -1;
}
// Get the camera information
CameraInfo camInfo = new CameraInfo();
error = cam.GetCameraInfo(camInfo);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
return -1;
}
PrintCameraInfo(camInfo);
// Start capturing images
error = cam.StartCapture();
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
return -1;
}
Image rawImage = new Image();
for (int imageCnt = 0; imageCnt < k_numImages; imageCnt++) {
// Retrieve an image
error = cam.RetrieveBuffer(rawImage);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
continue;
}
System.out.println("Grabbed image " + imageCnt);
// Create a converted image
Image convertedImage = new Image();
// Convert the raw image
error = rawImage.Convert(PIXEL_FORMAT_MONO8, convertedImage);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
return -1;
}
// Create a unique filename
String filename = camInfo.serialNumber() + "-" + imageCnt + ".pgm";
// Save the image. If a file format is not passed in, then the file
// extension is parsed to attempt to determine the file format.
error = convertedImage.Save(filename);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
return -1;
}
}
// Stop capturing images
error = cam.StopCapture();
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
return -1;
}
// Disconnect the camera
error = cam.Disconnect();
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
return -1;
}
return 0;
}
Aggregations