[kune-commits] r1735 - in trunk: . src/main/java/cc/kune/core/server/auth/openfire src/main/java/cc/kune/core/server/init src/main/java/cc/kune/core/server/manager src/main/java/cc/kune/core/server/manager/impl src/main/resources src/test/java/cc/kune/core/server/auth/openfire

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Mon Mar 5 20:24:00 CET 2012


Author: vjrj_
Date: 2012-03-05 20:24:00 +0100 (Mon, 05 Mar 2012)
New Revision: 1735

Added:
   trunk/src/main/java/cc/kune/core/server/auth/openfire/KuneAuthProvider.java.txt
   trunk/src/test/java/cc/kune/core/server/auth/openfire/KuneAuthProviderTest.java.txt
Removed:
   trunk/src/main/java/cc/kune/core/server/auth/openfire/KuneAuthProvider.java
   trunk/src/test/java/cc/kune/core/server/auth/openfire/KuneAuthProviderTest.java
Modified:
   trunk/.classpath
   trunk/pom.xml
   trunk/src/main/java/cc/kune/core/server/init/DatabaseInitializer.java
   trunk/src/main/java/cc/kune/core/server/manager/GroupManager.java
   trunk/src/main/java/cc/kune/core/server/manager/impl/DefaultManager.java
   trunk/src/main/java/cc/kune/core/server/manager/impl/GroupManagerDefault.java
   trunk/src/main/resources/wave-server-testing.properties
Log:
Trying to find W$ initialize problem

Modified: trunk/.classpath
===================================================================
--- trunk/.classpath	2012-03-05 17:13:05 UTC (rev 1734)
+++ trunk/.classpath	2012-03-05 19:24:00 UTC (rev 1735)
@@ -121,7 +121,6 @@
   <classpathentry kind="var" path="M2_REPO/mysql/mysql-connector-java/5.1.13/mysql-connector-java-5.1.13.jar"/>
   <classpathentry kind="var" path="M2_REPO/net/sourceforge/nekohtml/nekohtml/1.9.15/nekohtml-1.9.15.jar" sourcepath="M2_REPO/net/sourceforge/nekohtml/nekohtml/1.9.15/nekohtml-1.9.15-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/objenesis/objenesis/1.0/objenesis-1.0.jar" sourcepath="M2_REPO/org/objenesis/objenesis/1.0/objenesis-1.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/igniterealtime/openfire/3.7.0/openfire-3.7.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-container-default/1.0-alpha-8/plexus-container-default-1.0-alpha-8.jar" sourcepath="M2_REPO/org/codehaus/plexus/plexus-container-default/1.0-alpha-8/plexus-container-default-1.0-alpha-8-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.jar" sourcepath="M2_REPO/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/waveprotocol/proto-msg/0.3.12/proto-msg-0.3.12.jar"/>

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2012-03-05 17:13:05 UTC (rev 1734)
+++ trunk/pom.xml	2012-03-05 19:24:00 UTC (rev 1735)
@@ -712,18 +712,43 @@
       <version>1.0.2</version>
     </dependency>
     <!-- openfire auth integration -->
-    <dependency>
-      <groupId>org.igniterealtime</groupId>
-      <artifactId>openfire</artifactId>
-      <version>3.7.0</version>
-      <scope>provided</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>org.eclipse.jetty</groupId>
-          <!-- <artifactId>hibernate</artifactId> -->
-        </exclusion>
-      </exclusions>
-    </dependency>
+<!--     <dependency> -->
+<!--       <groupId>org.igniterealtime</groupId> -->
+<!--       <artifactId>openfire</artifactId> -->
+<!--       <version>3.7.0</version> -->
+<!--       <scope>provided</scope> -->
+<!--       <exclusions> -->
+<!--         <exclusion> -->
+<!--           <groupId>org.eclipse.jetty</groupId> -->
+<!--           <artifactId>hibernate</artifactId> -->
+<!--         </exclusion> -->
+<!--         <exclusion> -->
+<!--           <groupId>org.slf4j</groupId> -->
+<!--           <artifactId>spi</artifactId> -->
+<!--         </exclusion> -->
+<!--         <exclusion> -->
+<!--           <groupId>org.slf4j</groupId> -->
+<!--           <artifactId>slf4j-api</artifactId> -->
+<!--         </exclusion> -->
+<!--         <exclusion> -->
+<!--           <groupId>org.slf4j</groupId> -->
+<!--           <artifactId>jcl-over-slf4j</artifactId> -->
+<!--         </exclusion> -->
+<!--         <exclusion> -->
+<!--           <groupId>org.slf4j</groupId> -->
+<!--           <artifactId>jcl-over-slf4j</artifactId> -->
+<!--         </exclusion> -->
+<!--         <exclusion> -->
+<!--           <groupId>org.apache</groupId> -->
+<!--           <artifactId>commons</artifactId> -->
+<!--         </exclusion> -->
+<!--         <exclusion> -->
+<!--           <groupId>org.apache.commons</groupId> -->
+<!--           <artifactId>logging</artifactId> -->
+<!--         </exclusion> -->
+<!--       </exclusions> -->
+
+<!--     </dependency> -->
   </dependencies>
   <!-- <dependency> -->
   <!-- <groupId>dom4j</groupId> -->

