List of usage examples for org.apache.http.auth AuthenticationException printStackTrace
public void printStackTrace()
From source file:org.dvbviewer.controller.ui.fragments.TimerList.java
@Override public Loader<List<Timer>> onCreateLoader(int arg0, Bundle arg1) { AsyncLoader<List<Timer>> loader = new AsyncLoader<List<Timer>>(getActivity()) { @Override//from ww w. ja v a 2 s. c o m public List<Timer> loadInBackground() { List<Timer> result = null; try { String xml = ServerRequest.getRSString("/api/timerlist.html?utf8=255"); TimerHandler hanler = new TimerHandler(); result = hanler.parse(xml); Collections.sort(result); } catch (AuthenticationException e) { Log.e(ChannelEpg.class.getSimpleName(), "AuthenticationException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_credentials)); } catch (ParseException e) { Log.e(ChannelEpg.class.getSimpleName(), "ParseException"); e.printStackTrace(); } catch (ClientProtocolException e) { Log.e(ChannelEpg.class.getSimpleName(), "ClientProtocolException"); e.printStackTrace(); } catch (IOException e) { Log.e(ChannelEpg.class.getSimpleName(), "IOException"); e.printStackTrace(); } catch (URISyntaxException e) { Log.e(ChannelEpg.class.getSimpleName(), "URISyntaxException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (IllegalStateException e) { Log.e(ChannelEpg.class.getSimpleName(), "IllegalStateException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (IllegalArgumentException e) { Log.e(ChannelEpg.class.getSimpleName(), "IllegalArgumentException"); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (Exception e) { Log.e(ChannelEpg.class.getSimpleName(), "Exception"); e.printStackTrace(); } return result; } }; return loader; }
From source file:org.dvbviewer.controller.ui.fragments.RecordingList.java
@Override public Loader<List<Recording>> onCreateLoader(int arg0, Bundle arg1) { AsyncLoader<List<Recording>> loader = new AsyncLoader<List<Recording>>(getActivity()) { @Override//from w w w . j a va 2s. com public List<Recording> loadInBackground() { List<Recording> result = null; try { String xml = ServerRequest.getRSString("/api/recordings.html?utf8=255"); RecordingHandler hanler = new RecordingHandler(); result = hanler.parse(xml); Collections.sort(result); } catch (AuthenticationException e) { Log.e(ChannelEpg.class.getSimpleName(), "AuthenticationException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_credentials)); } catch (ParseException e) { Log.e(ChannelEpg.class.getSimpleName(), "ParseException"); e.printStackTrace(); } catch (ClientProtocolException e) { Log.e(ChannelEpg.class.getSimpleName(), "ClientProtocolException"); e.printStackTrace(); } catch (IOException e) { Log.e(ChannelEpg.class.getSimpleName(), "IOException"); e.printStackTrace(); } catch (URISyntaxException e) { Log.e(ChannelEpg.class.getSimpleName(), "URISyntaxException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (IllegalStateException e) { Log.e(ChannelEpg.class.getSimpleName(), "IllegalStateException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (IllegalArgumentException e) { Log.e(ChannelEpg.class.getSimpleName(), "IllegalArgumentException"); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (Exception e) { Log.e(ChannelEpg.class.getSimpleName(), "Exception"); e.printStackTrace(); } return result; } }; return loader; }
From source file:org.dvbviewer.controller.ui.fragments.ChannelEpg.java
@Override public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) { Loader<Cursor> loader = null; if (Config.SYNC_EPG && mCHannel != null) { String where = EpgTbl.EPG_ID + SqlSynatx.EQUALS + mCHannel.getEpgID() + SqlSynatx.AND + EpgTbl.END + SqlSynatx.BETWEEN + mDateInfo.getEpgDate().getTime() + SqlSynatx.AND + DateUtils.addDay(mDateInfo.getEpgDate()).getTime(); loader = new CursorLoader(getActivity(), EpgTbl.CONTENT_URI, null, where, null, EpgTbl.END); } else {// w w w . ja va2s .c om loader = new EpgLoader<Cursor>(getActivity(), mDateInfo) { @Override protected void onForceLoad() { super.onForceLoad(); setListShown(false); } @Override public Cursor loadInBackground() { MatrixCursor cursor = null; Date now = mDateInfo.getEpgDate(); String nowFloat = DateUtils.getFloatDate(now); Date tommorrow = DateUtils.addDay(now); String tommorrowFloat = DateUtils.getFloatDate(tommorrow); String url = ServerConsts.URL_CHANNEL_EPG + mCHannel.getEpgID() + "&start=" + nowFloat + "&end=" + tommorrowFloat; try { List<EpgEntry> result = null; EpgEntryHandler handler = new EpgEntryHandler(); String xml = ServerRequest.getRSString(url); result = handler.parse(xml); if (result != null && !result.isEmpty()) { String[] columnNames = new String[] { EpgTbl._ID, EpgTbl.EPG_ID, EpgTbl.TITLE, EpgTbl.SUBTITLE, EpgTbl.DESC, EpgTbl.START, EpgTbl.END }; cursor = new MatrixCursor(columnNames); for (EpgEntry entry : result) { cursor.addRow(new Object[] { entry.getId(), entry.getEpgID(), entry.getTitle(), entry.getSubTitle(), entry.getDescription(), entry.getStart().getTime(), entry.getEnd().getTime() }); } } } catch (AuthenticationException e) { Log.e(ChannelEpg.class.getSimpleName(), "AuthenticationException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_credentials)); } catch (ParseException e) { Log.e(ChannelEpg.class.getSimpleName(), "ParseException"); e.printStackTrace(); } catch (ClientProtocolException e) { Log.e(ChannelEpg.class.getSimpleName(), "ClientProtocolException"); e.printStackTrace(); } catch (IOException e) { Log.e(ChannelEpg.class.getSimpleName(), "IOException"); e.printStackTrace(); } catch (URISyntaxException e) { Log.e(ChannelEpg.class.getSimpleName(), "URISyntaxException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (IllegalStateException e) { Log.e(ChannelEpg.class.getSimpleName(), "IllegalStateException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (IllegalArgumentException e) { Log.e(ChannelEpg.class.getSimpleName(), "IllegalArgumentException"); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (Exception e) { Log.e(ChannelEpg.class.getSimpleName(), "Exception"); e.printStackTrace(); } return cursor; } }; } return loader; }
From source file:org.sdntest.app.SDNTest.java
private boolean flowAllowed() { // get login info from file // TODO: get from somewhere else, or setup certs BufferedReader br = null;/*from w w w . j ava2s . c o m*/ String uname; String password; try { br = new BufferedReader(new FileReader(GLOBUS_LOGIN_FILE)); uname = br.readLine(); password = br.readLine(); } catch (IOException e) { log.info("Error reading globus login file: {}", GLOBUS_LOGIN_FILE); return false; } finally { try { if (br != null) { br.close(); } } catch (IOException ex) { log.info("Error closing globus login file"); } } if (uname == null || password == null) { log.info("Error: could not get globus login from file"); return false; } else { log.info("Got globus login un: {}, pw: {}", uname, password); } // use login info to get authentication token UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(uname, password); CloseableHttpClient httpclient = HttpClientBuilder.create().build(); HttpGet authGet = new HttpGet(GLOBUS_AUTH_URL); try { authGet.addHeader(new BasicScheme().authenticate(credentials, authGet)); } catch (AuthenticationException e1) { e1.printStackTrace(); } authGet.addHeader("User-Agent", "onos"); log.info(authGet.toString()); CloseableHttpResponse response1; try { response1 = httpclient.execute(authGet); } catch (ClientProtocolException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } String authTok = ""; try { log.info(response1.toString()); String resStr = EntityUtils.toString(response1.getEntity()); log.info(resStr); JSONParser jsonParser = new JSONParser(); JSONObject jsonObject = (JSONObject) jsonParser.parse(resStr); authTok = (String) jsonObject.get("access_token"); } catch (IOException e) { e.printStackTrace(); return false; } catch (ParseException e) { e.printStackTrace(); return false; } catch (org.json.simple.parser.ParseException e) { e.printStackTrace(); } finally { try { response1.close(); } catch (IOException e) { e.printStackTrace(); } } log.info("Token: {}", authTok); return true; }
From source file:org.dvbviewer.controller.ui.fragments.ChannelList.java
@Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) { Loader<Cursor> loader = null; switch (loaderId) { case LOADER_CHANNELLIST: String selection = showFavs ? ChannelTbl.FLAGS + " & " + Channel.FLAG_FAV + "!= 0" : null; String orderBy = showFavs ? ChannelTbl.FAV_POSITION : ChannelTbl.POSITION; loader = new CursorLoader(getActivity(), ChannelTbl.CONTENT_URI_NOW, null, selection, null, orderBy); break;//www. j a va 2s . c om case LOADER_EPG: loader = new AsyncLoader<Cursor>(getActivity()) { @Override public Cursor loadInBackground() { List<EpgEntry> result = null; String nowFloat = org.dvbviewer.controller.utils.DateUtils.getFloatDate(new Date()); String url = ServerConsts.URL_EPG + "&start=" + nowFloat + "&end=" + nowFloat; try { EpgEntryHandler handler = new EpgEntryHandler(); String xml = ServerRequest.getRSString(url); result = handler.parse(xml); DbHelper helper = new DbHelper(getContext()); helper.saveNowPlaying(result); } catch (AuthenticationException e) { loadingResult = LoadingResult.INVALID_CREDENTIALS; Log.e(ChannelEpg.class.getSimpleName(), "AuthenticationException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_credentials)); } catch (ParseException e) { Log.e(ChannelEpg.class.getSimpleName(), "ParseException"); e.printStackTrace(); } catch (ClientProtocolException e) { Log.e(ChannelEpg.class.getSimpleName(), "ClientProtocolException"); e.printStackTrace(); } catch (IOException e) { Log.e(ChannelEpg.class.getSimpleName(), "IOException"); e.printStackTrace(); } catch (URISyntaxException e) { Log.e(ChannelEpg.class.getSimpleName(), "URISyntaxException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (IllegalStateException e) { Log.e(ChannelEpg.class.getSimpleName(), "IllegalStateException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (IllegalArgumentException e) { Log.e(ChannelEpg.class.getSimpleName(), "IllegalArgumentException"); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (Exception e) { Log.e(ChannelEpg.class.getSimpleName(), "Exception"); e.printStackTrace(); } return null; } }; break; case LOADER_REFRESH_CHANNELLIST: loader = new AsyncLoader<Cursor>(getActivity()) { @Override public Cursor loadInBackground() { try { /** * Request the Status.xml to get some default Recordingservice Configs */ String statusXml = ServerRequest.getRSString(ServerConsts.URL_STATUS); StatusHandler statusHandler = new StatusHandler(); Status s = statusHandler.parse(statusXml); String version = getVersionString(); DbHelper mDbHelper = new DbHelper(mContext); /** * Request the Channels */ if (Config.isOldRsVersion(version)) { byte[] rawData = ServerRequest.getRSBytes(ServerConsts.URL_CHANNELS_OLD); List<Channel> chans = ChannelListParser.parseChannelList(getContext(), rawData); mDbHelper.saveChannels(chans); } else { String chanXml = ServerRequest.getRSString(ServerConsts.URL_CHANNELS); ChannelHandler channelHandler = new ChannelHandler(); List<Channel> chans = channelHandler.parse(chanXml); mDbHelper.saveChannels(chans); } /** * Request the Favourites */ String favXml = ServerRequest.getRSString(ServerConsts.URL_FAVS); if (!TextUtils.isEmpty(favXml)) { FavouriteHandler handler = new FavouriteHandler(); List<Fav> favs = handler.parse(getActivity(), favXml); mDbHelper.saveFavs(favs); } mDbHelper.close(); /** * Get the Mac Address for WOL */ String macAddress = NetUtils.getMacFromArpCache(ServerConsts.REC_SERVICE_HOST); /** * Save the data in sharedpreferences */ Editor prefEditor = prefs.getPrefs().edit(); if (s != null) { prefEditor.putInt(DVBViewerPreferences.KEY_TIMER_TIME_BEFORE, s.getEpgBefore()); prefEditor.putInt(DVBViewerPreferences.KEY_TIMER_TIME_AFTER, s.getEpgAfter()); prefEditor.putInt(DVBViewerPreferences.KEY_TIMER_DEF_AFTER_RECORD, s.getDefAfterRecord()); } prefEditor.putString(DVBViewerPreferences.KEY_RS_MAC_ADDRESS, macAddress); prefEditor.putBoolean(DVBViewerPreferences.KEY_CHANNELS_SYNCED, true); prefEditor.commit(); Config.CHANNELS_SYNCED = true; } catch (AuthenticationException e) { Log.e(ChannelEpg.class.getSimpleName(), "AuthenticationException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_credentials)); } catch (ParseException e) { Log.e(ChannelEpg.class.getSimpleName(), "ParseException"); e.printStackTrace(); } catch (ClientProtocolException e) { Log.e(ChannelEpg.class.getSimpleName(), "ClientProtocolException"); e.printStackTrace(); } catch (IOException e) { Log.e(ChannelEpg.class.getSimpleName(), "IOException"); e.printStackTrace(); } catch (URISyntaxException e) { Log.e(ChannelEpg.class.getSimpleName(), "URISyntaxException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (IllegalStateException e) { Log.e(ChannelEpg.class.getSimpleName(), "IllegalStateException"); e.printStackTrace(); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (IllegalArgumentException e) { Log.e(ChannelEpg.class.getSimpleName(), "IllegalArgumentException"); showToast(getString(R.string.error_invalid_url) + "\n\n" + ServerConsts.REC_SERVICE_URL); } catch (Exception e) { Log.e(ChannelEpg.class.getSimpleName(), "Exception"); e.printStackTrace(); } return null; } private String getVersionString() throws Exception { String version = null; try { String versionXml = ServerRequest.getRSString(ServerConsts.URL_VERSION); VersionHandler versionHandler = new VersionHandler(); version = versionHandler.parse(versionXml); // here is a regex required! version = version.replace("DVBViewer Recording Service ", ""); String[] arr = version.split(" "); version = arr[0]; } catch (Exception e) { e.printStackTrace(); } return version; } }; break; default: break; } return loader; }