use of com.google.privacy.dlp.v2.Error in project openflowplugin by opendaylight.
the class DeviceContextImplTest method testProcessReply.
@Test
public void testProcessReply() {
final Error mockedError = mock(Error.class);
deviceContext.processReply(mockedError);
verify(messageSpy).spyMessage(Mockito.<Class>any(), eq(MessageSpy.StatisticsGroup.FROM_SWITCH_PUBLISHED_FAILURE));
final OfHeader mockedOfHeader = mock(OfHeader.class);
deviceContext.processReply(mockedOfHeader);
verify(messageSpy).spyMessage(Mockito.<Class>any(), eq(MessageSpy.StatisticsGroup.FROM_SWITCH_PUBLISHED_SUCCESS));
}
use of com.google.privacy.dlp.v2.Error in project openflowplugin by opendaylight.
the class StackedSegment method completeEntry.
private static boolean completeEntry(final OutboundQueueEntry entry, final OfHeader response) {
if (response instanceof Error) {
final Error err = (Error) response;
LOG.debug("Device-reported request XID {} failed {}:{}", response.getXid(), err.getTypeString(), err.getCodeString());
entry.fail(new DeviceRequestFailedException("Device-side failure", err));
return true;
}
return entry.complete(response);
}
use of com.google.privacy.dlp.v2.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 com.google.privacy.dlp.v2.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 com.google.privacy.dlp.v2.Error in project ovirt-engine-sdk-java by oVirt.
the class HttpConnection method send.
private HttpResponse send(HttpUriRequest request, boolean failedAuth) {
try {
injectHeaders(request);
HttpResponse response = client.execute(request);
/**
* If the request failed because of authentication, and it
* wasn't a request to the SSO service, then the most likely
* cause is an expired SSO token. In this case we need to
* request a new token, and try the original request again, but
* only once. It if fails again, we just return the failed
* response.
*/
if (response.getStatusLine().getStatusCode() == 401 && !failedAuth) {
ssoToken = null;
authenticate();
response = send(request, true);
}
if (response.getFirstHeader("content-type") != null) {
checkContentType(XML_CONTENT_TYPE_RE, "XML", response.getFirstHeader("content-type").getValue());
}
return response;
} catch (Exception e) {
throw new Error("Failed to send request", e);
}
}
Aggregations