private String getConnectionDetails() { String token = propertiesManager.peekAuthToken(); if (token == null) { token = context.getString(R.string.rest_error_detail_token_missing); } StringBuilder certificate = new StringBuilder(); String apiUrl = propertiesManager.getApiUrl(); if (apiUrl != null) { try { URL url = new URL(apiUrl); CertHandlingStrategy certHandlingStrategy = propertiesManager.getCertHandlingStrategy(); if (url.getProtocol().equalsIgnoreCase("https")) { certificate .append("\n") .append( context.getString( R.string.rest_error_detail_certificate_strategy, certHandlingStrategy.toString())); } if (certHandlingStrategy == CertHandlingStrategy.TRUST_CUSTOM) { boolean hasCert = propertiesManager.getCertificateChain().length > 0; certificate .append("\n\t") .append( context.getString( hasCert ? R.string.rest_error_detail_certificate_stored : R.string.rest_error_detail_certificate_missing)); } } catch (MalformedURLException e) { apiUrl = context.getString(R.string.rest_error_detail_malformed_url, e.getMessage()); } } else { apiUrl = context.getString(R.string.rest_error_detail_missing_url); } return context.getString( R.string.rest_error_details, apiUrl, propertiesManager.getUsername(), token, certificate.toString()); }