[jboss-svn-commits] JBL Code SVN: r33510 - in labs/jbosslabs/labs-3.0-build/integration/sbs-nukesauthentication/trunk/src/main: plugin and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jun 15 10:02:35 EDT 2010
Author: lkrzyzanek
Date: 2010-06-15 10:02:34 -0400 (Tue, 15 Jun 2010)
New Revision: 33510
Added:
labs/jbosslabs/labs-3.0-build/integration/sbs-nukesauthentication/trunk/src/main/java/org/jboss/labs/sbs/plugin/nukesauth/proxy/RegistrationManagerNukesProxy.java
Modified:
labs/jbosslabs/labs-3.0-build/integration/sbs-nukesauthentication/trunk/src/main/plugin/spring.xml
Log:
ORG-606 Added proxy to registrationManagerImpl - it validates username, email against Nukes DB
Added: labs/jbosslabs/labs-3.0-build/integration/sbs-nukesauthentication/trunk/src/main/java/org/jboss/labs/sbs/plugin/nukesauth/proxy/RegistrationManagerNukesProxy.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs-nukesauthentication/trunk/src/main/java/org/jboss/labs/sbs/plugin/nukesauth/proxy/RegistrationManagerNukesProxy.java (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs-nukesauthentication/trunk/src/main/java/org/jboss/labs/sbs/plugin/nukesauth/proxy/RegistrationManagerNukesProxy.java 2010-06-15 14:02:34 UTC (rev 33510)
@@ -0,0 +1,72 @@
+/*
+ * JBoss Community http://jboss.org/
+ *
+ * Copyright (c) 2010 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Libor Krzyzanek
+ */
+package org.jboss.labs.sbs.plugin.nukesauth.proxy;
+
+import org.apache.log4j.LogManager;
+import org.jboss.labs.sbs.plugin.nukesauth.NukesAccountManager;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jivesoftware.base.EmailAlreadyExistsException;
+import com.jivesoftware.base.User;
+import com.jivesoftware.base.UserAlreadyExistsException;
+import com.jivesoftware.base.UserTemplate;
+import com.jivesoftware.community.impl.RegistrationManagerImpl;
+
+/**
+ * Proxy to {@link RegistrationManagerImpl}. Manager just do validation on
+ * username and e-mail against nukes DBduring registration
+ *
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ */
+ at Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
+public class RegistrationManagerNukesProxy extends RegistrationManagerImpl {
+
+ protected static final org.apache.log4j.Logger log = LogManager.getLogger(RegistrationManagerNukesProxy.class);
+
+ private NukesAccountManager nukesAccountManager;
+
+ @Override
+ public User registerUser(UserTemplate user) throws UserAlreadyExistsException, EmailAlreadyExistsException {
+ if (user.getUsername() != null) {
+ if (nukesAccountManager.getAccountByUsername(user.getUsername()) != null) {
+ final String message = "User already exists: " + user.getUsername();
+ log.info(message);
+ throw new UserAlreadyExistsException(message);
+ }
+ }
+ if (user.getEmail() != null) {
+ if (nukesAccountManager.getNukesAccountsByEmail(user.getEmail()) != null) {
+ final String message = "Email already exists: " + user.getEmail();
+ log.info(message);
+ throw new EmailAlreadyExistsException(message);
+ }
+ }
+
+ return super.registerUser(user);
+ }
+
+ public void setNukesAccountManager(NukesAccountManager nukesAccountManager) {
+ this.nukesAccountManager = nukesAccountManager;
+ }
+
+}
Property changes on: labs/jbosslabs/labs-3.0-build/integration/sbs-nukesauthentication/trunk/src/main/java/org/jboss/labs/sbs/plugin/nukesauth/proxy/RegistrationManagerNukesProxy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: labs/jbosslabs/labs-3.0-build/integration/sbs-nukesauthentication/trunk/src/main/plugin/spring.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs-nukesauthentication/trunk/src/main/plugin/spring.xml 2010-06-15 13:47:25 UTC (rev 33509)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs-nukesauthentication/trunk/src/main/plugin/spring.xml 2010-06-15 14:02:34 UTC (rev 33510)
@@ -61,4 +61,19 @@
<property name="nukesAccountManager" ref="nukesAccountManager" />
</bean>
+ <!-- Must be exactly same lik in spring-managerContext.xml !!! -->
+ <bean id="registrationManagerImpl"
+ class="org.jboss.labs.sbs.plugin.nukesauth.proxy.RegistrationManagerNukesProxy"
+ parent="jiveManager">
+ <property name="jiveProperties" ref="jiveProperties" />
+ <property name="emailManager" ref="emailManagerImpl" />
+ <property name="userManagerImpl" ref="userManagerImpl" />
+ <property name="profileFieldManager" ref="profileFieldManager" />
+ <property name="entitlementManager" ref="entitlementManagerImpl" />
+ <property name="jiveObjectModerator" ref="jiveObjectModerator" />
+ <property name="communityManager" ref="communityManagerImpl" />
+
+ <property name="nukesAccountManager" ref="nukesAccountManager" />
+ </bean>
+
</beans>
More information about the jboss-svn-commits
mailing list