小编Shi*_*ami的帖子

尝试使用Smack登录XMPP服务器导致SASL"未授权"

我正在尝试使用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中做到这一点.

谢谢你的帮助

java xmpp sasl smack

9
推荐指数
1
解决办法
1万
查看次数

在Spring Expression Language中访问属性文件

我用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配置.

java spring thymeleaf spring-boot

6
推荐指数
1
解决办法
1万
查看次数

<p:inputText>值在更改时未在模型中更新

我有一个表单,让我可以编辑一个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)

jsf in-place-editor primefaces

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×2

in-place-editor ×1

jsf ×1

primefaces ×1

sasl ×1

smack ×1

spring ×1

spring-boot ×1

thymeleaf ×1

xmpp ×1