This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 7337198 CAMEL-13848: Add room password to camel-xmpp. Thanks to Tapio Piironen for the patch. 7337198 is described below commit 7337198fccc417ccd7f4fd7c97616bf54b6c5487 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sat Aug 10 08:12:14 2019 +0200 CAMEL-13848: Add room password to camel-xmpp. Thanks to Tapio Piironen for the patch. --- .../camel-xmpp/src/main/docs/xmpp-component.adoc | 3 +- .../apache/camel/component/xmpp/XmppEndpoint.java | 13 +++++++++ .../component/xmpp/XmppGroupChatProducer.java | 12 ++++---- .../endpoint/dsl/XmppEndpointBuilderFactory.java | 33 ++++++++++++++++++++++ 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/components/camel-xmpp/src/main/docs/xmpp-component.adoc b/components/camel-xmpp/src/main/docs/xmpp-component.adoc index b2b0e8a..895ec9d 100644 --- a/components/camel-xmpp/src/main/docs/xmpp-component.adoc +++ b/components/camel-xmpp/src/main/docs/xmpp-component.adoc @@ -73,7 +73,7 @@ with the following path and query parameters: |=== -=== Query Parameters (20 parameters): +=== Query Parameters (21 parameters): [width="100%",cols="2,5,^1,2",options="header"] @@ -98,6 +98,7 @@ with the following path and query parameters: | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean | *headerFilterStrategy* (filter) | To use a custom HeaderFilterStrategy to filter header to and from Camel message. | | HeaderFilterStrategy | *password* (security) | Password for login | | String +| *roomPassword* (security) | Password for room | | String | *user* (security) | User name (without server name). If not specified, anonymous login will be attempted. | | String |=== // endpoint options: END diff --git a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java index 80bd835..a3d8259 100644 --- a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java +++ b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java @@ -80,6 +80,8 @@ public class XmppEndpoint extends DefaultEndpoint implements HeaderFilterStrateg private boolean createAccount; @UriParam(label = "common") private String room; + @UriParam(label = "security", secret = true) + private String roomPassword; @UriParam(label = "common") private String nickname; @UriParam(label = "common") @@ -370,6 +372,17 @@ public class XmppEndpoint extends DefaultEndpoint implements HeaderFilterStrateg this.room = room; } + /** + * Password for room + */ + public void setRoomPassword(String roomPassword) { + this.roomPassword = roomPassword; + } + + protected String getRoomPassword() { + return roomPassword; + } + public String getParticipant() { // participant is optional so use user if not provided return participant != null ? participant : user; diff --git a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java index ff5de56..6ed7716 100644 --- a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java +++ b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java @@ -48,7 +48,6 @@ public class XmppGroupChatProducer extends DefaultProducer { @Override public void process(Exchange exchange) { - if (connection == null) { try { connection = endpoint.createConnection(); @@ -122,12 +121,15 @@ public class XmppGroupChatProducer extends DefaultProducer { protected synchronized void initializeChat() throws InterruptedException, SmackException, XMPPException, XmppStringprepException { if (chat == null) { room = endpoint.resolveRoom(connection); + String roomPassword = endpoint.getRoomPassword(); MultiUserChatManager chatManager = MultiUserChatManager.getInstanceFor(connection); chat = chatManager.getMultiUserChat(JidCreate.entityBareFrom(room)); - MucEnterConfiguration mucc = chat.getEnterConfigurationBuilder(Resourcepart.from(endpoint.getNickname())) - .requestNoHistory() - .build(); - chat.join(mucc); + MucEnterConfiguration.Builder mucc = chat.getEnterConfigurationBuilder(Resourcepart.from(endpoint.getNickname())) + .requestNoHistory(); + if (roomPassword != null) { + mucc.withPassword(roomPassword); + } + chat.join(mucc.build()); LOG.info("Joined room: {} as: {}", room, endpoint.getNickname()); } } diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/XmppEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/XmppEndpointBuilderFactory.java index 861c720..376a583 100644 --- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/XmppEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/XmppEndpointBuilderFactory.java @@ -296,6 +296,17 @@ public interface XmppEndpointBuilderFactory { return this; } /** + * Password for room. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default XmppEndpointConsumerBuilder roomPassword(String roomPassword) { + setProperty("roomPassword", roomPassword); + return this; + } + /** * User name (without server name). If not specified, anonymous login * will be attempted. * @@ -707,6 +718,17 @@ public interface XmppEndpointBuilderFactory { return this; } /** + * Password for room. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default XmppEndpointProducerBuilder roomPassword(String roomPassword) { + setProperty("roomPassword", roomPassword); + return this; + } + /** * User name (without server name). If not specified, anonymous login * will be attempted. * @@ -1021,6 +1043,17 @@ public interface XmppEndpointBuilderFactory { return this; } /** + * Password for room. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default XmppEndpointBuilder roomPassword(String roomPassword) { + setProperty("roomPassword", roomPassword); + return this; + } + /** * User name (without server name). If not specified, anonymous login * will be attempted. *