You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by ja...@apache.org on 2011/11/06 10:48:17 UTC
svn commit: r1198331 - in
/incubator/rave/sandbox/rave-extensions/rave-vanilla-extension: pom.xml
src/main/java/org/apache/rave/portal/service/impl/CustomUserService.java
src/main/webapp/WEB-INF/applicationContext-security.xml
src/main/webapp/login.jsp
Author: jasha
Date: Sun Nov 6 09:48:17 2011
New Revision: 1198331
URL: http://svn.apache.org/viewvc?rev=1198331&view=rev
Log:
Make the vanilla extension work out of the box again:
- add dependencies on slf4j, log4j and rave-demo-gadgets
- extend the DefaultUserService to keep profiting from newly added methods in UserService
- use same role restrictions as added in 0.5-incubating
Modified:
incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/pom.xml
incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/java/org/apache/rave/portal/service/impl/CustomUserService.java
incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/webapp/WEB-INF/applicationContext-security.xml
incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/webapp/login.jsp
Modified: incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/pom.xml
URL: http://svn.apache.org/viewvc/incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/pom.xml?rev=1198331&r1=1198330&r2=1198331&view=diff
==============================================================================
--- incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/pom.xml (original)
+++ incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/pom.xml Sun Nov 6 09:48:17 2011
@@ -20,8 +20,8 @@
$Id: pom.xml 1152919 2011-08-01 20:19:57Z jasha $
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
->
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ >
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.rave</groupId>
@@ -29,31 +29,37 @@
<name>Apache Rave :: rave-vanilla-extension</name>
<description>Apache Rave Project Sandbox</description>
<packaging>war</packaging>
- <version>SNAPSHOT</version>
+ <version>0.6-SNAPSHOT</version>
<properties>
- <apache.rave.version>0.4-incubating-SNAPSHOT</apache.rave.version>
+ <apache.rave.version>0.6-incubating-SNAPSHOT</apache.rave.version>
<com.h2database.version>1.3.154</com.h2database.version>
<javax.servlet.version>2.5</javax.servlet.version>
<jsp-api.version>2.1</jsp-api.version>
<el-api.version>1.0</el-api.version>
+ <org.slf4j.version>1.6.1</org.slf4j.version>
+ <log4j.version>1.2.16</log4j.version>
+
<commons-lang.version>2.6</commons-lang.version>
<junit.version>4.7</junit.version>
<cargo.version>1.1.0</cargo.version>
- <!-- if you want a remote debugging on a different a address
- override on command line with -Dcargo.debug.addres=xxxx -->
+ <!-- if you want a remote debugging on a different a address
+ override on command line with -Dcargo.debug.addres=xxxx -->
<cargo.debug.address>8000</cargo.debug.address>
- <!-- if you want to start remote debugging session suspended
- override on command line with -Dcargo.debug.suspend=y -->
+ <!-- if you want to start remote debugging session suspended
+ override on command line with -Dcargo.debug.suspend=y -->
<cargo.debug.suspend>n</cargo.debug.suspend>
- <javaagent />
- <!-- Force maven-filesync-plugin rewrite the Eclipse FileSync plugin configuration with
- $mvn filesync:generate -Dmaven.filesync.override=true -->
+ <javaagent/>
+ <!-- Force maven-filesync-plugin rewrite the Eclipse FileSync plugin configuration with
+ $mvn filesync:generate -Dmaven.filesync.override=true -->
<maven.filesync.override>false</maven.filesync.override>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
</properties>
<dependencies>
- <!-- servlet-api, jsp-api and el-api api must be scope provided -->
+ <!-- servlet-api, jsp-api and el-api api must be scope provided -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
@@ -73,23 +79,23 @@
<scope>provided</scope>
</dependency>
- <!-- Exclude commons-logging by adding it as a provided dependency -->
+ <!-- Exclude commons-logging by adding it as a provided dependency -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
-
- <!-- fore junit dependency on scope test -->
+
+ <!-- fore junit dependency on scope test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
-
- <!-- Ensure/enforce proper version for commons-lang, not relying on transitive dependencies -->
+
+ <!-- Ensure/enforce proper version for commons-lang, not relying on transitive dependencies -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
@@ -109,7 +115,7 @@
<version>${apache.rave.version}</version>
</dependency>
- <!-- Default database -->
+ <!-- Default database -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
@@ -124,6 +130,27 @@
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.rave</groupId>
+ <artifactId>rave-demo-gadgets</artifactId>
+ <type>war</type>
+ <version>${apache.rave.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- log4j logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${org.slf4j.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j.version}</version>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
<profiles>
@@ -235,7 +262,7 @@
<configuration>
<properties>
<cargo.jvmargs>
- <![CDATA[-Xdebug -Xrunjdwp:transport=dt_socket,address=${cargo.debug.address},server=y,suspend=${cargo.debug.suspend} -noverify ${javaagent}]]>
+ <![CDATA[-Xdebug -Xrunjdwp:transport=dt_socket,address=${cargo.debug.address},server=y,suspend=${cargo.debug.suspend} -noverify ${javaagent}]]>
</cargo.jvmargs>
<cargo.tomcat.context.reloadable>true</cargo.tomcat.context.reloadable>
</properties>
@@ -251,6 +278,14 @@
</deployable>
<deployable>
<groupId>org.apache.rave</groupId>
+ <artifactId>rave-demo-gadgets</artifactId>
+ <type>war</type>
+ <properties>
+ <context>/demogadgets</context>
+ </properties>
+ </deployable>
+ <deployable>
+ <groupId>org.apache.rave</groupId>
<artifactId>rave-vanilla-extension</artifactId>
<type>war</type>
<properties>
@@ -265,7 +300,7 @@
<zipUrlInstaller>
<url>
http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.tar.gz
- </url>
+ </url>
</zipUrlInstaller>
<systemProperties>
<shindig.host>localhost</shindig.host>
@@ -275,4 +310,4 @@
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
Modified: incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/java/org/apache/rave/portal/service/impl/CustomUserService.java
URL: http://svn.apache.org/viewvc/incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/java/org/apache/rave/portal/service/impl/CustomUserService.java?rev=1198331&r1=1198330&r2=1198331&view=diff
==============================================================================
--- incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/java/org/apache/rave/portal/service/impl/CustomUserService.java (original)
+++ incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/java/org/apache/rave/portal/service/impl/CustomUserService.java Sun Nov 6 09:48:17 2011
@@ -20,8 +20,8 @@
package org.apache.rave.portal.service.impl;
import org.apache.rave.portal.model.User;
+import org.apache.rave.portal.repository.PageRepository;
import org.apache.rave.portal.repository.UserRepository;
-import org.apache.rave.portal.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -34,43 +34,44 @@ import org.springframework.stereotype.Se
/**
* Custom User service is to demonstrate how you can extend userservice in RAVE and add additional information
- *
*/
@Service(value = "customUserService")
-public class CustomUserService implements UserService {
- protected static final Logger logger = LoggerFactory.getLogger(CustomUserService.class);
- protected UserRepository userRepository;
+public class CustomUserService extends DefaultUserService {
+ private static final Logger logger = LoggerFactory.getLogger(CustomUserService.class);
+ private UserRepository userRepository;
@Autowired
- public CustomUserService(UserRepository userRepository) {
- this.userRepository = userRepository;
-
- }
+ public CustomUserService(UserRepository userRepository, PageRepository pageRepository) {
+ super(userRepository, pageRepository);
+ this.userRepository = userRepository;
+ }
@Override
- public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
- logger.info("Custom User Serice called to get user informtion");
+ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
+ logger.info("Custom User Serice called to get user informtion");
final User user = userRepository.getByUsername(username);
- if(user == null) {
+ if (user == null) {
throw new UsernameNotFoundException("User with username '" + username + "' was not found!");
}
- fetchCustomCredential(user);
+ fetchCustomCredential(user);
return user;
}
- /**
- * This method attempts to load the custom credential and decorates it with
- * additional attributes.
- */
- private void fetchCustomCredential(User user) {
- try {
- logger.info("Decorating the credential for user" + user.getUsername());
- }
- catch (Exception e){
- logger.warn("Unexpected GridShib error:" +e.getMessage());
- }
- }
+ /**
+ * This method attempts to load the custom credential and decorates it with
+ * additional attributes.
+ *
+ * @param user for whom the custom credentials are fetched
+ */
+ private void fetchCustomCredential(User user) {
+ try {
+ logger.info("Decorating the credential for user" + user.getUsername());
+ } catch (Exception e) {
+ logger.warn("Unexpected GridShib error:" + e.getMessage());
+ }
+ }
+
@Override
public User getAuthenticatedUser() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
@@ -82,46 +83,4 @@ public class CustomUserService implement
}
}
- @Override
- public void setAuthenticatedUser(long userId) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void clearAuthenticatedUser() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void registerNewUser(User user) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public User getUserByUsername(String userName) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public User getUserById(Long id) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public User getUserByEmail(String userEmail) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void updateUserProfile(User user) {
- // TODO Auto-generated method stub
-
- }
-
}
\ No newline at end of file
Modified: incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/webapp/WEB-INF/applicationContext-security.xml
URL: http://svn.apache.org/viewvc/incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/webapp/WEB-INF/applicationContext-security.xml?rev=1198331&r1=1198330&r2=1198331&view=diff
==============================================================================
--- incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/webapp/WEB-INF/applicationContext-security.xml (original)
+++ incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/webapp/WEB-INF/applicationContext-security.xml Sun Nov 6 09:48:17 2011
@@ -22,50 +22,46 @@
This security file uses the default spring simple form login
-->
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:security="http://www.springframework.org/schema/security"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
+ xmlns:security="http://www.springframework.org/schema/security"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<security:http auto-config="true" use-expressions="true" disable-url-rewriting="true">
- <security:intercept-url pattern="/newaccount.jsp*" access="permitAll"/>
- <security:intercept-url pattern="/app/newaccount*" access="permitAll"/>
- <security:intercept-url pattern="/login.jsp*" filters="none" />
- <security:intercept-url pattern="/css/**" access="permitAll"/>
- <security:intercept-url pattern="/images/**" access="permitAll"/>
- <security:intercept-url pattern="/script/**" access="permitAll"/>
- <!-- all urls must be authenticated -->
- <security:intercept-url pattern="/**"
- access="isAuthenticated()"/>
- <!-- Set the user service ref here to the implementation you want to use. The name is
- defined in the @Service annotation of the corresponding service source code.
- -->
- <security:openid-login user-service-ref="customUserService" authentication-failure-url="/login.jsp?authfail=openid">
- <security:attribute-exchange>
- <!-- Supported by MyOpenID.com -->
- <security:openid-attribute name="firstName" type="http://schema.openid.net/namePerson/first"/>
- <security:openid-attribute name="lastName" type="http://schema.openid.net/namePerson/last"/>
- <security:openid-attribute name="email" type="http://schema.openid.net/contact/email" required="true"/>
- <!-- security:openid-attribute name="language" type="http://schema.openid.net/language/pref"/>
- <security:openid-attribute name="birthDate" type="http://schema.openid.net/birthDate"/>
- <security:openid-attribute name="namePerson" type="http://schema.openid.net/namePerson" required="true"/>
- <security:openid-attribute name="nickname" type="http://schema.openid.net/namePerson/friendly" required="true"/>
- <security:openid-attribute name="country" type="http://schema.openid.net/contact/country/home"/>
- -->
- </security:attribute-exchange>
- </security:openid-login>
- <security:form-login login-page="/login.jsp" authentication-failure-url="/login.jsp?authfail=form"/>
- <security:logout/>
+ <security:intercept-url pattern="/newaccount.jsp*" access="permitAll"/>
+ <security:intercept-url pattern="/app/newaccount*" access="permitAll"/>
+ <security:intercept-url pattern="/login.jsp*" filters="none"/>
+ <security:intercept-url pattern="/css/**" access="permitAll"/>
+ <security:intercept-url pattern="/images/**" access="permitAll"/>
+ <security:intercept-url pattern="/script/**" access="permitAll"/>
+ <security:intercept-url pattern="/app/admin/**" access="hasRole('ROLE_ADMIN')"/>
+ <!-- all urls must be authenticated -->
+ <security:intercept-url pattern="/**" access="hasAnyRole('ROLE_USER','ROLE_ADMIN')"/>
+
+
+ <!-- Set the user service ref here to the implementation you want to use. The name is
+ defined in the @Service annotation of the corresponding service source code.
+ -->
+ <security:openid-login user-service-ref="customUserService" authentication-failure-url="/login.jsp?authfail=openid">
+ <security:attribute-exchange>
+ <!-- Supported by MyOpenID.com -->
+ <security:openid-attribute name="firstName" type="http://schema.openid.net/namePerson/first"/>
+ <security:openid-attribute name="lastName" type="http://schema.openid.net/namePerson/last"/>
+ <security:openid-attribute name="email" type="http://schema.openid.net/contact/email" required="true"/>
+ </security:attribute-exchange>
+ </security:openid-login>
+ <security:form-login login-page="/login.jsp" authentication-failure-url="/login.jsp?authfail=form"/>
+ <security:logout/>
</security:http>
<security:authentication-manager>
- <!-- Set the user service ref here to the implementation you want to use. The name is
- defined in the @Service annotation of the corresponding service source code.
- -->
- <security:authentication-provider user-service-ref="customUserService">
- <security:password-encoder ref="passwordEncoder">
- <security:salt-source ref="saltSource"/>
- </security:password-encoder>
- </security:authentication-provider>
+ <!-- Set the user service ref here to the implementation you want to use. The name is
+ defined in the @Service annotation of the corresponding service source code.
+ -->
+ <security:authentication-provider user-service-ref="customUserService">
+ <security:password-encoder ref="passwordEncoder">
+ <security:salt-source ref="saltSource"/>
+ </security:password-encoder>
+ </security:authentication-provider>
</security:authentication-manager>
</beans>
Modified: incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/webapp/login.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/webapp/login.jsp?rev=1198331&r1=1198330&r2=1198331&view=diff
==============================================================================
--- incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/webapp/login.jsp (original)
+++ incubator/rave/sandbox/rave-extensions/rave-vanilla-extension/src/main/webapp/login.jsp Sun Nov 6 09:48:17 2011
@@ -16,86 +16,92 @@
~ specific language governing permissions and limitations
~ under the License.
--%>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
- <head>
- <meta charset="UTF-8" />
- <title><c:out value="Rave - Custom Login" /></title>
- <link rel="stylesheet" href="<c:url value="/css/custom.css" />" />
- </head>
- <body class="b-mac b-ch b-css3 l-en">
- <div class="page">
- <div class="dialog center">
- <div id="dialog_content">
- <h1>Login</h1>
- <div id="logins">
- <h2>Username and Password</h2>
- <form id="loginForm" name="loginForm"
- action="j_spring_security_check" method="post">
- <c:if test="${param['authfail'] eq 'form'}">
- <p class="error">The username or password is incorrect.</p>
- </c:if>
- <fieldset>
- <p>
- <label for="usernameField">Username: </label> <input
- id="usernameField" type="text" name="j_username" />
- </p>
-
- <p>
- <label for="passwordField">Password: </label> <input
- id="passwordField" type="password" name="j_password" />
- </p>
- <p>
- <label for="remember_me" class="checkboxLabel"> <input
- type='checkbox' name='_spring_security_remember_me'
- id="remember_me" value="true" /> Remember me </label>
- </p>
- </fieldset>
- <fieldset>
- <input type="submit" value="Login" />
- </fieldset>
- </form>
- </div>
- <h2>New User</h2>
- <form id="newAccount" action="<c:url value="/app/newaccount.jsp"/>"
- method="get">
- <fieldset>
- <p>
- <label for="createNewAccountButton">Register: </label> <input
- id="createNewAccountButton" type="submit"
- value="Create New Account" />
- </p>
- </fieldset>
- </form>
-
- <h2>OpenID Identity</h2>
- <form id="oidForm" name='oidf'
- action='j_spring_openid_security_check' method='POST'>
- <c:if test="${param['authfail'] eq 'openid'}">
- <p class="error">OpenID identification failed.</p>
- </c:if>
- <fieldset>
- <p>
- <label for="openid_identifier">Identity: </label> <input
- type='text' id="openid_identifier" name='openid_identifier'
- class="long" />
- </p>
- <p>
- <label for="remember_me_openid" class="checkboxLabel"> <input
- type='checkbox' name='_spring_security_remember_me'
- id="remember_me_openid" value="true" /> Remember me </label>
- </p>
- </fieldset>
- <fieldset>
- <input type="submit" value="Login with OpenID" />
- </fieldset>
- </form>
- </div>
- </div>
- </div>
- <script>
- document.loginForm.j_username.focus();
- </script>
+<head>
+ <meta charset="UTF-8"/>
+ <title><c:out value="Rave - Custom Login"/></title>
+ <link rel="stylesheet" href="<c:url value="/css/custom.css" />"/>
+</head>
+<body class="b-mac b-ch b-css3 l-en">
+<div class="page">
+ <div class="dialog center">
+ <div id="dialog_content">
+ <h1>Login</h1>
+
+ <div id="logins">
+ <h2>Username and Password</h2>
+
+ <form id="loginForm" name="loginForm"
+ action="j_spring_security_check" method="post">
+ <c:if test="${param['authfail'] eq 'form'}">
+ <p class="error">The username or password is incorrect.</p>
+ </c:if>
+ <fieldset>
+ <p>
+ <label for="usernameField">Username: </label> <input
+ id="usernameField" type="text" name="j_username"/>
+ </p>
+
+ <p>
+ <label for="passwordField">Password: </label> <input
+ id="passwordField" type="password" name="j_password"/>
+ </p>
+
+ <p>
+ <label for="remember_me" class="checkboxLabel"> <input
+ type='checkbox' name='_spring_security_remember_me'
+ id="remember_me" value="true"/> Remember me </label>
+ </p>
+ </fieldset>
+ <fieldset>
+ <input type="submit" value="Login"/>
+ </fieldset>
+ </form>
+ </div>
+ <h2>New User</h2>
+
+ <form id="newAccount" action="<c:url value="/app/newaccount.jsp"/>"
+ method="get">
+ <fieldset>
+ <p>
+ <label for="createNewAccountButton">Register: </label> <input
+ id="createNewAccountButton" type="submit"
+ value="Create New Account"/>
+ </p>
+ </fieldset>
+ </form>
+
+ <h2>OpenID Identity</h2>
+
+ <form id="oidForm" name='oidf'
+ action='j_spring_openid_security_check' method='POST'>
+ <c:if test="${param['authfail'] eq 'openid'}">
+ <p class="error">OpenID identification failed.</p>
+ </c:if>
+ <fieldset>
+ <p>
+ <label for="openid_identifier">Identity: </label> <input
+ type='text' id="openid_identifier" name='openid_identifier'
+ class="long"/>
+ </p>
+
+ <p>
+ <label for="remember_me_openid" class="checkboxLabel"> <input
+ type='checkbox' name='_spring_security_remember_me'
+ id="remember_me_openid" value="true"/> Remember me </label>
+ </p>
+ </fieldset>
+ <fieldset>
+ <input type="submit" value="Login with OpenID"/>
+ </fieldset>
+ </form>
+ </div>
+ </div>
+</div>
+<script>
+ document.loginForm.j_username.focus();
+</script>
</body>
</html>