From: <st...@us...> - 2006-10-07 22:35:32
|
Revision: 3465 http://svn.sourceforge.net/smartfrog/?rev=3465&view=rev Author: steve_l Date: 2006-10-07 15:33:43 -0700 (Sat, 07 Oct 2006) Log Message: ----------- client works Modified Paths: -------------- trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/AbstractXmppPrim.java trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/Xmpp.java trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/XmppClient.java trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/XmppClientImpl.java trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/components.sf Added Paths: ----------- trunk/core/components/xmpp/test/files/ trunk/core/components/xmpp/test/files/gmail_smartfrog_to_smartfrog.sf Modified: trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/AbstractXmppPrim.java =================================================================== --- trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/AbstractXmppPrim.java 2006-10-07 21:13:38 UTC (rev 3464) +++ trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/AbstractXmppPrim.java 2006-10-07 22:33:43 UTC (rev 3465) @@ -34,7 +34,7 @@ private String server, login, password, resource, serviceName; private int port; - private boolean presence, useTLS; + private boolean presence, requireEncryption,useTLS; protected AbstractXmppPrim() throws RemoteException { } @@ -57,6 +57,7 @@ password = sfResolve(ATTR_PASSWORD, password, true); port = sfResolve(ATTR_PORT, port, true); presence = sfResolve(ATTR_PRESENCE, presence, true); + requireEncryption = sfResolve(ATTR_REQUIRE_ENCRYPTION, requireEncryption, true); resource = sfResolve(ATTR_RESOURCE, resource, true); useTLS = sfResolve(ATTR_USE_TLS, useTLS, true); } @@ -120,8 +121,8 @@ */ public XMPPConnection login() throws SmartFrogException { XMPPConnection connection = null; - String connectionInfo = "connecting to " + server + ":" + port + - " as " + login; + String serverInfo= server + ":" + port + " as " + login; + String connectionInfo = "connecting to " + serverInfo; sfLog().debug(connectionInfo); try { if (useTLS) { @@ -130,6 +131,10 @@ connection = new XMPPConnection(server, port, serviceName); } connection.login(login, password, resource, presence); + //check the encryption status + if(requireEncryption && !connection.isSecureConnection()) { + throw new SmartFrogException("Failed to set up a secure connection to "+ serverInfo); + } return connection; } catch (XMPPException e) { if (connection != null) { Modified: trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/Xmpp.java =================================================================== --- trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/Xmpp.java 2006-10-07 21:13:38 UTC (rev 3464) +++ trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/Xmpp.java 2006-10-07 22:33:43 UTC (rev 3465) @@ -51,8 +51,13 @@ * should presence information be provided. {@value} */ String ATTR_PRESENCE = "presence"; - /** + * should we require an encrypted connection + * -that is, fail if the connection negotiated is not secured. + * {@value} + */ + String ATTR_REQUIRE_ENCRYPTION="requireEncryption"; + /** * resource for the login. {@value} */ String ATTR_RESOURCE = "resource"; Modified: trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/XmppClient.java =================================================================== --- trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/XmppClient.java 2006-10-07 21:13:38 UTC (rev 3464) +++ trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/XmppClient.java 2006-10-07 22:33:43 UTC (rev 3465) @@ -31,7 +31,7 @@ /** * username for the message or any other unaddressed messages. {@value} */ - String ATTR_DESTINATION = "destination"; + String ATTR_DESTINATION = "to"; /** * a message to send when this component starts. {@value} */ Modified: trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/XmppClientImpl.java =================================================================== --- trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/XmppClientImpl.java 2006-10-07 21:13:38 UTC (rev 3464) +++ trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/XmppClientImpl.java 2006-10-07 22:33:43 UTC (rev 3465) @@ -95,16 +95,19 @@ throw new SmartFrogRuntimeException("No recipient for XMPP message"); } try { - XMPPConnection connection = null; + XMPPConnection connection; connection = login(); try { Message m = new Message(recipient); m.setBody(text); m.setType(Message.Type.NORMAL); connection.sendPacket(m); - connection.close(); } finally { - connection.close(); + try { + connection.close(); + } catch (IllegalStateException e) { + sfLog().ignore("when closing a connection",e); + } } } catch (IllegalStateException e) { //smack uses IllegalStateException for signalling problems Modified: trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/components.sf =================================================================== --- trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/components.sf 2006-10-07 21:13:38 UTC (rev 3464) +++ trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/components.sf 2006-10-07 22:33:43 UTC (rev 3465) @@ -40,10 +40,10 @@ description "name of the service when different from the server name"; } login extends String { - description "user name for logins"; + description "user name for logins, no @domain suffix"; } useTLS extends Boolean { - description "should a (legacy) TLS encrypted channel be used" + description "should a (legacy) TLS encrypted channel be used"; } password extends String { description "password for logins"; @@ -54,26 +54,36 @@ presence extends Boolean { description "should presence information be provided"; } + requireEncryption extends Boolean { + description ##should we require an encrypted connection + -that is, fail if the connection negotiated is not secured + #; + } resource extends String { description "resource for the login"; } } -/** - * listens for new messages - */ - -XmppListener extends Prim { +XmppComponent extends Prim { xmppSchema extends XmppSchema; - server TBD; - serviceName server; + serviceName LAZY server; port 5222; + requireEncryption true; resource "SmartFrog"; presence false; useTLS false; } /** + * listens for new messages + */ + +XmppListener extends XmppComponent { + sfClass "org.smartfrog.services.xmpp.XmppListenerImpl"; + presence true; +} + +/** * this component can be used in workflows; it will then terminate after sending * its message. * if deployed non-terminating, it can be used to send messages to either the default destination, @@ -81,38 +91,51 @@ */ -XmppClientSchema extends XmppSchema { - destination extends OptionalString { +XmppClientSchema extends Schema { + to extends OptionalString { description "username for the message or any other unaddressed messages"; } message extends OptionalString { - description "a message to send when this component starts" + description "a message to send when this component starts"; } } -XmppClient extends Prim { +XmppClient extends XmppComponent { xmppClientSchema extends XmppClientSchema; - port 5222; - resource "SmartFrog"; - presence false; sfClass "org.smartfrog.services.xmpp.XmppClientImpl"; } /** + * workflow variant + */ +XmppClientWorkflow extends XmppClient { + sfShouldTerminate true; +} + +/** * binding to google chat */ GoogleChatClient extends XmppClient { server "talk.google.com"; - serviceName "google.com" + serviceName "gmail.com"; } +GoogleChatClientWorkflow extends GoogleChatClient { + sfShouldTerminate true; +} + + /** - * binding to google chat + * binding to jabber.org */ JabberClient extends XmppClient { server "jabber.org"; } +JabberClientWorkflow extends JabberClient { + sfShouldTerminate true; +} + /** Note that setting the system property smack.debugEnabled to true turns debugging on for all components. This system properties component can be deployed @@ -124,5 +147,13 @@ XmppDebugging extends SystemProperties { debug true; - properties ["smack.debugEnabled",debug]; - } \ No newline at end of file + setOnStartup true; + setOnDeploy false; + properties [["smack.debugEnabled",debug]]; + } + + +XmppDebuggingWorkflow extends XmppDebugging { + sfShouldTerminate true; + unsetOnTerminate false; +} \ No newline at end of file Added: trunk/core/components/xmpp/test/files/gmail_smartfrog_to_smartfrog.sf =================================================================== --- trunk/core/components/xmpp/test/files/gmail_smartfrog_to_smartfrog.sf (rev 0) +++ trunk/core/components/xmpp/test/files/gmail_smartfrog_to_smartfrog.sf 2006-10-07 22:33:43 UTC (rev 3465) @@ -0,0 +1,40 @@ +/** (C) Copyright 2006 Hewlett-Packard Development Company, LP + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For more information: www.smartfrog.org + + */ + +#include "/org/smartfrog/services/xmpp/components.sf" +#include "/org/smartfrog/sfcore/workflow/components.sf" + +sfConfig extends Sequence { + + debug extends XmppDebugging { + sfShouldTerminate true; + unsetOnTerminate false; + } + + post extends GoogleChatClientWorkflow { + to "ste...@gm..."; + login "smartfrog.one"; + password PROPERTY xmpp.password; + message "hello, world"; + } + + + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |