List of usage examples for javax.servlet ServletException ServletException
public ServletException(String message, Throwable rootCause)
From source file:com.iorga.iraj.servlet.AgglomeratorServlet.java
@Override public void init(final ServletConfig config) throws ServletException { super.init(config); if (config.getInitParameter("mode") != null) { mode = Mode.valueOf(config.getInitParameter("mode").toUpperCase()); }// w w w .ja va 2s.c om if (mode == Mode.DEVELOPMENT) { // development mode, activate the watch service try { watchService = FileSystems.getDefault().newWatchService(); } catch (final IOException e) { throw new ServletException("Problem while activating the watch service", e); } } parseResourcesFromMappings(config); if (mode == Mode.DEVELOPMENT) { directoryWatcherThread = new Thread(new DirectoryWatcher(), DirectoryWatcher.class.getName()); directoryWatcherThread.setDaemon(true); directoryWatcherThread.start(); } }
From source file:de.fhg.igd.vaadin.util.servlets.AutowiringApplicationServlet.java
/** * Create and configure a new instance of the configured application class. * * <p>// w w w .j a v a 2 s. c o m * The implementation in {@link AutowiringApplicationServlet} delegates to * {@link #getAutowireCapableBeanFactory getAutowireCapableBeanFactory()}, then invokes * {@link AutowireCapableBeanFactory#createBean AutowireCapableBeanFactory.createBean()} * using the configured {@link Application} class. * </p> * * @param request the triggering {@link HttpServletRequest} * @throws ServletException if creation or autowiring fails */ @Override protected Application getNewApplication(HttpServletRequest request) throws ServletException { final Class<? extends Application> cl; try { cl = getApplicationClass(); } catch (final ClassNotFoundException e) { throw new ServletException("failed to determine ApplicationClass", e); } try { final AutowireCapableBeanFactory beanFactory = getAutowireCapableBeanFactory(); return beanFactory.createBean(cl); } catch (final BeansException e) { throw new ServletException("failed to create new instance of " + cl, e); } }
From source file:dk.dma.msinm.user.security.SecurityServletFilter.java
/** * Initializes the security configuration * @param filterConfig the servlet filter configuration *//* w ww.j a v a 2s . co m*/ @Override public void init(FilterConfig filterConfig) throws ServletException { // Initialize the security configuration if (StringUtils.isNotBlank(securityConfFile)) { try { securityConf = new SecurityConf( filterConfig.getServletContext().getResourceAsStream(securityConfFile)); } catch (Exception e) { log.error("Error loading security config file " + securityConfFile, e); throw new ServletException("Error loading security config file " + securityConfFile, e); } } else { securityConf = new SecurityConf(); } log.info("Loaded security configuration " + securityConf); }
From source file:be.fedict.eid.applet.service.impl.handler.FileDigestsDataMessageHandler.java
public Object handleMessage(FileDigestsDataMessage message, Map<String, String> httpHeaders, HttpServletRequest request, HttpSession session) throws ServletException { List<DigestInfo> fileDigestInfos = new LinkedList<DigestInfo>(); List<String> messageFileDigestInfos = message.fileDigestInfos; Iterator<String> messageIterator = messageFileDigestInfos.iterator(); while (messageIterator.hasNext()) { String digestAlgo = messageIterator.next(); String hexDigestValue = messageIterator.next(); String description = messageIterator.next(); byte[] digestValue; try {/*w w w .ja v a 2 s. c o m*/ digestValue = Hex.decodeHex(hexDigestValue.toCharArray()); } catch (DecoderException e) { throw new ServletException("digest value decode error: " + e.getMessage(), e); } fileDigestInfos.add(new DigestInfo(digestValue, digestAlgo, description)); } // TODO DRY refactor: is a copy-paste from HelloMessageHandler SignatureService signatureService = this.signatureServiceLocator.locateService(); DigestInfo digestInfo; try { digestInfo = signatureService.preSign(fileDigestInfos, null); } catch (NoSuchAlgorithmException e) { throw new ServletException("no such algo: " + e.getMessage(), e); } // also save it in the session for later verification SignatureDataMessageHandler.setDigestValue(digestInfo.digestValue, digestInfo.digestAlgo, session); IdentityService identityService = this.identityServiceLocator.locateService(); boolean removeCard; if (null != identityService) { IdentityRequest identityRequest = identityService.getIdentityRequest(); removeCard = identityRequest.removeCard(); } else { removeCard = this.removeCard; } SignRequestMessage signRequestMessage = new SignRequestMessage(digestInfo.digestValue, digestInfo.digestAlgo, digestInfo.description, this.logoff, removeCard, this.requireSecureReader); return signRequestMessage; }
From source file:se.curity.examples.oauth.OAuthOpaqueFilter.java
public void init(FilterConfig filterConfig) throws ServletException { ImmutableMultimap<String, String> initParams = initParamsMapFrom(filterConfig); _oauthHost = getInitParamValue(InitParams.OAUTH_HOST, initParams); int oauthPort = getInitParamValue(InitParams.OAUTH_PORT, initParams, Integer::parseInt); String introspectionPath = getInitParamValue(InitParams.INTROSPECTION_PATH, initParams); String clientId = getInitParamValue(InitParams.CLIENT_ID, initParams); String clientSecret = getInitParamValue(InitParams.CLIENT_SECRET, initParams); String scope = getInitParamValue(InitParams.SCOPE, initParams); _scopes = scope.split("\\s+"); synchronized (this) { if (_opaqueTokenValidator == null) { try { URI introspectionUri = new URI("https", null, _oauthHost, oauthPort, introspectionPath, null, null);// w w w . j a v a 2 s. c o m _opaqueTokenValidator = new OpaqueTokenValidator(introspectionUri, clientId, clientSecret, _httpClient); } catch (URISyntaxException e) { throw new ServletException("Invalid parameters", e); } _logger.info("{} successfully initialized", OAuthFilter.class.getSimpleName()); } else { _logger.warn("Attempted to set introspect URI more than once! Ignoring further attempts."); } } }
From source file:fr.putnami.pwt.core.service.server.service.BasicCommandService.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); String servicesParam = config.getInitParameter(BasicCommandService.PARAM_SERVICES); if (servicesParam != null) { String[] serviceToInstanciate = servicesParam.split(";"); if (serviceToInstanciate != null && serviceToInstanciate.length > 0) { for (String serviceName : serviceToInstanciate) { if (serviceName != null && serviceName.length() > 0) { try { this.getClass(); Class<?> serviceClass = Class.forName(serviceName); Object service = serviceClass.newInstance(); for (Class<?> serviceInterface : serviceClass.getInterfaces()) { this.injectService(serviceInterface, service); }//from w w w.j a v a 2s . c om } catch (ClassNotFoundException e) { throw new ServletException("Can not load service class " + serviceName, e); } catch (InstantiationException e) { throw new ServletException("Can not instantiate service " + serviceName, e); } catch (IllegalAccessException e) { throw new ServletException("Can not instantiate service " + serviceName, e); } } } } } }
From source file:org.jboss.arquillian.warp.impl.server.execution.WarpFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { try {/*from w w w. j a v a 2 s.c o m*/ log.log(Level.FINE, "initializing {0}", WarpFilter.class.getSimpleName()); ManagerBuilder builder = ManagerBuilder.from().extension(Class.forName(DEFAULT_EXTENSION_CLASS)); manager = builder.create(); manager.start(); manager.bind(ApplicationScoped.class, Manager.class, manager); delegator = new RequestDelegator(); } catch (Exception e) { throw new ServletException("Could not init " + WarpFilter.class.getSimpleName(), e); } }
From source file:com.controlj.green.bulktrend.trendserver.SearchServlet.java
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ParameterizedTrendAcceptor filter = getFilter(req); SystemConnection connection = null;// w ww. j av a 2 s .c o m try { connection = DirectAccess.getDirectAccess().getUserSystemConnection(req); } catch (InvalidConnectionRequestException e) { throw new ServletException("Error getting Add-On connection", e); } TrendSourceFinder finder = new TrendSourceFinder(connection); Collection<TrendSourceInfo> trends; try { trends = finder.findTrends(finder.getIdForPath(req.getParameter(PARAM_PATH)), filter); } catch (SystemException e) { writeErrorInRow(resp, e.getMessage()); throw new ServletException(e); } catch (ActionExecutionException e) { writeErrorInRow(resp, e.getMessage()); throw new ServletException(e); } ServletOutputStream out = resp.getOutputStream(); disableCache(resp); for (TrendSourceInfo trend : trends) { out.println(" <tr>"); writeStringCell(out, "displaypath", trend.getDisplayPath()); writeStringCell(out, "type", trend.getType().toString()); writeBooleanCell(out, "enabled", trend.isEnabled()); writeRawCell(out, "sampleinterval", trend.isCOV() ? " " : mSecToTime(trend.getSampleInterval())); writeBooleanCell(out, "cov", trend.isCOV()); writeStringCell(out, "buffersize", Integer.toString(trend.getBufferSize())); writeBooleanCell(out, "historian", trend.isHistorianEnabled()); writeStringCell(out, "trigger", Integer.toString(trend.getHistorianTrigger())); writeRawCell(out, "uploadtime", trend.isCOV() && trend.isEnabled() && trend.isHistorianEnabled() ? " " : mSecToTime(trend.getHistorianUploadTime())); writeRawCell(out, "lookupstring", prepareLookupStringContent(trend.getLookupString())); out.println(" <tr>"); } }
From source file:edu.indiana.d2i.htrc.security.JWTServletFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { // TokenVerifierConfiguration should be HOCON file stored in somewhere in the file system. String filterConfigFile = filterConfig.getInitParameter(PARAM_FILTER_CONFIG); if (filterConfigFile == null) { log.warn(/*from ww w. j a va2 s . c om*/ "No configuration was specified for JWTServletFilter. Using default " + DEFAULT_JWTFILTER_CONF); filterConfigFile = DEFAULT_JWTFILTER_CONF; } URL configUrl; try { if (filterConfigFile.contains(":/")) { configUrl = new URL(filterConfigFile); } else if (!filterConfigFile.startsWith("/")) { ServletContext servletContext = filterConfig.getServletContext(); configUrl = servletContext.getResource(filterConfigFile); } else { configUrl = new File(filterConfigFile).toURI().toURL(); } } catch (MalformedURLException e) { throw new ServletException("Could not load JWTFilter configuration from: " + filterConfigFile, e); } JWTServletFilterConfiguration configuration = new JWTServletFilterConfiguration(configUrl); try { this.tokenVerifier = new TokenVerifier(configuration.getTokenVerifierConfiguration()); } catch (InvalidAlgorithmParameterException e) { throw new ServletException("Could not initialize token verifier.", e); } // We map following JWT claims to HTRC specific request headers by default claimToHeaderMappings.put("email", "htrc-user-email"); claimToHeaderMappings.put("sub", "htrc-user-id"); claimToHeaderMappings.put("iss", "htrc-token-issuer"); // Any extra claim mappings are loaded from configuration file claimToHeaderMappings.putAll(configuration.getClaimMappings()); }