Deleted: trunk/src/main/java/cc/kune/core/server/auth/openfire/KuneAuthProvider.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/auth/openfire/KuneAuthProvider.java	2012-03-05 17:13:05 UTC (rev 1734)
+++ trunk/src/main/java/cc/kune/core/server/auth/openfire/KuneAuthProvider.java	2012-03-05 19:24:00 UTC (rev 1735)
@@ -1,129 +0,0 @@
-package cc.kune.core.server.auth.openfire;
-
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-
-import org.jivesoftware.openfire.auth.AuthProvider;
-import org.jivesoftware.openfire.auth.ConnectionException;
-import org.jivesoftware.openfire.auth.InternalUnauthenticatedException;
-import org.jivesoftware.openfire.auth.UnauthorizedException;
-import org.jivesoftware.openfire.user.UserNotFoundException;
-import org.waveprotocol.wave.model.wave.ParticipantId;
-
-public class KuneAuthProvider implements AuthProvider {
-
-  protected class ClassLoadingObjectInputStream extends ObjectInputStream {
-
-    /**
-     * Code copied from HashSessionManager
-     * 
-     * @throws IOException
-     */
-    public ClassLoadingObjectInputStream() throws IOException {
-      super();
-    }
-
-    public ClassLoadingObjectInputStream(final java.io.InputStream in) throws IOException {
-      super(in);
-    }
-
-    @Override
-    public Class<?> resolveClass(final java.io.ObjectStreamClass cl) throws IOException,
-        ClassNotFoundException {
-      try {
-        return Class.forName(cl.getName(), false, Thread.currentThread().getContextClassLoader());
-      } catch (final ClassNotFoundException e) {
-        return super.resolveClass(cl);
-      }
-    }
-  }
-
-  private static final String USER_NOT_LOGGED = "User not logged";
-
-  @SuppressWarnings("unused")
-  @Override
-  public void authenticate(final String username, final String token) throws UnauthorizedException,
-      ConnectionException, InternalUnauthenticatedException {
-    try {
-      final File session = new File("/var/lib/kune/_sessions/" + token);
-      boolean logged = false;
-      if (session.exists()) {
-        final FileInputStream is = new FileInputStream(session);
-        final DataInputStream in = new DataInputStream(is);
-
-        final String clusterId = in.readUTF();
-        in.readUTF(); // nodeId
-        final long created = in.readLong();
-        final long accessed = in.readLong();
-        final int requests = in.readInt();
-
-        final int size = in.readInt();
-        if (size > 0) {
-          final ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream(in);
-          for (int i = 0; i < size; i++) {
-            final String key = ois.readUTF();
-            final Object value = ois.readObject();
-            if (value instanceof ParticipantId) {
-              if (((ParticipantId) value).getAddress().startsWith(username + "@")) {
-                logged = true;
-                break;
-              }
-            }
-          }
-          ois.close();
-        }
-        in.close();
-        is.close();
-        if (!logged) {
-          throw new UnauthorizedException("Incorrect username");
-        }
-      } else {
-        throw new UnauthorizedException(USER_NOT_LOGGED);
-      }
-    } catch (final FileNotFoundException e) {
-      throw new UnauthorizedException(USER_NOT_LOGGED, e);
-    } catch (final IOException e) {
-      throw new UnauthorizedException(USER_NOT_LOGGED, e);
-    } catch (final ClassNotFoundException e) {
-      throw new UnauthorizedException(USER_NOT_LOGGED, e);
-    }
-  }
-
-  @Override
-  public void authenticate(final String username, final String token, final String digest)
-      throws UnauthorizedException, ConnectionException, InternalUnauthenticatedException {
-    throw new UnsupportedOperationException();
-  }
-
-  @Override
-  public String getPassword(final String arg0) throws UserNotFoundException,
-      UnsupportedOperationException {
-    throw new UnsupportedOperationException();
-  }
-
-  @Override
-  public boolean isDigestSupported() {
-    return false;
-  }
-
-  @Override
-  public boolean isPlainSupported() {
-    return true;
-  }
-
-  @Override
-  public void setPassword(final String arg0, final String arg1) throws UserNotFoundException,
-      UnsupportedOperationException {
-    throw new UnsupportedOperationException();
-  }
-
-  @Override
-  public boolean supportsPasswordRetrieval() {
-    return false;
-  }
-
-}

