我正在尝试将Spring Security SAML Extension与Spring Boot集成.
关于这件事,我确实开发了一个完整的示例应用程序.它的源代码可以在GitHub上找到:
通过将其作为Spring Boot应用程序运行(针对SDK内置的Application Server运行),WebApp可以正常工作.
不幸的是,相同的AuthN进程在Undertow/WildFly上根本不起作用.
根据日志,IdP实际上执行AuthN过程:我的自定义UserDetails
实现的指令被正确执行.尽管有执行流程,但Spring并未设置并保留当前用户的权限.
@Component
public class SAMLUserDetailsServiceImpl implements SAMLUserDetailsService {
// Logger
private static final Logger LOG = LoggerFactory.getLogger(SAMLUserDetailsServiceImpl.class);
@Override
public Object loadUserBySAML(SAMLCredential credential)
throws UsernameNotFoundException, SSOUserAccountNotExistsException {
String userID = credential.getNameID().getValue();
if (userID.compareTo("jdoe@samplemail.com") != 0) { // We're simulating the data access.
LOG.warn("SSO User Account not found into the system");
throw new SSOUserAccountNotExistsException("SSO User Account not found into …
Run Code Online (Sandbox Code Playgroud) 我有一个在Wildfly 8.0.0 Final上运行的JavaEE应用程序.
应用程序使用大量图像,我不想将它们存储在数据库中,因此它们被写入硬盘.
例如,如何配置Wildfly/Undertow以便在某个URL上提供这些文件(/ var/images)http://localhost:8080/myapplication/imagesFromDisk
?
我正在使用Vert.x和基于事件循环的服务器相当新,而不是线程/连接模型.
public void start(Future<Void> fut) {
vertx
.createHttpServer()
.requestHandler(r -> {
LocalDateTime start = LocalDateTime.now();
System.out.println("Request received - "+start.format(DateTimeFormatter.ISO_DATE_TIME));
final MyModel model = new MyModel();
try {
for(int i=0;i<10000000;i++){
//some simple operation
}
model.data = start.format(DateTimeFormatter.ISO_DATE_TIME) +" - "+LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
r.response().end(
new Gson().toJson(model)
);
})
.listen(4568, result -> {
if (result.succeeded()) {
fut.complete();
} else {
fut.fail(result.cause());
}
});
System.out.println("Server started ..");
}
Run Code Online (Sandbox Code Playgroud)
根据目前的答案编辑:
我现在使用的代码:
Pooled<ByteBuffer> pooledByteBuffer = exchange.getConnection().getBufferPool().allocate();
ByteBuffer byteBuffer = pooledByteBuffer.getResource();
int limit = byteBuffer.limit();
byteBuffer.clear();
exchange.getRequestChannel().read(byteBuffer);
int pos = byteBuffer.position();
byteBuffer.rewind();
byte[] bytes = new byte[pos];
byteBuffer.get(bytes);
String requestBody = new String(bytes, Charset.forName("UTF-8") );
byteBuffer.clear();
pooledByteBuffer.free();
Run Code Online (Sandbox Code Playgroud)
它似乎工作正常但我不确定是否需要clear()
ByteBuffer才能将其返回池中.我甚至不确定使用exchange.getConnection().getBufferPool().allocate();
.文档中没有太多关于它的内容.
目前在spring boot 1.3中,我们只能将访问日志记录到文件系统中的文件中.有没有办法实际使用自定义记录器(如log4j2)来记录访问日志?
我目前正在使用带有spring boot的下载,但是在检查了spring boot源代码之后,使用DefaultAccessLogReceiver初始化了underow logger,它正在写入文件.我想尽可能使用AccessLogHandler,并避免编写记录访问权限的Web过滤器.
这有什么简单的方法吗?(写拉取请求除外)
我正在使用Undertow创建一个简单的应用程序.
public class App {
public static void main(String[] args) {
Undertow server = Undertow.builder().addListener(8080, "localhost")
.setHandler(new HttpHandler() {
public void handleRequest(HttpServerExchange exchange) throws Exception {
Thread.sleep(5000);
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.getResponseSender().send("Hello World");
}
}).build();
server.start();
}
}
Run Code Online (Sandbox Code Playgroud)
我打开浏览器选项卡,localhost:8080
然后打开第二个选项卡localhost:8080
这次第一个标签将等待5秒,第二个标签将等待10秒
为什么会这样?
我可能错了,但根据我的理解,WildFly必须具备以下功能:
必须可以将我的JSF视图(即xhtml文件)链接到WildFly服务器上已有的资源(pdf,图像,其他xhtml文件).
我可以在php和apache服务器上做同样的事情.
我需要在哪里放置这些资源,如何从我的视图中访问它们?E. g.将视图中的链接放到pdf文件中,该文件在新选项卡中打开pdf文件.
非常感谢您的提示和提示!!
编辑
standalone.xml
<server name="default-server">
<http-listener name="default" socket-binding="http" max-post-size="974247881"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<location name="/content" handler="ContentDir"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
<file name="ContentDir" path="${jboss.home.dir}/standalone/data/unzipped" directory-listing="true"/>
</handlers>
Run Code Online (Sandbox Code Playgroud)
链接在JSF视图中
<h:outputLink value="http://localhost:8181/content">KLICK</h:outputLink>
Run Code Online (Sandbox Code Playgroud)
当我点击这个时,我得到目录列表,如你所说.
但是我怎样才能使它显示index.xhtml
在content
指向的目录中?这就是我想要的.
content
指向${jboss.home.dir}/standalone/data/unzipped
和解压缩有一个index.xhtml
以及另一个包含更多.xhtml
文件的文件夹.
在文件夹中的文件index.xhtml
有相对链接.xhmtl
:
<ul>
<li><a href="t/rt.html">hg</a></li>
<li><a href="t/tert.html">jghj</a></li>
<li><a href="t/gf.html">jghj</a></li>
<li><a href="t/hg.html">jghj</a></li>
<li><a href="t/hgfh.html">jghj</a></li>
<li><a href="t/hfgh.html">jhgj</a></li>
<li><a href="t/hfgh.html">jhgj</a></li> …
Run Code Online (Sandbox Code Playgroud) 我创建了一个Undertow服务器和一个处理程序来记录请求.我在检索请求体时遇到问题HttpServerExchange
.
在LoggingHandler
课堂上,我的身体没有问题.但在TestEndpoint
身体空洞.
如果我删除了检索请求体的行,LoggingHandler
则会填充正文TestEndpoint
.
有谁知道这样做的方法?
我的服务器类:
package com.undertow.server;
import com.undertow.server.endpoints.TestEndpoint;
import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer;
import org.jboss.resteasy.spi.ResteasyDeployment;
import io.undertow.Undertow;
import io.undertow.Undertow.Builder;
import io.undertow.server.HandlerWrapper;
import io.undertow.server.HttpHandler;
import io.undertow.server.handlers.BlockingHandler;
import io.undertow.servlet.api.DeploymentInfo;
public class UndertowServer {
private UndertowJaxrsServer server;
public UndertowServer() {
this.server = new UndertowJaxrsServer();
}
public void start() {
Builder builder = Undertow.builder().addHttpListener(8000, "0.0.0.0");
this.server.start(builder);
this.configureEndpoints();
}
private void configureEndpoints() {
ResteasyDeployment deployment = new ResteasyDeployment();
deployment.getActualResourceClasses().add(TestEndpoint.class);
DeploymentInfo deploymentInfo = this.server.undertowDeployment(deployment) //
.setClassLoader(ClassLoader.getSystemClassLoader()).setContextPath("/gateway/") //
.setDeploymentName("gateway.war"); …
Run Code Online (Sandbox Code Playgroud) 根据这个:http://undertow.io/它支持websockets.但是,没有关于如何这样做的文档.我只想要一个处理Web套接字示例的简单嵌入式底层.
我不想抓住整个jboss应用服务器.
我很快就会使用名为Undertow的服务器.该网站说:
Undertow是一个用java编写的灵活的高性能Web服务器,提供基于NIO的阻塞和非阻塞API
如果Undertow允许非阻塞,那是否与node.js相同?我不是指语言或类似的东西.我有一个单独的项目,我认为node.js是一个不错的选择,但如果我可以将单个产品用于多个项目,那将会很有帮助.
编辑:我发现了这个问题. Java NIO非阻塞模式vs node.js异步操作我开始认为我有些困惑.
undertow ×10
java ×7
wildfly ×4
spring ×2
httphandler ×1
jboss ×1
log4j2 ×1
nio ×1
node.js ×1
nonblocking ×1
rest ×1
resteasy ×1
spring-boot ×1
spring-saml ×1
vert.x ×1
websocket ×1
wildfly-8 ×1