io.undertow.server.handlers.form.FormParserFactory Java Examples
The following examples show how to use
io.undertow.server.handlers.form.FormParserFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public AuthenticationMechanism create(String mechanismName,IdentityManager identityManager, FormParserFactory formParserFactory, Map<String, String> properties) { String realm = properties.get(REALM); String silent = properties.get(SILENT); String charsetString = properties.get(CHARSET); Charset charset = charsetString == null ? StandardCharsets.UTF_8 : Charset.forName(charsetString); Map<Pattern, Charset> userAgentCharsets = new HashMap<>(); String userAgentString = properties.get(USER_AGENT_CHARSETS); if(userAgentString != null) { String[] parts = userAgentString.split(","); if(parts.length % 2 != 0) { throw UndertowMessages.MESSAGES.userAgentCharsetMustHaveEvenNumberOfItems(userAgentString); } for(int i = 0; i < parts.length; i += 2) { Pattern pattern = Pattern.compile(parts[i]); Charset c = Charset.forName(parts[i + 1]); userAgentCharsets.put(pattern, c); } } return new BasicAuthenticationMechanism(realm, mechanismName, silent != null && silent.equals("true"), identityManager, charset, userAgentCharsets); }
Example #2
Source File: BasicAuthenticationMechanism.java From quarkus-http with Apache License 2.0 | 6 votes |
@Override public AuthenticationMechanism create(String mechanismName, IdentityManager identityManager, FormParserFactory formParserFactory, Map<String, String> properties) { String realm = properties.get(REALM); String silent = properties.get(SILENT); String charsetString = properties.get(CHARSET); Charset charset = charsetString == null ? StandardCharsets.UTF_8 : Charset.forName(charsetString); Map<Pattern, Charset> userAgentCharsets = new HashMap<>(); String userAgentString = properties.get(USER_AGENT_CHARSETS); if(userAgentString != null) { String[] parts = userAgentString.split(","); if(parts.length % 2 != 0) { throw UndertowMessages.MESSAGES.userAgentCharsetMustHaveEvenNumberOfItems(userAgentString); } for(int i = 0; i < parts.length; i += 2) { Pattern pattern = Pattern.compile(parts[i]); Charset c = Charset.forName(parts[i + 1]); userAgentCharsets.put(pattern, c); } } return new BasicAuthenticationMechanism(realm, mechanismName, silent != null && silent.equals("true"), identityManager, charset, userAgentCharsets); }
Example #3
Source File: LightBasicAuthenticationMechanism.java From light-oauth2 with Apache License 2.0 | 6 votes |
@Override public AuthenticationMechanism create(String mechanismName, FormParserFactory formParserFactory, Map<String, String> properties) { String realm = properties.get(REALM); String silent = properties.get(SILENT); String charsetString = properties.get(CHARSET); Charset charset = charsetString == null ? StandardCharsets.UTF_8 : Charset.forName(charsetString); Map<Pattern, Charset> userAgentCharsets = new HashMap<>(); String userAgentString = properties.get(USER_AGENT_CHARSETS); if(userAgentString != null) { String[] parts = userAgentString.split(","); if(parts.length % 2 != 0) { throw UndertowMessages.MESSAGES.userAgentCharsetMustHaveEvenNumberOfItems(userAgentString); } for(int i = 0; i < parts.length; i += 2) { Pattern pattern = Pattern.compile(parts[i]); Charset c = Charset.forName(parts[i + 1]); userAgentCharsets.put(pattern, c); } } return new com.networknt.oauth.security.LightBasicAuthenticationMechanism(realm, mechanismName, silent != null && silent.equals("true"), identityManager, charset, userAgentCharsets); }
Example #4
Source File: FormAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 5 votes |
public FormAuthenticationMechanism(final FormParserFactory formParserFactory, final String name, final String loginPage, final String errorPage, final String postLocation, final IdentityManager identityManager) { this.name = name; this.loginPage = loginPage; this.errorPage = errorPage; this.postLocation = postLocation; this.formParserFactory = formParserFactory; this.identityManager = identityManager; }
Example #5
Source File: MCMPHandler.java From lams with GNU General Public License v2.0 | 5 votes |
MCMPHandler(MCMPConfig config, ModCluster modCluster, HttpHandler next) { this.config = config; this.next = next; this.modCluster = modCluster; this.container = modCluster.getContainer(); this.parserFactory = FormParserFactory.builder(false).addParser(new FormEncodedDataDefinition().setForceCreation(true)).build(); UndertowLogger.ROOT_LOGGER.mcmpHandlerCreated(); }
Example #6
Source File: FormAuthenticationMechanism.java From quarkus-http with Apache License 2.0 | 5 votes |
public FormAuthenticationMechanism(final FormParserFactory formParserFactory, final String name, final String loginPage, final String errorPage, final String postLocation, final IdentityManager identityManager) { this.name = name; this.loginPage = loginPage; this.errorPage = errorPage; this.postLocation = postLocation; this.formParserFactory = formParserFactory; this.identityManager = identityManager; }
Example #7
Source File: ServletFormAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public AuthenticationMechanism create(String mechanismName, IdentityManager identityManager, FormParserFactory formParserFactory, Map<String, String> properties) { boolean saveOriginal = true; if(properties.containsKey(SAVE_ORIGINAL_REQUEST)) { saveOriginal = Boolean.parseBoolean(properties.get(SAVE_ORIGINAL_REQUEST)); } return new ServletFormAuthenticationMechanism(formParserFactory, mechanismName, properties.get(LOGIN_PAGE), properties.get(ERROR_PAGE), identityManager, saveOriginal); }
Example #8
Source File: LightFormAuthenticationMechanism.java From light-oauth2 with Apache License 2.0 | 5 votes |
public LightFormAuthenticationMechanism(final FormParserFactory formParserFactory, final String name, final String loginPage, final String errorPage, final String postLocation, final IdentityManager identityManager) { this.name = name; this.loginPage = loginPage; this.errorPage = errorPage; this.postLocation = postLocation; this.formParserFactory = formParserFactory; this.identityManager = identityManager; }
Example #9
Source File: BodyHandler.java From light-4j with Apache License 2.0 | 5 votes |
/** * Method used to parse the body into FormData and attach it into exchange * * @param exchange exchange to be attached * @throws IOException */ private void attachFormDataBody(final HttpServerExchange exchange) throws IOException { Object data; FormParserFactory formParserFactory = FormParserFactory.builder().build(); FormDataParser parser = formParserFactory.createParser(exchange); if (parser != null) { FormData formData = parser.parseBlocking(); data = BodyConverter.convert(formData); exchange.putAttachment(REQUEST_BODY, data); } }
Example #10
Source File: HTTPIOHandler.java From core-ng-project with Apache License 2.0 | 5 votes |
HTTPIOHandler(HTTPHandler handler, ShutdownHandler shutdownHandler) { this.handler = handler; this.shutdownHandler = shutdownHandler; var builder = FormParserFactory.builder(); builder.setDefaultCharset(UTF_8.name()); formParserFactory = builder.build(); }
Example #11
Source File: FormHandler.java From mangooio with Apache License 2.0 | 5 votes |
/** * Retrieves the form parameter from a request * * @param exchange The Undertow HttpServerExchange * * @throws IOException */ @SuppressWarnings("rawtypes") protected Form getForm(HttpServerExchange exchange) throws IOException { final Form form = Application.getInstance(Form.class); if (RequestUtils.isPostPutPatch(exchange)) { final Builder builder = FormParserFactory.builder(); builder.setDefaultCharset(StandardCharsets.UTF_8.name()); try (final FormDataParser formDataParser = builder.build().createParser(exchange)) { if (formDataParser != null) { exchange.startBlocking(); final FormData formData = formDataParser.parseBlocking(); for (String data : formData) { Deque<FormValue> deque = formData.get(data); if (deque != null) { FormValue formValue = deque.element(); if (formValue != null) { if (formValue.isFileItem() && formValue.getFileItem().getFile() != null) { form.addFile(Files.newInputStream(formValue.getFileItem().getFile())); } else { if (data.contains("[]")) { String key = StringUtils.replace(data, "[]", ""); for (Iterator iterator = deque.iterator(); iterator.hasNext();) { form.addValueList(new HttpString(key).toString(), ((FormValue) iterator.next()).getValue()); } } else { form.addValue(new HttpString(data).toString(), formValue.getValue()); } } } } } } } form.setSubmitted(true); } return form; }
Example #12
Source File: ServletFormAuthenticationMechanism.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public AuthenticationMechanism create(String mechanismName, IdentityManager identityManager, FormParserFactory formParserFactory, Map<String, String> properties) { boolean saveOriginal = true; if(properties.containsKey(SAVE_ORIGINAL_REQUEST)) { saveOriginal = Boolean.parseBoolean(properties.get(SAVE_ORIGINAL_REQUEST)); } return new ServletFormAuthenticationMechanism( formParserFactory, mechanismName, properties.get(LOGIN_PAGE), properties.get(ERROR_PAGE), identityManager, saveOriginal); }
Example #13
Source File: DigestAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public AuthenticationMechanism create(String mechanismName,IdentityManager identityManager, FormParserFactory formParserFactory, Map<String, String> properties) { return new DigestAuthenticationMechanism(properties.get(REALM), properties.get(CONTEXT_PATH), mechanismName, identityManager); }
Example #14
Source File: ServletFormAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 4 votes |
public ServletFormAuthenticationMechanism(FormParserFactory formParserFactory, String name, String loginPage, String errorPage, String postLocation) { super(formParserFactory, name, loginPage, errorPage, postLocation); this.saveOriginalRequest = true; }
Example #15
Source File: ServletFormAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 4 votes |
public ServletFormAuthenticationMechanism(FormParserFactory formParserFactory, String name, String loginPage, String errorPage) { super(formParserFactory, name, loginPage, errorPage); this.saveOriginalRequest = true; }
Example #16
Source File: ServletFormAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 4 votes |
public ServletFormAuthenticationMechanism(FormParserFactory formParserFactory, String name, String loginPage, String errorPage, IdentityManager identityManager) { super(formParserFactory, name, loginPage, errorPage, identityManager); this.saveOriginalRequest = true; }
Example #17
Source File: ServletFormAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 4 votes |
public ServletFormAuthenticationMechanism(FormParserFactory formParserFactory, String name, String loginPage, String errorPage, IdentityManager identityManager, boolean saveOriginalRequest) { super(formParserFactory, name, loginPage, errorPage, identityManager); this.saveOriginalRequest = saveOriginalRequest; }
Example #18
Source File: ClientCertAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public AuthenticationMechanism create(String mechanismName,IdentityManager identityManager, FormParserFactory formParserFactory, Map<String, String> properties) { String forceRenegotiation = properties.get(FORCE_RENEGOTIATION); return new ClientCertAuthenticationMechanism(mechanismName, forceRenegotiation == null ? true : "true".equals(forceRenegotiation), identityManager); }
Example #19
Source File: ManagedServlet.java From lams with GNU General Public License v2.0 | 4 votes |
public void setupMultipart(ServletContextImpl servletContext) { FormEncodedDataDefinition formDataParser = new FormEncodedDataDefinition() .setDefaultEncoding(servletContext.getDeployment().getDefaultRequestCharset().name()); MultipartConfigElement multipartConfig = servletInfo.getMultipartConfig(); if(multipartConfig == null) { multipartConfig = servletContext.getDeployment().getDeploymentInfo().getDefaultMultipartConfig(); } this.multipartConfig = multipartConfig; if (multipartConfig != null) { //todo: fileSizeThreshold MultipartConfigElement config = multipartConfig; if (config.getMaxRequestSize() != -1) { maxRequestSize = config.getMaxRequestSize(); } else { maxRequestSize = -1; } final Path tempDir; if(config.getLocation() == null || config.getLocation().isEmpty()) { tempDir = servletContext.getDeployment().getDeploymentInfo().getTempPath(); } else { String location = config.getLocation(); Path locFile = Paths.get(location); if(locFile.isAbsolute()) { tempDir = locFile; } else { tempDir = servletContext.getDeployment().getDeploymentInfo().getTempPath().resolve(location); } } MultiPartParserDefinition multiPartParserDefinition = new MultiPartParserDefinition(tempDir); if(config.getMaxFileSize() > 0) { multiPartParserDefinition.setMaxIndividualFileSize(config.getMaxFileSize()); } multiPartParserDefinition.setDefaultEncoding(servletContext.getDeployment().getDefaultRequestCharset().name()); formParserFactory = FormParserFactory.builder(false) .addParser(formDataParser) .addParser(multiPartParserDefinition) .build(); } else { //no multipart config we don't allow multipart requests formParserFactory = FormParserFactory.builder(false).addParser(formDataParser).build(); maxRequestSize = -1; } }
Example #20
Source File: SessionValidationPostHandler.java From mxisd with GNU Affero General Public License v3.0 | 4 votes |
public SessionValidationPostHandler(SessionManager mgr) { super(mgr); factory = FormParserFactory.builder().build(); }
Example #21
Source File: ManagedServlet.java From lams with GNU General Public License v2.0 | 4 votes |
public FormParserFactory getFormParserFactory() { return formParserFactory; }
Example #22
Source File: ImmediateAuthenticationMechanismFactory.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public AuthenticationMechanism create(String mechanismName, IdentityManager identityManager, FormParserFactory formParserFactory, Map<String, String> properties) { return authenticationMechanism; }
Example #23
Source File: FormAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 4 votes |
public FormAuthenticationMechanism(final FormParserFactory formParserFactory, final String name, final String loginPage, final String errorPage, final IdentityManager identityManager) { this(formParserFactory, name, loginPage, errorPage, DEFAULT_POST_LOCATION, identityManager); }
Example #24
Source File: LightFormAuthenticationMechanism.java From light-oauth2 with Apache License 2.0 | 4 votes |
public LightFormAuthenticationMechanism(final String name, final String loginPage, final String errorPage) { this(FormParserFactory.builder().build(), name, loginPage, errorPage); }
Example #25
Source File: LightFormAuthenticationMechanism.java From light-oauth2 with Apache License 2.0 | 4 votes |
public LightFormAuthenticationMechanism(final String name, final String loginPage, final String errorPage, final String postLocation) { this(FormParserFactory.builder().build(), name, loginPage, errorPage, postLocation); }
Example #26
Source File: LightFormAuthenticationMechanism.java From light-oauth2 with Apache License 2.0 | 4 votes |
public LightFormAuthenticationMechanism(final FormParserFactory formParserFactory, final String name, final String loginPage, final String errorPage) { this(formParserFactory, name, loginPage, errorPage, DEFAULT_POST_LOCATION); }
Example #27
Source File: LightFormAuthenticationMechanism.java From light-oauth2 with Apache License 2.0 | 4 votes |
public LightFormAuthenticationMechanism(final FormParserFactory formParserFactory, final String name, final String loginPage, final String errorPage, final IdentityManager identityManager) { this(formParserFactory, name, loginPage, errorPage, DEFAULT_POST_LOCATION, identityManager); }
Example #28
Source File: LightFormAuthenticationMechanism.java From light-oauth2 with Apache License 2.0 | 4 votes |
public LightFormAuthenticationMechanism(final FormParserFactory formParserFactory, final String name, final String loginPage, final String errorPage, final String postLocation) { this(formParserFactory, name, loginPage, errorPage, postLocation, null); }
Example #29
Source File: DomainApiUploadHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public DomainApiUploadHandler(ModelController modelController) { this.modelController = modelController; this.formParserFactory = FormParserFactory.builder().build(); }
Example #30
Source File: DomainApiGenericOperationHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public DomainApiGenericOperationHandler(ModelController modelController) { this.modelController = modelController; this.formParserFactory = FormParserFactory.builder().build(); }