Copied: trunk/src/main/java/cc/kune/core/server/auth/openfire/KuneAuthProvider.java.txt (from rev 1732, trunk/src/main/java/cc/kune/core/server/auth/openfire/KuneAuthProvider.java)
===================================================================
--- trunk/src/main/java/cc/kune/core/server/auth/openfire/KuneAuthProvider.java.txt	                        (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/auth/openfire/KuneAuthProvider.java.txt	2012-03-05 19:24:00 UTC (rev 1735)
@@ -0,0 +1,129 @@
+package cc.kune.core.server.auth.openfire;
+
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+import org.jivesoftware.openfire.auth.AuthProvider;
+import org.jivesoftware.openfire.auth.ConnectionException;
+import org.jivesoftware.openfire.auth.InternalUnauthenticatedException;
+import org.jivesoftware.openfire.auth.UnauthorizedException;
+import org.jivesoftware.openfire.user.UserNotFoundException;
+import org.waveprotocol.wave.model.wave.ParticipantId;
+
+public class KuneAuthProvider implements AuthProvider {
+
+  protected class ClassLoadingObjectInputStream extends ObjectInputStream {
+
+    /**
+     * Code copied from HashSessionManager
+     * 
+     * @throws IOException
+     */
+    public ClassLoadingObjectInputStream() throws IOException {
+      super();
+    }
+
+    public ClassLoadingObjectInputStream(final java.io.InputStream in) throws IOException {
+      super(in);
+    }
+
+    @Override
+    public Class<?> resolveClass(final java.io.ObjectStreamClass cl) throws IOException,
+        ClassNotFoundException {
+      try {
+        return Class.forName(cl.getName(), false, Thread.currentThread().getContextClassLoader());
+      } catch (final ClassNotFoundException e) {
+        return super.resolveClass(cl);
+      }
+    }
+  }
+
+  private static final String USER_NOT_LOGGED = "User not logged";
+
+  @SuppressWarnings("unused")
+  @Override
+  public void authenticate(final String username, final String token) throws UnauthorizedException,
+      ConnectionException, InternalUnauthenticatedException {
+    try {
+      final File session = new File("/var/lib/kune/_sessions/" + token);
+      boolean logged = false;
+      if (session.exists()) {
+        final FileInputStream is = new FileInputStream(session);
+        final DataInputStream in = new DataInputStream(is);
+
+        final String clusterId = in.readUTF();
+        in.readUTF(); // nodeId
+        final long created = in.readLong();
+        final long accessed = in.readLong();
+        final int requests = in.readInt();
+
+        final int size = in.readInt();
+        if (size > 0) {
+          final ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream(in);
+          for (int i = 0; i < size; i++) {
+            final String key = ois.readUTF();
+            final Object value = ois.readObject();
+            if (value instanceof ParticipantId) {
+              if (((ParticipantId) value).getAddress().startsWith(username + "@")) {
+                logged = true;
+                break;
+              }
+            }
+          }
+          ois.close();
+        }
+        in.close();
+        is.close();
+        if (!logged) {
+          throw new UnauthorizedException("Incorrect username");
+        }
+      } else {
+        throw new UnauthorizedException(USER_NOT_LOGGED);
+      }
+    } catch (final FileNotFoundException e) {
+      throw new UnauthorizedException(USER_NOT_LOGGED, e);
+    } catch (final IOException e) {
+      throw new UnauthorizedException(USER_NOT_LOGGED, e);
+    } catch (final ClassNotFoundException e) {
+      throw new UnauthorizedException(USER_NOT_LOGGED, e);
+    }
+  }
+
+  @Override
+  public void authenticate(final String username, final String token, final String digest)
+      throws UnauthorizedException, ConnectionException, InternalUnauthenticatedException {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public String getPassword(final String arg0) throws UserNotFoundException,
+      UnsupportedOperationException {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public boolean isDigestSupported() {
+    return false;
+  }
+
+  @Override
+  public boolean isPlainSupported() {
+    return true;
+  }
+
+  @Override
+  public void setPassword(final String arg0, final String arg1) throws UserNotFoundException,
+      UnsupportedOperationException {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public boolean supportsPasswordRetrieval() {
+    return false;
+  }
+
+}

Modified: trunk/src/main/java/cc/kune/core/server/init/DatabaseInitializer.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/init/DatabaseInitializer.java	2012-03-05 17:13:05 UTC (rev 1734)
+++ trunk/src/main/java/cc/kune/core/server/init/DatabaseInitializer.java	2012-03-05 19:24:00 UTC (rev 1735)
@@ -21,11 +21,8 @@
 
 import java.util.TimeZone;
 
-import javax.persistence.NoResultException;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.hibernate.exception.SQLGrammarException;
 import org.waveprotocol.box.server.authentication.PasswordDigest;
 
 import cc.kune.core.client.errors.UserMustBeLoggedException;
@@ -178,44 +175,9 @@
     translationManager.persist(test);
   }
 
-  private void createProperties() {
-    // final PropertyGroup groupProps = new PropertyGroup(Group.PROPS_ID);
-    // final PropertyGroup userProps = new PropertyGroup(User.PROPS_ID);
-    // propGroupManager.persist(userProps);
-    // propGroupManager.persist(groupProps);
-    // final PropertySubgroup userXmppProps = new
-    // PropertySubgroup("user-xmpp");
-    // propSubgroupManager.persist(userXmppProps);
-
-    // final Property colorProp = new Property("xmpp_color",
-    // "Choose your color", Property.Type.STRING, true, "blue",
-    // userProps, userXmppProps);
-    // final ArrayList<String> subValues = new ArrayList<String>();
-    // subValues.add(SubscriptionMode.autoAcceptAll.toString());
-    // subValues.add(SubscriptionMode.autoRejectAll.toString());
-    // subValues.add(SubscriptionMode.manual.toString());
-    // final Property subProp = new Property("xmpp_subcriptionmode",
-    // "New buddies options", Property.Type.ENUM, true,
-    // SubscriptionMode.manual.toString(), subValues, userProps,
-    // userXmppProps);
-    // final Property unanavProp = new
-    // Property("xmpp_unanavailableitemsvisible",
-    // "Show unavailable buddies",
-    // Property.Type.BOOL, true, Boolean.toString(true), userProps,
-    // userXmppProps);
-    // propertyManager.persist(colorProp);
-    // propertyManager.persist(subProp);
-    // propertyManager.persist(unanavProp);
-  }
-
   public void initConditional() throws Exception {
-    try {
-      groupManager.getSiteDefaultGroup();
-    } catch (final NoResultException e) {
+    if (groupManager.count() == 0) {
       initialize();
-    } catch (final SQLGrammarException e3) {
-      // Seems like in Windows we get this Exception instead
-      initialize();
     }
     translationService.init();
   }
@@ -224,7 +186,6 @@
   public void initDatabase() throws Exception {
     createOthers();
     createLicenses();
-    createProperties();
     createDefUsersGroup();
   }
 

Modified: trunk/src/main/java/cc/kune/core/server/manager/GroupManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/GroupManager.java	2012-03-05 17:13:05 UTC (rev 1734)
+++ trunk/src/main/java/cc/kune/core/server/manager/GroupManager.java	2012-03-05 19:24:00 UTC (rev 1735)
@@ -43,6 +43,14 @@
 
   void clearGroupBackImage(Group group);
 
+  /**
+   * Count # of registered groups (only used to see in the database is
+   * initialized)
+   * 
+   * @return the int
+   */
+  int count();
+
   Group createGroup(Group group, User user, String publicDescrip) throws GroupShortNameInUseException,
       UserMustBeLoggedException;
 

Modified: trunk/src/main/java/cc/kune/core/server/manager/impl/DefaultManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/impl/DefaultManager.java	2012-03-05 17:13:05 UTC (rev 1734)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/DefaultManager.java	2012-03-05 19:24:00 UTC (rev 1735)
@@ -157,4 +157,12 @@
     return search(query, firstResult, maxResults);
   }
 
+  @SuppressWarnings("unchecked")
+  public int size() {
+    final FullTextEntityManager fullTextEm = Search.getFullTextEntityManager(getEntityManager());
+    final List<T> entities = fullTextEm.createQuery(
+        "SELECT e FROM " + entityClass.getSimpleName() + " AS e").getResultList();
+    return entities.size();
+  }
+
 }

Modified: trunk/src/main/java/cc/kune/core/server/manager/impl/GroupManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/impl/GroupManagerDefault.java	2012-03-05 17:13:05 UTC (rev 1734)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/GroupManagerDefault.java	2012-03-05 19:24:00 UTC (rev 1735)
@@ -144,6 +144,11 @@
   }
 
   @Override
+  public int count() {
+    return super.size();
+  }
+
+  @Override
   public Group createGroup(final Group group, final User user, final String publicDescrip)
       throws GroupShortNameInUseException, GroupLongNameInUseException, UserMustBeLoggedException {
     checkIfShortNameAreInUse(group.getShortName());

Modified: trunk/src/main/resources/wave-server-testing.properties
===================================================================
--- trunk/src/main/resources/wave-server-testing.properties	2012-03-05 17:13:05 UTC (rev 1734)
+++ trunk/src/main/resources/wave-server-testing.properties	2012-03-05 19:24:00 UTC (rev 1735)
@@ -68,7 +68,7 @@
 # To become an admin: Register a user and set its address as the value below.
 # Admin has a privilege to change passwords of other users using an agent robot.
 # Default value: @${wave_server_domain}
-admin_user = @local.net
+admin_user = @localhost
 
 # The wave id of the welcome template wave. (Without domain, for example: w+Fxjs_-ZPmmA).
 # If filled in then a copy of this wave (actually only the root blip) will be

Deleted: trunk/src/test/java/cc/kune/core/server/auth/openfire/KuneAuthProviderTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/auth/openfire/KuneAuthProviderTest.java	2012-03-05 17:13:05 UTC (rev 1734)
+++ trunk/src/test/java/cc/kune/core/server/auth/openfire/KuneAuthProviderTest.java	2012-03-05 19:24:00 UTC (rev 1735)
@@ -1,18 +0,0 @@
-package cc.kune.core.server.auth.openfire;
-
-import org.jivesoftware.openfire.auth.ConnectionException;
-import org.jivesoftware.openfire.auth.InternalUnauthenticatedException;
-import org.jivesoftware.openfire.auth.UnauthorizedException;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class KuneAuthProviderTest {
-
-  @Test
-  @Ignore
-  public void maintest() throws UnauthorizedException, ConnectionException,
-      InternalUnauthenticatedException {
-    final KuneAuthProvider auth = new KuneAuthProvider();
-    auth.authenticate("admin", "169le0ik2rma81xhj4560ul7fm");
-  }
-}

Copied: trunk/src/test/java/cc/kune/core/server/auth/openfire/KuneAuthProviderTest.java.txt (from rev 1732, trunk/src/test/java/cc/kune/core/server/auth/openfire/KuneAuthProviderTest.java)
===================================================================
--- trunk/src/test/java/cc/kune/core/server/auth/openfire/KuneAuthProviderTest.java.txt	                        (rev 0)
+++ trunk/src/test/java/cc/kune/core/server/auth/openfire/KuneAuthProviderTest.java.txt	2012-03-05 19:24:00 UTC (rev 1735)
@@ -0,0 +1,18 @@
+package cc.kune.core.server.auth.openfire;
+
+import org.jivesoftware.openfire.auth.ConnectionException;
+import org.jivesoftware.openfire.auth.InternalUnauthenticatedException;
+import org.jivesoftware.openfire.auth.UnauthorizedException;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class KuneAuthProviderTest {
+
+  @Test
+  @Ignore
+  public void maintest() throws UnauthorizedException, ConnectionException,
+      InternalUnauthenticatedException {
+    final KuneAuthProvider auth = new KuneAuthProvider();
+    auth.authenticate("admin", "169le0ik2rma81xhj4560ul7fm");
+  }
+}




More information about the kune-commits mailing list