草庐IT

secure_file_priv

全部标签

Java file.getPath() 返回语言修改路径

我需要用fileChooser.getSelectedFile()方法但是它总是返回语言修改路径,因为一些目录在osX中被翻译。例如,文件夹“/Downloads”被翻译成我的系统语言“/Stiahnuté”,但实际路径是“/Downloads”返回:/Users/John/Stiahnuté期待/Users/John/Downloads如果我选择了一些子目录,那么fileChooser.getSelectedFile()会再次返回正确的路径。看起来总是只翻译路径中的最后一个目录/Users/John/Downloads/subDirectory代码:saveButton.addAct

java - Spring security - 创建 403 访问被拒绝的自定义响应

我有一个带有jwt身份验证的springbootrestapi。问题是我无法摆脱默认的403AccessDeniedrest响应,它看起来像这样:{"timestamp":1516206966541,"status":403,"error":"Forbidden","message":"AccessDenied","path":"/api/items/2"}我创建了自定义AccessDeniedHandler:publicclassCustomAccessDeniedHandlerimplementsAccessDeniedHandler{@Overridepublicvoidhand

java - Spring Boot - 大量无效请求和套接字接受失败 java.io.IOException : Too many open files

我的机器运行着Spring(SpringBoot1.5.2.RELEASE)应用程序。最近我在我的日志文件中收到了很多警告:.w.s.m.s.DefaultHandlerExceptionResolver:FailedtoreadHTTPmessage:org.springframework.http.converter.HttpMessageNotReadableException:Couldnotreaddocument:null;nestedexceptionisjava.net.SocketTimeoutException我已经检查过tcpdump并且很多请求没有正文(空/空)

Java 1.7 + JSCH : java. security.InvalidKeyException: Key is too long for this algorithm

我正在尝试使用JSCH将文件上传到远程SFTP分享。每次我尝试从我的代码中连接到共享时,我都会得到一个看起来像这样的异常:com.jcraft.jsch.JSchException:Session.connect:java.security.InvalidKeyException:Keyistoolongforthisalgorithmatcom.jcraft.jsch.Session.connect(Session.java:558)~[jsch-0.1.51.jar:na]atcom.jcraft.jsch.Session.connect(Session.java:183)~[js

为 glob 或类似 Ant 的模式 "*foo/**/*.txt"返回 List<File> 的 Java 库?

我正在寻找一个库,它会提供一种方法,该方法会给我一个匹配给定类Ant模式的文件列表。对于*foo/**/*.txt我会得到foo/x.txtfoo/bar/baz/.txtmyfoo/baz/boo/bar.txt等我知道这可以通过DirWalker和PathMatchermat=FileSystems.getDefault().getPathMatcher("glob:"+filesPattern);,但我更喜欢一些维护的库。我希望CommonsIO拥有它,但没有。更新:我很高兴重用Ant的代码,但更喜欢比整个Ant更小的东西。 最佳答案

java - 使用 Java Config 的 Spring Security 无法使用 eraseCredentials 方法

使用SpringSecurity3.2.2和SpringFramework3.2.8的以下JavaConfig配置,即使我使用“.eraseCredentials(false)”,用户密码也会被删除,并且它无法使用authentication.getCredentials()。@Configuration@EnableWebSecurity@Order(1)publicclassSecurityConfigextendsWebSecurityConfigurerAdapter{@Bean(name="authenticationEntryPoint")publicLoginUrlAut

java - 您如何配置 spring security 以使用基本身份验证对数据库进行身份验证?

我已经用Java编写代码13周了,目前正在开发RESTfulWeb服务。后端已经完成,现在我正在创建一个UI。要求之一是用户使用httpbasic登录。我将此配置为当用户导航到该页面时弹出对话框出现,您可以输入一个硬编码用户我已经登录并登录。但我真正需要它做的是验证用户一个数据库。我进行了广泛搜索,试图找到一种方法来配置它以针对数据库进行验证,但无济于事。这是我的虚拟用户的spring-security.xml文件。-->这里是(我相信)唯一与我的web.xml文件中的设置相关的信息。springSecurityFilterChainorg.springframework.web.fi

java - 在 Java 中 : "Too many open files" error when reading from a network path

我有下面的代码,它只是从一个文件夹中读取所有文件。此文件夹中有20,000个文件。该代码在本地文件夹(d:/files)上运行良好,但在读取大约1,000-2,000个文件后在网络路径(//robot/files)上运行失败。更新:文件夹是彼此的副本。导致此问题的原因以及如何解决?packagecef_debug;importjava.io.*;publicclassMain{publicstaticvoidmain(String[]args)throwsThrowable{Stringfolder=args[0];File[]files=(newFile(folder)).listF

java - 具有路径变量和 Ant 匹配器的 Spring Security 自定义方法

我正在使用带有java配置的springboot、webMVC和springsecurity。我的URL是“RESTful”的,想要添加自定义授权方法。例如:.antMatchers("/path/*/**").access("@myBean.authorise()")我想实现这样的目标:.antMatchers("/path/{token}/**").access("@myBean.authorise(token)")我知道我可以传入HttpServletRequest并手动去除路径,但我想避免这种情况!也不太热衷于方法级安全性,宁愿将配置保存在一个地方,因为我有很多Controll

java - Spring Security hasPermission 不起作用

我正在尝试将SpringSecurity集成到我的SpringWeb应用程序中。基本上我需要根据用户权限隐藏一些菜单。这是我所做的。我在类路径下添加了JARS。spring-security-acl-4.0.2.RELEASE.jarspring-security-config-4.0.2.RELEASE.jarspring-security-core-4.0.2.RELEASE.jarspring-security-taglibs-4.0.1.RELEASE.jarspring-security-web-4.0.2.RELEASE.jar下面是web.xml中的条目log4jConf