我必须说我对整个模型非常困惑,我需要帮助将所有漂浮的部分粘在一起.
我不是在做Spring REST,只是简单的WebMVC控制器.
我的使命:我希望使用用户名+通过身份验证进行表单登录.我想对第三方服务进行身份验证.成功后我想返回一个cookie但不使用默认的cookie令牌机制.我想让cookie改为使用JWT令牌.通过利用cookie机制,每个请求都将与JWT一起发送.
因此,为了打破它,我有以下模块来照顾:
成功验证后,使用我的自定义实现替换cookie会话令牌
每个请求从cookie中解析JWT(使用过滤器)
从JWT中提取用户详细信息/数据,以便控制器可以访问
什么令人困惑?(请纠正我错在哪里)
第三方认证
要对第三方进行身份验证,我需要通过扩展AuthenticationProvider来获得自定义提供程序
public class JWTTokenAuthenticationProvider implements AuthenticationProvider {
@Override
public Authentication authenticate( Authentication authentication ) throws AuthenticationException {
// auth against 3rd party
// return Authentication
return new UsernamePasswordAuthenticationToken( name, password, new ArrayList<>() );
}
@Override
public boolean supports(Class<?> authentication) {
return authentication.equals( UsernamePasswordAuthenticationToken.class );
}
}
Run Code Online (Sandbox Code Playgroud)
问题:
用JWT替换cookie令牌
不知道如何优雅地做到这一点,我可以想到多种方式,但他们不是Spring Security方式,我不想打破流程.非常感谢这里的任何建议!
使用cookie的每个请求解析JWT
根据我的理解,我需要像这样扩展AbstractAuthenticationProcessingFilter
public class CookieAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
@Override
public Authentication attemptAuthentication( HttpServletRequest request, …Run Code Online (Sandbox Code Playgroud) Java FX提供Window.centerOnScreen()来猜测 - 屏幕上的窗口居中.但是,Java FX对"屏幕中心"的定义似乎是(0.5x; 0.33y).我希望这是一个bug,但我被告知不是.
无论如何.是否有人提出了一个简洁的解决方案,如何在显示窗口之前将窗口居中?我的第一种方法导致屏幕闪烁,因为必须首先显示窗口,然后才能居中.
public static void centerOnScreen(Stage stage) {
stage.centerOnScreen();
stage.setY(stage.getY() * 3f / 2f);
}
Run Code Online (Sandbox Code Playgroud)
更新:我忘了提到; 我事先不知道窗口的大小,所以为了手动居中,我必须首先显示它 - 导致它闪烁一次的原因.所以我正在寻找一种解决方案来集中它而不首先显示它 - 就像Java FX能够做到这一点,但是错误的方式.
在next.config.js- 我添加了使用 SVG 图像所需的配置。
const withCSS = require('@zeit/next-css');
const withSass = require('@zeit/next-sass');
const withImages = require('next-images');
module.exports = withCSS(
withSass(
{
webpack: (config) => config,
distDir: '../_next'
},
withImages({
webpack(config, options) {
return config;
}
})
)
);
Run Code Online (Sandbox Code Playgroud)
这是我的 SVG 文件,位于下一个文件夹下/client/assets/googleIcon.svg。
也许问题出在 SVG 文件中。我没有使用 SVG 的经验,这个 SVG 正确吗?
<svg version="1.1" width="100%" height="100%" viewBox="0 0 25 25">
<g fill="none" fillRule="evenodd">
<path
d="M20.66 12.693c0-.603-.054-1.182-.155-1.738H12.5v3.287h4.575a3.91 3.91 0 0 1-1.697 2.566v2.133h2.747c1.608-1.48 2.535-3.65 2.535-6.24z"
fill="#4285F4"
/>
<path
d="M12.5 21c2.295 0 4.22-.76 …Run Code Online (Sandbox Code Playgroud) 我使用的是全新的 Fedora CoreOS,它附带了 Docker 版本 19.03.11。
我的core用户在docker组中:
[core@localhost ~]$ groups
core adm wheel sudo systemd-journal docker
Run Code Online (Sandbox Code Playgroud)
按照portainer 的部署说明,我创建了一个新的 Portainer 容器,如下所示(如core或root,这根本不重要):
$ docker volume create portainer_data
$ docker run -d -p 9000:9000 -p 8000:8000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
Run Code Online (Sandbox Code Playgroud)
当我尝试连接到本地守护进程时:
权限/var/run/docker.sock:
[core@localhost ~]$ ll /var/run/docker.sock
srw-rw----. 1 root docker 0 Aug 2 10:02 /var/run/docker.sock
Run Code Online (Sandbox Code Playgroud)
即使我也chmod o+rw /var/run/docker.sock行不通。这表明问题可能出在容器本身,因此我尝试访问它,但无法访问:
[core@localhost ~]$ docker exec -it portainer …Run Code Online (Sandbox Code Playgroud) 我在使用 ActiveMQ 时遇到了问题,我发现它很难确定,甚至很难重现,也很难提出具体问题。请多多包涵。
基本上我有:
producer (prioritized messages) -> queue -> consumer
Run Code Online (Sandbox Code Playgroud)
通常,队列中有几条 10 万条消息,每当具有更高优先级的消息到达时,它们首先被消耗。
这工作正常,直到星星对齐并且写入队列的高优先级消息不会被消耗。至少在我打电话Queue.removeMatchingMessages(String selector)从队列中删除消息之前- 哪个和多少都无关紧要。
幸运的是,我发现了一个强有力的指标来说明正在发生的事情。
从我们的 UI 中可以看出,我提交了 444 条优先级 (3) 比其余 (1) 更高的消息,但它们没有被消耗:
使用调试器检查队列,我发现它StoreQueueCursor.pendingCount是 444:
如果我再提交 72 条消息,则待处理计数为 516 (444 + 72):
当我然后使用 删除 72 条消息时Queue.removeMatchingMessages(String selector),StoreQueueCursor.pendingCount变为 0:
我的 444 条消息突然被消耗了:
所以我现在能问的最好的问题是:
它的目的是什么StoreQueueCursor以及它如何导致我的消息被消费?或者更确切地说:为什么这些消息没有写入队列并准备好被消费?
任何帮助深表感谢。
我正在使用org.apache.activemq:activemq-broker:5.15.12(通过 Spring Boot 2.3.1.RELEASE)。
有趣的是,在我所有的高优先级消息都得到处理的“快乐情况”中,pendingCount它远高于 0:
在 ActiveMQ 的如何支持优先队列?它说:
由于消息游标(和客户端)实现了严格的优先级排序,如果消息分派可以从缓存中发生并且不必访问磁盘(即,您的消费者足够快以跟上生产者),则可以遵守严格的优先级排序),或者如果您使用的是永远不必刷新到磁盘的非持久性消息(使用 FilePendingMessageCursor)。但是,一旦遇到消费者速度慢或生产者速度明显加快的情况,您会观察到缓存将填满(可能是优先级较低的消息),而优先级较高的消息会卡在磁盘上,直到它们才可用。重新分页。在这种情况下,您可以决定权衡优化的消息调度以实现优先级实施。您可以禁用缓存,消息过期检查,
所以我尝试像这样禁用缓存(顺便说一下,我已经jms.prefetchPolicy.all=0 …
我希望这段代码抛出ClassCastException:
public class Generics {
public static void main(String[] args) {
method(Integer.class);
}
public static <T> T method(Class<T> t) {
return (T) new String();
}
}
Run Code Online (Sandbox Code Playgroud)
但事实并非如此.将字符串转换为T不会失败,直到我以某种方式使用返回的对象,如:
public class Generics {
public static void main(String[] args) {
method(Integer.class).intValue();
}
public static <T> T method(Class<T> t) {
return (T) new String();
}
}
Run Code Online (Sandbox Code Playgroud)
背景:我创建了一个使用JAXB来解组XML文件的类.它看起来像这样:
public static <T> T unmarshal(File file, Class<? extends T> clazz)
Run Code Online (Sandbox Code Playgroud)
根据root-Element是否为匿名类型,返回T或JAXBElement.当然,JAXBElement不能转换为T.在我的单元测试中,我只调用了unmarshal()而没有对结果做任何事情,一切正常.在Code中,它失败了.
为什么不直接失败?这是一个错误吗?如果没有,我想了解原因.
这听起来可能与“为 JavaFX ImageView 设置最大大小”重复,但它是不同的。
我想限制 ImageView 的最大尺寸。不幸的是,设置 ImageView 大小的唯一方法似乎是 fitWidth 和 fitHeight,但是如果图像小于适合值,则会放大图像。
我尝试将 fitWidth/fitHeight 设置为 0/0 并将 ImageView 包装到设置了 maxWidth 的窗格中 - 没有成功(图像以原始大小显示)。
对我来说,这似乎是 JavaFX 无法实现的,但我不敢相信。但我在网上找不到任何东西。这方面有什么技巧/错误/解决方法吗?
Please save me from going crazy.
No matter how many times I google, I always end up with (usually deprecated) versions of the following code:
IEnumerator setImage(string url) {
Texture2D texture = profileImage.canvasRenderer.GetMaterial().mainTexture as Texture2D;
WWW www = new WWW(url);
yield return www;
Debug.Log("Why on earh is this never called?");
www.LoadImageIntoTexture(texture);
www.Dispose();
www = null;
}
Run Code Online (Sandbox Code Playgroud)
I'm using Unity 5 not 4. The URL I'm trying to load exists. Please shine some light on me.
How do I load an …
在Java 8u51之前,以下工作正常:
<script src="javascript.js"></script>javascript.jsusing中包含的函数webView.getEngine().executeScript()切换到8u60后,它不再有效:
Exception in thread "JavaFX Application Thread" netscape.javascript.JSException: TypeError: undefined is not a function
Run Code Online (Sandbox Code Playgroud)
因此javascript.js不再加载该文件.它从IDE启动时起作用,其中JavaScript文件位于文件系统上.但是,它在应用程序打包时不再有效,因此javascript.js位于JAR文件中.
知道改变了什么以及如何解决这个问题?
我有这个存储库:
@Repository
public class MyRepository {
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
public MyRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
}
void doSomething() {
namedParameterJdbcTemplate.update(...);
}
}
Run Code Online (Sandbox Code Playgroud)
它在 Spring Boot 1.4.5(Spring Core 和 JDBC 4.3.7)中按预期工作。调试时doSomething(),我可以看到 的实例MyRepository 是一个普通对象,并且namedParameterJdbcTemplate已设置。
但是,一旦我更新到 Spring Boot 1.4.6 (Spring Core & JDBC 4.3.8) 或更高版本, 的实例 MyRepository 就是 aMyRepository$$EnhancerBySpringCGLIB并且namedParameterJdbcTemplate是null。我看到它被注入到构造函数中,但是,此时我的存储库尚未增强 CGLIB。
这是为什么?我在4.3.8 版本发行说明中找不到任何提示。
我有一项返回的服务:
WWW-Authenticate: Negotiate, Basic realm="TM1"
Run Code Online (Sandbox Code Playgroud)
由于这不适用于 libcurl,我尝试使用 nginx 来修改这些标头,如下所示:
WWW-Authenticate: Negotiate
WWW-Authenticate: Basic realm="TM1"
Run Code Online (Sandbox Code Playgroud)
我失败的尝试#1:
http {
proxy_intercept_errors on;
server {
listen 10103;
server_name localhost;
location / {
proxy_pass https://tm1server:10103;
proxy_intercept_errors on;
proxy_hide_header WWW-Authenticate;
add_header "Status is" "${status}" always;
if ($status = 401) {
add_header WWW-Authenticate 'Basic realm="TM1"' always;
add_header WWW-Authenticate 'Negotiate' always;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
测试:
$ curl -sv http://localhost:10103/api/v1/Configuration
* Trying 127.0.0.1:10103...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 10103 (#0)
> GET …Run Code Online (Sandbox Code Playgroud) 自从如何更改 GitHub 上的存储库描述?以来,GitHub 的 UI 发生了变化。并且编辑按钮不再存在。另外,我在设置中找不到任何内容。
自 2020 年以来,您如何更改存储库描述?齿轮无法点击。
java ×5
javafx ×2
spring ×2
c# ×1
casting ×1
docker ×1
generics ×1
github ×1
javascript ×1
next-images ×1
next.js ×1
nginx ×1
nginx-config ×1
portainer ×1
reactjs ×1
repository ×1