我正在尝试使用Smack登录XMPP服务器.尝试登录时,我收到以下错误:
SASL身份验证PLAIN失败:未经授权
我已经能够使用具有相同凭据的PSI-IM连接并登录服务器.
这就是我目前拥有的:
System.setProperty("smack.debugEnabled", "true");
XMPPConnection.DEBUG_ENABLED = true;
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
ConnectionConfiguration configuration = new ConnectionConfiguration("chat.bla.com", 5223);
configuration.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
configuration.setSocketFactory(new DummySSLSocketFactory());
configuration.setSASLAuthenticationEnabled(true);
configuration.setDebuggerEnabled(true);
configuration.setServiceName("bla.net");
Connection connection = new XMPPConnection(configuration);
try {
connection.connect();
connection.login("user@bla.net", "blablabla");
} catch (XMPPException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的DummySSLSocketFactory:http://svn.igniterealtime.org/svn/repos/spark/tags/spark_2_5_3_s/src/java/org/jivesoftware/spark/util/DummySSLSocketFactory.java
我认为问题是我需要在通过PSI连接时选择"Legacy SSL",但我不知道如何在Java中做到这一点.
谢谢你的帮助
我用Thymeleaf使用Spring Boot创建了一个简单的Web应用程序.我使用application.properties文件作为配置.我想要做的是向该文件添加名称和版本等新属性,并访问Thymeleaf的值.
我已经能够通过创建一个新的JavaConfiguration类并暴露一个Spring Bean来实现这一点:
@Configuration
public class ApplicationConfiguration {
@Value("${name}")
private String name;
@Bean
public String name() {
return name;
}
}
Run Code Online (Sandbox Code Playgroud)
我可以使用Thymeleaf在模板中显示它,如下所示:
<span th:text="${@name}"></span>
Run Code Online (Sandbox Code Playgroud)
这对我来说似乎过于冗长和复杂.实现这一目标的更优雅方式是什么?
如果可能的话,我想避免使用xml配置.
我有一个表单,让我可以编辑一个bean列表(一次一个),使用我可以在bean之间切换的按钮.
保持简单:
public class MyBean {
private String text;
}
public class MyController {
private List<MyBean> availableBeans = new ArrayList<MyBean>(); // has five MyBeans with random text
private MyBean selectedBean; // initialized with first element of list
private int index = 0;
public void nextBean() { index++; }
public void previousBean() { index--; }
private void refreshBean() { selectedBean = availableBeans.get(index); }
}
Run Code Online (Sandbox Code Playgroud)
对于html部分,我有类似的东西
<h:form id="someForm">
<!-- stuff -->
<p:inputText value="#{myController.selectedBean.text}" />
<p:inplace editor="true" label="#{myController.selectedBean.text}" >
<p:inputText value="#{myController.selectedBean.text}" />
</p:inplace> …Run Code Online (Sandbox Code Playgroud)