Browse files

remove xmpp-account-info.xml - read mybuddy from mongo

  • Loading branch information...
1 parent 9fd22e7 commit e07500b9762cfc3fef048c383f137d3d00dd9340 @mirceac mirceac committed Sep 28, 2012
View
14 sipXcommons/src/main/java/org/sipfoundry/commons/userdb/ValidUsers.java
@@ -392,11 +392,23 @@ private UserGroup convertUserGroup(DBObject groupResult) {
}
public String getImBotName() {
+ User imbotUser = getImbotUser();
+ if (imbotUser != null) {
+ return imbotUser.getUserName();
+ }
+ return null;
+ }
+
+ public User getImbotUser() {
DBObject queryImbot = QueryBuilder.start(ENTITY_NAME).is(ENTITY_NAME_IMBOTSETTINGS).and(IM_ENABLED).is(true).get();
DBObject imbotResult = getEntityCollection().findOne(queryImbot);
if (imbotResult != null) {
- return getStringValue(imbotResult, IM_ID);
+ User imbotUser = new User();
+ imbotUser.setUserName(getStringValue(imbotResult, IM_ID));
+ imbotUser.setPintoken(getStringValue(imbotResult, PINTOKEN));
+ return imbotUser;
}
+
return null;
}
View
16 sipXimbot/etc/sipximbot.cf
@@ -23,13 +23,7 @@ bundle agent sipximbot {
"any" usebundle => "sipximbot_running";
}
-bundle agent sipximbot_config {
- vars:
- any::
- "xml_file_norestart" slist => {
- "xmpp-account-info.xml"
- };
-
+bundle agent sipximbot_config {
files:
any::
"$(sipx.SIPX_CONFDIR)/sipximbot.properties"
@@ -38,14 +32,6 @@ bundle agent sipximbot_config {
perms => m("644"),
edit_line => sipximbot_properties_contents,
classes => if_repaired("restart_sipximbot");
-
- any::
- "$(sipx.SIPX_CONFDIR)/$(xml_file_norestart)"
- comment => "install imbot config $(this.promiser)",
- create => "true",
- perms => m("644"),
- copy_from => copy_from_cfdata("$(sipx.location_id)/$(xml_file_norestart)");
-
}
bundle edit_line sipximbot_properties_contents {
View
7 sipXopenfire/config-plugin/sipxplugin.beans.xml
@@ -33,7 +33,6 @@
<bean id="openfireConfiguration" class="org.sipfoundry.sipxconfig.openfire.OpenfireConfiguration">
<property name="config" ref="openfireXml"/>
<property name="sipxConfig" ref="openfireSipxXml"/>
- <property name="accountConfig" ref="openfireAccountXml"/>
<property name="ldapManager" ref="ldapManager"/>
<property name="configManager" ref="configManager"/>
<property name="featureManager" ref="featureManager"/>
@@ -68,11 +67,5 @@
<property name="serviceInterface" value="org.sipfoundry.sipxconfig.openfire.OpenfireApi" />
</bean>
- <bean id="openfireAccountXml" class="org.sipfoundry.sipxconfig.openfire.XmppAccountInfo">
- <property name="coreContext" ref="coreContext" />
- <property name="validUsers" ref="validUsers" />
- <property name="imbot" ref="imBot" />
- </bean>
-
<bean id="imFeatureHook" class="org.sipfoundry.sipxconfig.web.plugin.IMFeatureHook" />
</beans>
View
13 sipXopenfire/config-plugin/src/org/sipfoundry/sipxconfig/openfire/OpenfireConfiguration.java
@@ -48,7 +48,6 @@
public class OpenfireConfiguration implements ConfigProvider, DaoEventListener {
private OpenfireConfigurationFile m_config;
private SipxOpenfireConfiguration m_sipxConfig;
- private XmppAccountInfo m_accountConfig;
private LdapManager m_ldapManager;
private ConfigManager m_configManager;
private FeatureManager m_featureManager;
@@ -110,14 +109,6 @@ public void replicate(ConfigManager manager, ConfigRequest request) throws IOExc
IOUtils.closeQuietly(openfire);
}
- Writer account = new FileWriter(new File(dir, "xmpp-account-info.xml"));
- try {
- XmlFile config = new XmlFile(account);
- config.write(m_accountConfig.getDocument());
- } finally {
- IOUtils.closeQuietly(account);
- }
-
Writer ofproperty = new FileWriter(new File(dir, "ofproperty.yaml"));
try {
writeOfPropertyConfig(ofproperty, m_openfire.getSettings());
@@ -186,10 +177,6 @@ public void onSave(Object entity) {
checkReplicate(entity);
}
- public void setAccountConfig(XmppAccountInfo accountConfig) {
- m_accountConfig = accountConfig;
- }
-
public void setConfigManager(ConfigManager configManager) {
m_configManager = configManager;
}
View
89 sipXopenfire/config-plugin/src/org/sipfoundry/sipxconfig/openfire/XmppAccountInfo.java
@@ -1,89 +0,0 @@
-/*
- *
- *
- * Copyright (C) 2009 Nortel, certain elements licensed under a Contributor Agreement.
- * Contributors retain copyright to elements licensed under a Contributor Agreement.
- * Licensed to the User under the LGPL license.
- *
- *
- */
-package org.sipfoundry.sipxconfig.openfire;
-
-import org.dom4j.Document;
-import org.dom4j.Element;
-import org.sipfoundry.commons.userdb.ValidUsers;
-import org.sipfoundry.sipxconfig.common.CoreContext;
-import org.sipfoundry.sipxconfig.common.User;
-import org.sipfoundry.sipxconfig.dialplan.config.XmlFile;
-import org.sipfoundry.sipxconfig.im.ImAccount;
-import org.sipfoundry.sipxconfig.imbot.ImBot;
-import org.sipfoundry.sipxconfig.imbot.ImBotSettings;
-
-public class XmppAccountInfo {
- private static final String NAMESPACE = "http://www.sipfoundry.org/sipX/schema/xml/xmpp-account-info-00-00";
- private static final String USER = "user";
- private static final String USER_NAME = "user-name";
- private static final String PASSWORD = "password";
- private static final String DISPLAY_NAME = "display-name";
-
- private CoreContext m_coreContext;
- private ValidUsers m_validUsers;
- private ImBot m_imbot;
-
- public Document getDocument() {
- ImBotSettings imbotSettings = m_imbot.getSettings();
- Document document = XmlFile.FACTORY.createDocument();
- final Element accountInfos = document.addElement("xmpp-account-info", NAMESPACE);
-
- createPaUserAccount(accountInfos, imbotSettings);
-
- return document;
- }
-
- private void createPaUserAccount(Element accountInfos, ImBotSettings imbotSettings) {
- String paUserName = imbotSettings.getPersonalAssistantImId();
- String paPassword = imbotSettings.getPersonalAssistantImPassword();
-
- User paUser = m_coreContext.newUser();
- paUser.setUserName(paUserName);
- ImAccount imAccount = new ImAccount(paUser);
- imAccount.setEnabled(true);
-
- createUserAccount(paUser, accountInfos, paPassword);
- }
-
- private void createUserAccount(User user, Element accountInfos, String paPassword) {
- ImAccount imAccount = new ImAccount(user);
- if (!imAccount.isEnabled()) {
- return;
- }
-
- Element userAccounts = accountInfos.addElement(USER);
- userAccounts.addElement(USER_NAME).setText(imAccount.getImId());
- userAccounts.addElement("sip-user-name").setText(user.getName());
- userAccounts.addElement(DISPLAY_NAME).setText(imAccount.getImDisplayName());
- userAccounts.addElement(PASSWORD).setText(paPassword);
- String email = imAccount.getEmailAddress();
- userAccounts.addElement("email").setText(email != null ? email : "");
- userAccounts.addElement("on-the-phone-message").setText(imAccount.getOnThePhoneMessage());
- userAccounts.addElement("advertise-on-call-status").setText(
- Boolean.toString(imAccount.advertiseSipPresence()));
- userAccounts.addElement("show-on-call-details").setText(Boolean.toString(imAccount.includeCallInfo()));
- }
-
- public ValidUsers getValidUsers() {
- return m_validUsers;
- }
-
- public void setValidUsers(ValidUsers validUsers) {
- m_validUsers = validUsers;
- }
-
- public void setCoreContext(CoreContext coreContext) {
- m_coreContext = coreContext;
- }
-
- public void setImbot(ImBot imbot) {
- m_imbot = imbot;
- }
-}
View
247 sipXopenfire/config-plugin/test/org/sipfoundry/sipxconfig/openfire/XmppAccountInfoTest.java
@@ -1,247 +0,0 @@
-/*
- *
- *
- * Copyright (C) 2009 Nortel, certain elements licensed under a Contributor Agreement.
- * Contributors retain copyright to elements licensed under a Contributor Agreement.
- * Licensed to the User under the LGPL license.
- *
- *
- */
-package org.sipfoundry.sipxconfig.openfire;
-
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import static java.util.Arrays.asList;
-import static java.util.Collections.emptyList;
-
-import junit.framework.TestCase;
-import org.apache.commons.io.IOUtils;
-import org.dom4j.Document;
-import org.sipfoundry.sipxconfig.TestHelper;
-import org.sipfoundry.sipxconfig.admin.commserver.Location;
-import org.sipfoundry.sipxconfig.admin.commserver.LocationsManager;
-import org.sipfoundry.sipxconfig.common.CoreContext;
-import org.sipfoundry.sipxconfig.common.DaoUtils;
-import org.sipfoundry.sipxconfig.common.User;
-import org.sipfoundry.sipxconfig.conference.Bridge;
-import org.sipfoundry.sipxconfig.conference.Conference;
-import org.sipfoundry.sipxconfig.conference.ConferenceBridgeContext;
-import org.sipfoundry.sipxconfig.permission.PermissionManagerImpl;
-import org.sipfoundry.sipxconfig.service.SipxImbotService;
-import org.sipfoundry.sipxconfig.service.SipxServiceManager;
-import org.sipfoundry.sipxconfig.setting.Group;
-import org.sipfoundry.sipxconfig.setting.ModelFilesContext;
-import org.sipfoundry.sipxconfig.test.TestUtil;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.sipfoundry.sipxconfig.test.TestUtil.getModelDirectory;
-
-public class XmppAccountInfoTest extends TestCase {
- private List<User> m_users;
- private List<Group> m_groups;
- private List<Conference> m_conferences;
- private User m_userOne;
- private User m_userTwo;
- private User m_userThree;
- private User m_userFour;
- private User m_userFive;
- private Group m_group1;
- private Group m_group2;
- private Group m_group3;
- private Group m_group4;
- private ModelFilesContext m_neoconfModelFilesContext;
- private PermissionManagerImpl m_pm;
- private LocationsManager m_locationsManager;
- private SipxImbotService m_sipxImbotService = new SipxImbotService();
-
-
- @Override
- protected void setUp() throws Exception {
- m_neoconfModelFilesContext = TestHelper.getModelFilesContext(getModelDirectory("neoconf"));
- Location location = new Location();
- location.setAddress("192.168.1.2");
- location.setFqdn("puppy.org");
-
- m_locationsManager = createMock(LocationsManager.class);
- m_locationsManager.getLocationsForService(m_sipxImbotService);
- expectLastCall().andReturn(Arrays.asList(location)).anyTimes();
-
- replay(m_locationsManager);
-
- m_sipxImbotService.setLocationsManager(m_locationsManager);
-
- m_pm = new PermissionManagerImpl();
- m_pm.setModelFilesContext(m_neoconfModelFilesContext);
-
- m_group1 = new ImGroup(true, true, true);
- m_group1.setName("group1");
- m_group1.setDescription("my group");
-
- // m_group2 im-group is enabled, im-account is disabled
- m_group2 = new ImGroup(true, false, true);
- m_group2.setName("group2");
- m_group2.setDescription("empty IM group");
-
- // the following group won't be replicated
- m_group3 = new Group();
-
- // m_group4 im-group is disabled, im-account is enabled
- m_group4 = new ImGroup(false, true, false);
- m_group4.setName("group4");
- m_group4.setDescription("NO IM group");
-
- m_groups = asList(m_group1, m_group2, m_group3, m_group4);
-
- m_userOne = new User();
- m_userOne.setPermissionManager(m_pm);
- m_userOne.addGroup(m_group1);
- m_userOne.addGroup(m_group3);
- m_userOne.setSettingTypedValue("im/on-the-phone-message", "testing phone message");
- m_userOne.setSettingTypedValue("im/advertise-sip-presence", true);
- m_userOne.setUserName("One");
- m_userOne.setImId("One_IM");
- m_userOne.setImDisplayName("One_IM_DisplayName");
- m_userOne.setEmailAddress("one@puppy.org");
-
- m_userTwo = new User();
- m_userTwo.setPermissionManager(m_pm);
- m_userTwo.addGroup(m_group2);
- m_userTwo.setUserName("Two");
- m_userTwo.setImDisplayName("Two_IM_DisplayName");
- m_userTwo.setEmailAddress("two@puppy.org");
-
- m_userThree = new User();
- m_userThree.setPermissionManager(m_pm);
- m_userThree.setSettingTypedValue("im/im-account", true);
- m_userThree.setSettingTypedValue("im/on-the-phone-message", "");
- m_userThree.setSettingTypedValue("im/advertise-sip-presence", true);
- m_userThree.setSettingTypedValue("im/include-call-info", true);
- m_userThree.setUserName("Three");
- m_userThree.setImPassword("bongoImPassword");
- m_userThree.setEmailAddress("three@puppy.org");
-
- m_userFour = new User();
- m_userFour.setPermissionManager(m_pm);
- m_userFour.addGroup(m_group1);
- m_userFour.addGroup(m_group4);
- m_userFour.setUserName("Four");
- m_userFour.setImDisplayName("Four_IM_DisplayName");
-
- m_userFive = new User();
- m_userFive.setPermissionManager(m_pm);
- m_userFive.addGroup(m_group4);
- m_userFive.setUserName("Five");
- m_userFive.setFirstName("Five_DisplayName");
-
- m_users = new ArrayList<User>();
- m_users.addAll(asList(m_userOne, m_userTwo, m_userThree, m_userFour, m_userFive));
-
- Bridge mockBridge = new Bridge() {
- @Override
- public String getHost() {
- return "servicename.domain.com";
- }
- };
-
- Conference conf1 = new Conference();
- conf1.setModelFilesContext(m_neoconfModelFilesContext);
- conf1.setBridge(mockBridge);
- conf1.setSettingTypedValue("fs-conf-conference/participant-code", "123");
- conf1.setEnabled(true);
- conf1.setName("conf1");
- conf1.setDescription("Description");
- conf1.setExtension("300");
- conf1.setSettingTypedValue("chat-meeting/moderated", true);
- conf1.setOwner(m_userOne);
-
- Conference conf2 = new Conference();
-
- Conference conf3 = new Conference();
- conf3.setModelFilesContext(m_neoconfModelFilesContext);
- conf3.setBridge(mockBridge);
- conf3.setEnabled(true);
- conf3.setName("conf3");
- conf3.setDescription("Description 3");
- conf3.setExtension("300");
- conf3.setSettingTypedValue("chat-meeting/moderated", false);
- conf3.setOwner(m_userThree);
-
- m_conferences = asList(conf1, conf2, conf3);
-
- }
-
- public void testGenerate() throws Exception {
- CoreContext coreContext = createMock(CoreContext.class);
-
- coreContext.loadUsersByPage(0, DaoUtils.PAGE_SIZE);
- expectLastCall().andReturn(m_users).atLeastOnce();
- coreContext.getGroups();
- expectLastCall().andReturn(m_groups);
- coreContext.getGroupMembers(m_group1);
- expectLastCall().andReturn(asList(m_userOne, m_userTwo, m_userFour)).once();
- coreContext.getGroupMembers(m_group2);
- expectLastCall().andReturn(asList(m_userTwo)).once();
- coreContext.getGroupMembers(m_group3);
- expectLastCall().andReturn(emptyList()).once();
- coreContext.getGroupMembers(m_group4);
- expectLastCall().andReturn(asList(m_userFour, m_userFive)).once();
- User paUser = new User();
- paUser.setPermissionManager(m_pm);
- coreContext.newUser();
- expectLastCall().andReturn(paUser);
- replay(coreContext);
-
- ConferenceBridgeContext m_conferenceContext = createMock(ConferenceBridgeContext.class);
-
- m_conferenceContext.getAllConferences();
- expectLastCall().andReturn(m_conferences).atLeastOnce();
- replay(m_conferenceContext);
-
- m_sipxImbotService.setBeanName(SipxImbotService.BEAN_ID);
- m_sipxImbotService.setModelDir("sipximbot");
- m_sipxImbotService.setModelName("sipximbot.xml");
- m_sipxImbotService.setModelFilesContext(m_neoconfModelFilesContext);
- m_sipxImbotService.setSettingValue("imbot/imId", "MyAssistant");
- m_sipxImbotService.setSettingValue("imbot/imPassword", "password");
-
- SipxServiceManager m_sipxServiceManager = createMock(SipxServiceManager.class);
- m_sipxServiceManager.getServiceByBeanId(SipxImbotService.BEAN_ID);
- expectLastCall().andReturn(m_sipxImbotService).atLeastOnce();
- replay(m_sipxServiceManager);
-
- paUser.setSipxImbotService(m_sipxImbotService);
-
- XmppAccountInfo xmppAccountInfo = new XmppAccountInfo();
- xmppAccountInfo.setCoreContext(coreContext);
- xmppAccountInfo.setConferenceBridgeContext(m_conferenceContext);
- xmppAccountInfo.setSipxServiceManager(m_sipxServiceManager);
-
- Document document = xmppAccountInfo.getDocument();
- String domDoc = TestUtil.asString(document);
-
- InputStream referenceXml = XmppAccountInfoTest.class.getResourceAsStream("xmpp-account-info.test.xml");
- assertEquals(IOUtils.toString(referenceXml), domDoc);
- }
-
- private class ImGroup extends Group {
- public ImGroup(boolean imGroup, boolean imAccount, boolean addPaToGroup) {
- HashMap<String, String> values = new HashMap<String, String>();
- if (imGroup) {
- values.put("im/im-group", "1");
- if (addPaToGroup) {
- values.put("im/add-pa-to-group", "1");
- }
- }
- if (imAccount) {
- values.put("im/im-account", "1");
- }
- setDatabaseValues(values);
- }
- }
-}
View
58 ...openfire/config-plugin/test/org/sipfoundry/sipxconfig/openfire/xmpp-account-info.test.xml
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<xmpp-account-info xmlns="http://www.sipfoundry.org/sipX/schema/xml/xmpp-account-info-00-00">
- <user>
- <user-name>MyAssistant</user-name>
- <sip-user-name>MyAssistant</sip-user-name>
- <display-name>MyAssistant</display-name>
- <password>password</password>
- <email></email>
- <on-the-phone-message>On the phone</on-the-phone-message>
- <advertise-on-call-status>true</advertise-on-call-status>
- <show-on-call-details>false</show-on-call-details>
- </user>
- <group>
- <group-name>group1</group-name>
- <description>my group</description>
- <user>
- <user-name>One_IM</user-name>
- </user>
- <user>
- <user-name>Four</user-name>
- </user>
- <user>
- <user-name>MyAssistant</user-name>
- </user>
- </group>
- <group>
- <group-name>group2</group-name>
- <description>empty IM group</description>
- <user>
- <user-name>MyAssistant</user-name>
- </user>
- </group>
- <chat-room>
- <subdomain>conference</subdomain>
- <room-owner>One_IM</room-owner>
- <room-name>conf1</room-name>
- <description>Description</description>
- <password>123</password>
- <moderated>true</moderated>
- <is-public-room>true</is-public-room>
- <is-members-only>false</is-members-only>
- <is-persistent>true</is-persistent>
- <conference-extension>300</conference-extension>
- </chat-room>
- <chat-room>
- <subdomain>conference</subdomain>
- <room-owner>Three</room-owner>
- <room-name>conf3</room-name>
- <description>Description 3</description>
- <password></password>
- <moderated>false</moderated>
- <is-public-room>true</is-public-room>
- <is-members-only>false</is-members-only>
- <is-persistent>true</is-persistent>
- <conference-extension>300</conference-extension>
- </chat-room>
-</xmpp-account-info>
View
324 sipXopenfire/etc/schema/xmpp-account-info.xsd
@@ -1,324 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.sipfoundry.org/xmpp-account-info/" targetNamespace="http://www.sipfoundry.org/xmpp-account-info/">
- <element name="xmpp-account-info" type="tns:XmppAccountInfo"></element>
-
- <complexType name="XmppUserAccount">
- <sequence>
- <element name="user-name" type="string" minOccurs="1"
- maxOccurs="1">
- <annotation>
- <documentation>
- The xmpp user name (does not include domain).
- </documentation>
- </annotation>
- </element>
- <element name="sip-user-name" type="string" minOccurs="1"
- maxOccurs="1">
- <annotation>
- <documentation>
- SIP user name (does not include domain). Domain
- is the same as the XMPP domain.
- </documentation>
- </annotation>
- </element>
- <element name="display-name" type="string" minOccurs="1"
- maxOccurs="1">
- <annotation>
- <documentation>Xmpp display name.</documentation>
- </annotation>
- </element>
- <element name="password" type="string" minOccurs="1"
- maxOccurs="1">
- <annotation>
- <documentation>xmpp account password</documentation>
- </annotation>
- </element>
- <element name="email" type="string" minOccurs="1"
- maxOccurs="1">
- <annotation>
- <documentation>xmpp email address</documentation>
- </annotation>
- </element>
- <element name="on-the-phone-message" type="string"
- minOccurs="1" maxOccurs="1">
- <annotation>
- <documentation>
- on the phone message. This is shown to the
- buddies of this account when user is on the
- phone. This should be settable from the user
- portal of the user.
-
- </documentation>
- </annotation>
- </element>
- <element name="advertise-on-call-status" type="boolean"
- minOccurs="1" maxOccurs="1">
- <annotation>
- <documentation>
- Dictates whether or not the sipXopenfire plugin will make available the
- SIP status information about the user
- </documentation>
- </annotation>
- </element>
- <element name="show-on-call-details" type="boolean"
- minOccurs="1" maxOccurs="1">
- <annotation>
- <documentation>
- When user is on the phone and advertise-on-call-status is true, this dictates
- whether or not the sipXopenfire plugin will make available the
- information about the other call party
- </documentation>
- </annotation>
- </element>
- </sequence>
- </complexType>
-
- <complexType name="XmppGroup">
- <sequence>
- <element name="group-name" type="string" minOccurs="1" maxOccurs="1">
- <annotation>
- <documentation>The xmpp group name.</documentation>
- </annotation>
- </element>
- <element name="administrator" type="string" minOccurs="0" maxOccurs="1">
- <annotation>
- <documentation>The xmpp group administrator.</documentation>
- </annotation>
- </element>
- <element name="description" type="string" minOccurs="0" maxOccurs="1">
- <annotation>
- <documentation>
- Xmpp group description.
- </documentation>
- </annotation>
- </element>
- <element name="user" type="tns:XmppGroupMember" minOccurs="0" maxOccurs="unbounded">
- <annotation>
- <documentation>Group member.</documentation>
- </annotation>
- </element>
- </sequence>
- </complexType>
-
- <complexType name="XmppChatRoom">
- <sequence>
- <element name="subdomain" type="string" maxOccurs="1" minOccurs="1" >
- <annotation>
- <documentation>
- Chat server subdomain.
- </documentation>
- </annotation>
- </element>
- <element name="room-owner" type="string" maxOccurs="1" minOccurs="1" >
- <annotation>
- <documentation>
- This should be the xmpp user name of the user that is set in his
- user profile in sipx. Users with no xmpp id must not create rooms.
- </documentation>
- </annotation>
- </element>
- <element name="room-name" type="string" maxOccurs="1" minOccurs="1" >
- <annotation>
- <documentation>
- Chat room name.
- </documentation>
- </annotation>
- </element>
- <element name="description" type="string" maxOccurs="1" minOccurs="0" default="">
- <annotation>
- <documentation>
- Chat room description.
- </documentation>
- </annotation>
- </element>
- <element name="password" type="string" maxOccurs="1" minOccurs="0" default="">
- <annotation>
- <documentation>
- Chat room password.
- </documentation>
- </annotation>
- </element>
- <element name="moderated" type="boolean" maxOccurs="1" minOccurs="0" default="false">
- <annotation>
- <documentation>
- Is chat room moderated.
- </documentation>
- </annotation>
- </element>
- <element name="is-public-room" type="boolean" maxOccurs="1" minOccurs="0" default="true">
- <annotation>
- <documentation>
- Is chat room public, i.e. it is listed in the directory.
- </documentation>
- </annotation>
- </element>
- <element name="is-members-only" type="boolean" maxOccurs="1" minOccurs="0" default="false">
- <annotation>
- <documentation>
- Is chat room members only.
- </documentation>
- </annotation>
- </element>
- <element name="is-persistent" type="boolean" maxOccurs="1" minOccurs="0" default="true">
- <annotation>
- <documentation>
- Is chat room persistent.
- </documentation>
- </annotation>
- </element>
- <element name="log-room-conversations" type="boolean" maxOccurs="1" minOccurs="0" default="true">
- <annotation>
- <documentation>
- Is chat logged.
- </documentation>
- </annotation>
- </element>
- <element name="conference-extension" type="string" maxOccurs="1" minOccurs="0">
- <annotation>
- <documentation>
- SipX conference extension. Should be assigned to the
- administrator.
- </documentation>
- </annotation>
- </element>
- <element name="conference-reach-info" type="string" maxOccurs="1" minOccurs="0">
- <annotation>
- <documentation>
- String describing how to reach the audio conference from a phone that is not on the system, e.g. a PSTN phone
- </documentation>
- </annotation>
- </element>
- <element name="password" type="string" maxOccurs="1" minOccurs="0">
- <annotation>
- <documentation>
- PIN required to enter conference and IM Chatroom.
- </documentation>
- </annotation>
- </element>
- </sequence>
- </complexType>
-
- <complexType name="ServerList">
- <sequence>
- <element name="host" type="string" maxOccurs="1" minOccurs="1" default="">
- <annotation>
- <documentation>
- IP address of FQDN of the server
- </documentation>
- </annotation>
- </element>
- <element name="port" maxOccurs="1" minOccurs="1" default="5269">
- <annotation>
- <documentation>
- Port number of server
- </documentation>
- </annotation>
- <simpleType>
- <restriction base='integer'>
- <minInclusive value='1024'/>
- <maxInclusive value='65535'/>
- </restriction>
- </simpleType>
- </element>
- </sequence>
- </complexType>
-
- <complexType name="XmppServerToServer">
- <sequence>
- <element name="enabled" type="boolean" maxOccurs="1" minOccurs="1" default="false">
- <annotation>
- <documentation>
- Is Server-to-server functionality turned on?
- </documentation>
- </annotation>
- </element>
-
- <element name="port" maxOccurs="1" minOccurs="1" default="5269">
- <annotation>
- <documentation>
- Port number used by openfire for server-to-server connections.
- </documentation>
- </annotation>
- <simpleType>
- <restriction base='integer'>
- <minInclusive value='1024'/>
- <maxInclusive value='65535'/>
- </restriction>
- </simpleType>
- </element>
-
- <element name="disconnect-on-idle" type="boolean" maxOccurs="1" minOccurs="1" default="false">
- <annotation>
- <documentation>
- Determines if openfire closes a server-to-server connection if there is not activity of a specified period of time.
- </documentation>
- </annotation>
- </element>
-
- <element name="idle-timeout" type="integer" maxOccurs="1" minOccurs="0" default="3600">
- <annotation>
- <documentation>
- Value in seconds that represents the amount of time that a server-to-server connection
- has to be idle for before closing the connection. This parameter is only relevant when
- disconnect-on-idle is true.
- </documentation>
- </annotation>
- </element>
-
- <element name="any-can-connect" type="boolean" maxOccurs="1" minOccurs="1" default="false">
- <annotation>
- <documentation>
- Dictates whether or not openfire will restrict the servers that can connect to it.
- </documentation>
- </annotation>
- </element>
-
- <element name="allowed-servers" type="tns:ServerList" maxOccurs="unbounded" minOccurs="0">
- <annotation>
- <documentation>
- List of servers that are allowed to connect. Only relevant when any-can-connect
- is set to false
- </documentation>
- </annotation>
- </element>
-
- <element name="disallowed-servers" type="tns:ServerList" maxOccurs="unbounded" minOccurs="0">
- <annotation>
- <documentation>
- List of servers that are not allowed to connect. Only relevant when any-can-connect
- is set to true
- </documentation>
- </annotation>
- </element>
- </sequence>
- </complexType>
-
- <complexType name="XmppAccountInfo">
- <sequence>
- <element name="user" type="tns:XmppUserAccount"
- maxOccurs="unbounded" minOccurs="0">
- </element>
- <element name="group" type="tns:XmppGroup"
- maxOccurs="unbounded" minOccurs="0">
- </element>
- <element name="chat-room" type="tns:XmppChatRoom" maxOccurs="unbounded" minOccurs="0">
- </element>
- <element name="server-to-server" type="tns:XmppServerToServer" maxOccurs="unbounded" minOccurs="0">
- </element>
- </sequence>
- </complexType>
-
- <complexType name="XmppGroupMember">
- <sequence>
- <element name="user-name" type="string">
- <annotation>
- <documentation>
- IM Id for group member. If domain is left
- out it is assumed to be the XMPP domain for
- this server.
- </documentation>
- </annotation>
- </element>
- </sequence>
- </complexType>
-</schema>
View
29 sipXopenfire/etc/sipxopenfire-process.xml.in
@@ -1,29 +0,0 @@
-<?xml version='1.0' encoding='iso-8859-1' standalone='yes'?>
-<sipXecs-process xmlns='http://www.sipfoundry.org/sipX/schema/xml/sipXecs-process-01-00'>
- <name>SipXopenfire</name>
- <version>@VERSION@</version>
- <commands>
- <configtest>
- <execute>@SIPX_BINDIR@/sipxopenfire.sh</execute>
- <parameter>--configtest</parameter>
- </configtest>
- <start>
- <execute>@SIPX_BINDIR@/sipxopenfire.sh</execute>
- <parameter>--start</parameter>
- </start>
- <stop>
- <execute>@SIPX_BINDIR@/sipxopenfire.sh</execute>
- <parameter>--stop</parameter>
- </stop>
- </commands>
- <status>
- <pid>@SIPX_RUNDIR@/sipxopenfire.pid</pid>
- <log>@SIPX_LOGDIR@/sipxopenfire.log</log>
- </status>
- <resources>
- <file>@SIPX_CONFDIR@/sipxopenfire.xml</file>
- <file>@SIPX_CONFDIR@/xmpp-account-info.xml</file>
- <file>@SIPX_JAVADIR@/sipXopenfire/conf/openfire.xml</file>
- <osconfig>@SIPX_CONFDIR@/domain-config</osconfig>
- </resources>
-</sipXecs-process>
View
14 sipXopenfire/etc/sipxopenfire.cf
@@ -35,12 +35,6 @@ bundle agent sipxopenfire_config {
"sipxopenfire.xml",
"multipleldap-openfire.xml"
};
-
- any::
- "xml_file_norestart" slist => {
- "xmpp-account-info.xml",
- };
-
files:
sipxopenfire::
"$(sipx.OPENFIRE_HOME)/plugins/admin/webapp/WEB-INF/web.xml"
@@ -71,13 +65,7 @@ bundle agent sipxopenfire_config {
create => "true",
perms => m("644"),
copy_from => copy_from_cfdata("$(sipx.location_id)/ofproperty.yaml"),
- classes => if_repaired("update_ofproperty");
-
- "$(sipx.SIPX_CONFDIR)/$(xml_file_norestart)"
- comment => "install openfire config $(this.promiser)",
- create => "true",
- perms => m("644"),
- copy_from => copy_from_cfdata("$(sipx.location_id)/$(xml_file_norestart)");
+ classes => if_repaired("update_ofproperty");
"$(sipx.OPENFIRE_HOME)/resources/security/truststore"
comment => "openfire authorities",
View
50 sipXopenfire/etc/xmpp-account-info.xml.example
@@ -1,50 +0,0 @@
-<?xml version="1.0" ?>
-<xmpp-account-info xmlns="http://www.sipfoundry.org/sipX/schema/xml/xmpp-account-info-00-00">
-
-<user>
- <user-name>user1</user-name>
- <sip-user-name>user1</sip-user-name>
- <display-name>Mr. User One </display-name>
- <password>123</password>
- <email>user1@domain.org</email>
- <on-the-phone-message>I am on the phone so buzz off. </on-the-phone-message>
-</user>
-
-<user>
- <user-name>user2</user-name>
- <sip-user-name>user2</sip-user-name>
- <display-name>Mr. User Two </display-name>
- <password>123</password>
- <email>user2@domain.org</email>
- <on-the-phone-message>I am on the phone so buzz off. </on-the-phone-message>
-</user>
-
-<group>
- <group-name>somegroup</group-name>
- <description>my group</description>
- <administrator>user1</administrator>
- <user>
- <user-name>user1</user-name>
- </user>
- <user>
- <user-name>user2</user-name>
- </user>
-</group>
-
-<chat-room>
- <subdomain>subdomain</subdomain>
- <room-owner>user1</room-owner>
- <room-name>mychat</room-name>
- <moderated>false</moderated>
- <members-only>false</members-only>
- <log-room-conversations>false</log-room-conversations>
- <is-public-room>true</is-public-room>
- <is-persistent>true</is-persistent>
- <description>My chat room</description>
- <password>password</password>
- <conference-extension>201</conference-extension>
- <conference-pin>1234</conference-pin>
-</chat-room>
-
-</xmpp-account-info>
-
View
111 sipXopenfire/presence-plugin/src/org/sipfoundry/openfire/config/AccountsParser.java
@@ -22,7 +22,6 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;
-import org.dom4j.Element;
import org.jivesoftware.openfire.group.Group;
import org.jivesoftware.openfire.group.GroupManager;
import org.jivesoftware.openfire.muc.MUCRoom;
@@ -37,25 +36,10 @@
import org.sipfoundry.openfire.plugin.presence.SipXOpenfirePlugin;
import org.sipfoundry.openfire.plugin.presence.SipXOpenfirePluginException;
import org.sipfoundry.openfire.plugin.presence.UserAccount;
-import org.xml.sax.InputSource;
import org.xmpp.packet.JID;
public class AccountsParser {
-
- public static final String XMPP_INFO = "xmpp-account-info";
- public static final String USER = "user";
- public static final String GROUP = "group";
- public static final String CHAT_ROOM = "chat-room";
- public static String userTag = String.format("%s/%s", XMPP_INFO, USER);
- public static String groupTag = String.format("%s/%s", XMPP_INFO, GROUP);
- public static String chatRoomTag = String.format("%s/%s", XMPP_INFO, CHAT_ROOM);
- public static String groupMemberTag = String.format("%s/%s", groupTag, USER);
-
- private static String currentTag = null;
- private static Digester digester;
- private final String accountDbFileName;
private long lastModified;
- private final File accountDbFile;
private final File watchFile;
private static Logger logger = Logger.getLogger(AccountsParser.class);
private XmppAccountInfo previousXmppAccountInfo = null;
@@ -86,8 +70,7 @@ public void run() {
}
public void parseAccounts(ConferenceService conferenceService, boolean parseEnabled) {
- String fileUrl = "file://" + accountDbFileName;
- XmppAccountInfo newAccountInfo = AccountsParser.parse(fileUrl, conferenceService, parseEnabled);
+ XmppAccountInfo newAccountInfo = AccountsParser.parse(conferenceService, parseEnabled);
if (m_parsingEnabled) {
logger.debug("Pruning unwanted users");
pruneUnwantedXmppUsers( newAccountInfo.getXmppUserAccountNames() );
@@ -291,22 +274,9 @@ private static void pruneUnwantedXmppChatRoomServices(Collection<XmppChatRoom> c
}
}
- public AccountsParser(String accountDbFileName, String watchFileName, ConferenceService conferenceService, boolean parsingEnabled) {
- try {
- digester = new Digester();
- addRules(digester);
- } catch (Exception ex) {
- throw new SipXOpenfirePluginException(ex);
- }
-
+ public AccountsParser(String watchFileName, ConferenceService conferenceService, boolean parsingEnabled) {
this.watchFile = new File(watchFileName);
m_parsingEnabled = parsingEnabled;
-
- this.accountDbFileName = accountDbFileName;
- this.accountDbFile = new File(accountDbFileName);
- if (!accountDbFile.exists()) {
- throw new SipXOpenfirePluginException("Account db file not found : " + accountDbFileName);
- }
m_conferenceService = conferenceService;
}
@@ -319,71 +289,9 @@ public static void stopScanner() {
timer.cancel();
}
- private static void addCallMethod(String elementName, String methodName) {
- digester.addCallMethod(String.format("%s/%s", currentTag, elementName), methodName, 0);
- }
-
- /*
- * Add the digester rules.
- *
- * @param digester
- */
- private static void addRules(Digester digester) throws Exception {
- AccountsParser.digester = digester;
- digester.setUseContextClassLoader(true);
- digester.addObjectCreate(XMPP_INFO, XmppAccountInfo.class.getName());
-
- digester.addObjectCreate(userTag, XmppUserAccount.class.getName());
- digester.addSetNext(userTag, "addAccount");
-
- digester.addObjectCreate(groupTag, XmppGroup.class.getName());
- digester.addSetNext(groupTag, "addGroup");
-
- digester.addObjectCreate(groupMemberTag, XmppGroupMember.class.getName());
- digester.addSetNext(groupMemberTag, "addMember");
-
- digester.addObjectCreate(chatRoomTag, XmppChatRoom.class.getName());
- digester.addSetNext(chatRoomTag, "addChatRoom");
-
- currentTag = userTag;
- addCallMethod("password", "setPassword");
- addCallMethod("user-name", "setUserName");
- addCallMethod("sip-user-name", "setSipUserName");
- addCallMethod("email", "setEmail");
- addCallMethod("display-name", "setDisplayName");
- addCallMethod("on-the-phone-message", "setOnThePhoneMessage");
- addCallMethod("conference-extension", "setConferenceExtension");
- addCallMethod("advertise-on-call-status", "setAdvertiseOnCallPreference");
- addCallMethod("show-on-call-details", "setShowOnCallDetailsPreference");
- currentTag = groupTag;
- addCallMethod("group-name", "setGroupName");
- addCallMethod("description", "setDescription");
- addCallMethod("administrator", "setAdministrator");
- currentTag = groupMemberTag;
- addCallMethod("user-name", "setUserName");
- currentTag = chatRoomTag;
- addCallMethod("subdomain", "setSubdomain");
- addCallMethod("conference-extension", "setConferenceExtension");
- addCallMethod("conference-reach-info", "setConferenceReachabilityInfo");
- addCallMethod("room-name", "setRoomName");
- addCallMethod("description", "setDescription");
- addCallMethod("password", "setPassword");
- addCallMethod("room-owner", "setOwner");
- addCallMethod("moderated", "setModerated");
- addCallMethod("log-room-conversations", "setLogRoomConversations");
- addCallMethod("is-public-room", "setIsPublicRoom");
- addCallMethod("is-members-only", "setMembersOnly");
- addCallMethod("is-persistent", "setPersistent");
-
- }
-
- public static XmppAccountInfo parse(String url, ConferenceService conferenceService, boolean parseEnabled) {
- // Create a Digester instance
+ public static XmppAccountInfo parse(ConferenceService conferenceService, boolean parseEnabled) {
try {
- InputSource inputSource = new InputSource(url);
- digester.parse(inputSource);
- XmppAccountInfo accountInfo = (XmppAccountInfo) digester.getRoot();
-
+ XmppAccountInfo accountInfo = new XmppAccountInfo();
if (parseEnabled) {
parseMongoUsers(accountInfo);
parseMongoGroups(accountInfo);
@@ -399,9 +307,11 @@ public static XmppAccountInfo parse(String url, ConferenceService conferenceServ
}
private static void parseMongoUsers(XmppAccountInfo accountInfo) {
- List<User> users = UnfortunateLackOfSpringSupportFactory.getValidUsers().getUsersWithImEnabled();
+ ValidUsers validUsers = UnfortunateLackOfSpringSupportFactory.getValidUsers();
+ List<User> users = validUsers.getUsersWithImEnabled();
+ XmppUserAccount account = null;
for (User user : users) {
- XmppUserAccount account = new XmppUserAccount();
+ account = new XmppUserAccount();
account.setPassword(user.getPintoken());
account.setUserName(user.getJid());
account.setSipUserName(user.getUserName());
@@ -412,6 +322,11 @@ private static void parseMongoUsers(XmppAccountInfo accountInfo) {
accountInfo.addAccount(account);
}
+ User imbotUser = validUsers.getImbotUser();
+ account = new XmppUserAccount();
+ account.setPassword(imbotUser.getPintoken());
+ account.setUserName(imbotUser.getUserName());
+ accountInfo.addAccount(account);
}
private static void parseMongoConferences(XmppAccountInfo accountInfo, ConferenceService conferenceService) throws Exception {
View
17 ...nfire/presence-plugin/src/org/sipfoundry/openfire/plugin/presence/SipXOpenfirePlugin.java
@@ -392,16 +392,10 @@ public void initializePlugin(PluginManager manager, File pluginDirectory) {
* Load up the database.
*/
log.info("hostname " + hostname);
-
- String accountConfigurationFile = configurationPath + "/xmpp-account-info.xml";
String watchFile = configurationPath + "/xmpp-update.xml";
- if (!new File(accountConfigurationFile).exists()) {
- System.err.println("User account file not found");
- throw new SipXOpenfirePluginException("Cannot find user accounts file");
- } else {
- this.accountsParser = new AccountsParser(accountConfigurationFile, watchFile, m_conferenceService, watcherConfig.isEnableParsing());
- this.accountsParser.startScanner();
- }
+ this.accountsParser = new AccountsParser(watchFile, m_conferenceService, watcherConfig.isEnableParsing());
+ this.accountsParser.startScanner();
+
// config and instantiate and the presence unifier used to gather all presence info
PresenceUnifier.setPlugin(this);
@@ -884,10 +878,7 @@ public void addUserToGroup(JID jid, String groupName, boolean isAdmin) throws Gr
if (isValidUser(jid)) {
log.debug("addUserToGroup " + jid + " GroupName " + groupName);
Group group = groupManager.getGroup(groupName, true);
- if (group.getAdmins().contains(jid)) {
- log.debug("Admins already has " + jid);
- group.getMembers().add(jid);
- } else {
+ if (!group.getAdmins().contains(jid)) {
if (isAdmin) {
if (jid.getDomain().equals(this.getXmppDomain())) {
group.getAdmins().add(jid);

0 comments on commit e07500b

Please sign in to comment.