You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by mp...@apache.org on 2011/08/29 21:55:36 UTC
svn commit: r1162966 - in
/incubator/rave/sandbox/science-gateways/rave-gateway-extensions: pom.xml
src/main/java/org/apache/rave/portal/service/impl/CommunityUserService.java
src/main/webapp/WEB-INF/web.xml
Author: mpierce
Date: Mon Aug 29 19:55:35 2011
New Revision: 1162966
URL: http://svn.apache.org/viewvc?rev=1162966&view=rev
Log:
(RAVE-213) Fixing some bugs with the sandbox deployment.
Modified:
incubator/rave/sandbox/science-gateways/rave-gateway-extensions/pom.xml
incubator/rave/sandbox/science-gateways/rave-gateway-extensions/src/main/java/org/apache/rave/portal/service/impl/CommunityUserService.java
incubator/rave/sandbox/science-gateways/rave-gateway-extensions/src/main/webapp/WEB-INF/web.xml
Modified: incubator/rave/sandbox/science-gateways/rave-gateway-extensions/pom.xml
URL: http://svn.apache.org/viewvc/incubator/rave/sandbox/science-gateways/rave-gateway-extensions/pom.xml?rev=1162966&r1=1162965&r2=1162966&view=diff
==============================================================================
--- incubator/rave/sandbox/science-gateways/rave-gateway-extensions/pom.xml (original)
+++ incubator/rave/sandbox/science-gateways/rave-gateway-extensions/pom.xml Mon Aug 29 19:55:35 2011
@@ -58,14 +58,14 @@
</properties>
<dependencies>
-
+ <!-- ================================================== -->
+ <!-- These are mininal required dependencies for any extension -->
+ <!-- ================================================== -->
<dependency>
<groupId>org.apache.rave</groupId>
<artifactId>rave-commons</artifactId>
<version>0.3-incubating-SNAPSHOT</version>
</dependency>
-
- <!--The rave-portal.jar is needed for compilation -->
<dependency>
<groupId>org.apache.rave</groupId>
<artifactId>rave-portal</artifactId>
@@ -73,15 +73,12 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
-
- <!-- The rave-portal.war dependency is needed for running with cargo -->
<dependency>
<groupId>org.apache.rave</groupId>
<artifactId>rave-portal</artifactId>
<version>0.3-incubating-SNAPSHOT</version>
<type>war</type>
</dependency>
-
<dependency>
<groupId>org.apache.rave</groupId>
<artifactId>rave-shindig</artifactId>
@@ -90,14 +87,9 @@
<scope>provided</scope>
</dependency>
- <!-- JSON Dependencies -->
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20070829</version>
- </dependency>
-
+ <!-- ================================================== -->
<!-- Gridshib dependencies -->
+ <!-- ================================================== -->
<dependency>
<groupId>edu.ncsa</groupId>
<artifactId>gridshib-saml-tools</artifactId>
@@ -108,7 +100,6 @@
<artifactId>gridshib-common</artifactId>
<version>0_5_0</version>
</dependency>
-
<dependency>
<groupId>edu.ncsa</groupId>
<artifactId>globus-opensaml</artifactId>
@@ -130,7 +121,9 @@
<version>1.2.13</version>
</dependency>
+ <!-- ================================================== -->
<!-- These are needed for Grid authentication -->
+ <!-- ================================================== -->
<dependency>
<groupId>cog-jglobus</groupId>
<artifactId>cog-jglobus</artifactId>
@@ -167,12 +160,18 @@
<version>4.2</version>
<scope>${scope.sharedlib}</scope>
</dependency>
+
+ <!--This is needed by the ProxyManager. Scope set to "provided" to avoid including
+ unnecessary jars.
+ -->
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>1.0</version>
- <scope>${scope.sharedlib}</scope>
+ <scope>provided</scope>
</dependency>
+
+<!--
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
@@ -217,145 +216,140 @@
<version>2.4</version>
<scope>${scope.sharedlib}</scope>
</dependency>
+-->
+ <!-- ================================================== -->
+ <!-- Spring -->
+ <!-- ================================================== -->
+<!--
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jdbc</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-web</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-config</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-openid</artifactId>
+ <version>${org.springframework.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-oxm</artifactId>
+ <version>${org.springframework.version}</version>
+ </dependency>
- <!-- Shindig -->
+
+ <dependency>
+ <groupId>org.openid4java</groupId>
+ <artifactId>openid4java-consumer</artifactId>
+ <version>${org.openid4java.version}</version>
+ <type>pom</type>
+ </dependency>
+-->
+ <!-- Jackson JSON Mapper -->
<dependency>
- <groupId>org.apache.shindig</groupId>
- <artifactId>shindig-common</artifactId>
- <type>jar</type>
- <scope>compile</scope>
- <version>${apache.shindig.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>jasper-el</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>el-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <!-- Spring -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jdbc</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-orm</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-web</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-config</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-openid</artifactId>
- <version>${org.springframework.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-oxm</artifactId>
- <version>${org.springframework.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.openid4java</groupId>
- <artifactId>openid4java-consumer</artifactId>
- <version>${org.openid4java.version}</version>
- <type>pom</type>
- </dependency>
-
- <!-- Jackson JSON Mapper -->
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <version>1.8.1</version>
- </dependency>
-
- <!-- JSON Support -->
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20090211</version>
- </dependency>
-
- <!--Persistence-->
- <dependency>
- <groupId>org.apache.openjpa</groupId>
- <artifactId>openjpa</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- </dependency>
-
- <!-- JSTL -->
- <dependency>
- <groupId>org.glassfish.web</groupId>
- <artifactId>jstl-impl</artifactId>
- </dependency>
-
- <!-- Logging -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.ibm.icu</groupId>
- <artifactId>icu4j</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
-
- <!-- Test -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- </dependency>
- </dependencies>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>1.8.1</version>
+ </dependency>
+
+ <!-- JSON Support -->
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20090211</version>
+ </dependency>
+
+ <!--Persistence-->
+<!--
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
+-->
+
+ <!-- JSTL -->
+<!--
+ <dependency>
+ <groupId>org.glassfish.web</groupId>
+ <artifactId>jstl-impl</artifactId>
+ </dependency>
+-->
+
+ <!-- ================================================== -->
+ <!-- Logging -->
+ <!-- ================================================== -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+<!--
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+-->
+
+<!--
+ <dependency>
+ <groupId>com.ibm.icu</groupId>
+ <artifactId>icu4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+-->
+
+ <!-- Test -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ </dependency>
+ </dependencies>
<profiles>
Modified: incubator/rave/sandbox/science-gateways/rave-gateway-extensions/src/main/java/org/apache/rave/portal/service/impl/CommunityUserService.java
URL: http://svn.apache.org/viewvc/incubator/rave/sandbox/science-gateways/rave-gateway-extensions/src/main/java/org/apache/rave/portal/service/impl/CommunityUserService.java?rev=1162966&r1=1162965&r2=1162966&view=diff
==============================================================================
--- incubator/rave/sandbox/science-gateways/rave-gateway-extensions/src/main/java/org/apache/rave/portal/service/impl/CommunityUserService.java (original)
+++ incubator/rave/sandbox/science-gateways/rave-gateway-extensions/src/main/java/org/apache/rave/portal/service/impl/CommunityUserService.java Mon Aug 29 19:55:35 2011
@@ -72,9 +72,9 @@ import xportlets.proxymanager.ProxyStora
* myproxy-logon or similar.
*/
@Service(value = "communityUserService")
-//public class CommunityUserService extends DefaultUserService {
-public class CommunityUserService implements UserService {
- private static final String COMMUNITY_CREDENTIAL_LOCATION="community.credential.location";
+public class CommunityUserService extends DefaultUserService {
+ // private static final String COMMUNITY_CREDENTIAL_LOCATION="community.credential.location";
+ private static final String COMMUNITY_CREDENTIAL_LOCATION="/tmp/x509up_u501";
private static int defaultPort = 7512;
private static int defaultLifeTime = 60*24*100;
private static String defaultServer="myproxy.teragrid.org";
@@ -95,12 +95,13 @@ public class CommunityUserService implem
@Autowired
public CommunityUserService(UserRepository userRepository) {
+ super(userRepository);
this.userRepository = userRepository;
myproxyHostname=defaultServer;
myproxyLifeTime=defaultLifeTime;
myproxyPortNumber=defaultPort;
- communityCredFile="";
+ communityCredFile=COMMUNITY_CREDENTIAL_LOCATION;
}
@Override
@@ -131,14 +132,16 @@ public class CommunityUserService implem
//Second, decorate the credential
String userName=user.getUsername();
- String userEmail="" ;//user.getEmail(); not implemented in User.java yet.
+ String userEmail=user.getEmail();
//This is the authentication instant for the user's portal session.
Date authnInstant=new Date();
- String ipAddress = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes())
- .getRequest().getRemoteAddr();
+ String ipAddress = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest().getRemoteAddr();
+
logger.info("SAMLAttributes to assign:"+userName+" "+userEmail+" "+authnInstant
+" "+ipAddress);
+ System.out.println("SAMLAttributes to assign:"+userName+" "+userEmail+" "+authnInstant
+ +" "+ipAddress);
String authnMethod=SAMLAuthenticationStatement.AuthenticationMethod_Password;
GSSCredential decoratedGssCred=GridShibUtils.decorateGSSCred(communityCred,
userName,
@@ -181,76 +184,4 @@ public class CommunityUserService implem
ex3.printStackTrace();
}
}
- @Override
- public User getAuthenticatedUser() {
- Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
-
- if (authentication != null && authentication.getPrincipal() instanceof User) {
- return (User) authentication.getPrincipal();
- } else {
- throw new SecurityException("Could not get the authenticated user!");
- }
- }
-
- @Override
- public void setAuthenticatedUser(long userId) {
- final User user = userRepository.get(userId);
- if(user == null) {
- throw new UsernameNotFoundException("User with id '" + userId + "' was not found!");
- }
- SecurityContext securityContext = createContext(user);
- SecurityContextHolder.setContext(securityContext);
- }
-
- @Override
- public void clearAuthenticatedUser() {
- SecurityContextHolder.clearContext();
- }
-
- private SecurityContext createContext(final User user) {
- SecurityContext securityContext = new SecurityContextImpl();
- securityContext.setAuthentication(new AbstractAuthenticationToken(user.getAuthorities()) {
- @Override
- public Object getCredentials() {
- return "N/A";
- }
-
- @Override
- public Object getPrincipal() {
- return user;
- }
-
- @Override
- public boolean isAuthenticated() {
- return true;
- }
- });
- return securityContext;
- }
-
- @Override
- @Transactional
- public void registerNewUser(User user) {
- userRepository.save(user);
- }
-
- @Override
- public User getUserById(Long id) {
- return userRepository.get(id);
- }
-
- @Override
- public User getUserByUsername(String userName){
- return userRepository.getByUsername(userName);
- }
-
- @Override
- public User getUserByEmail(String userEmail){
- return userRepository.getByUserEmail(userEmail);
- }
-
- @Override
- public void updateUserProfile(User user) {
- System.out.println("Updating user profile");
- }
}
\ No newline at end of file
Modified: incubator/rave/sandbox/science-gateways/rave-gateway-extensions/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/rave/sandbox/science-gateways/rave-gateway-extensions/src/main/webapp/WEB-INF/web.xml?rev=1162966&r1=1162965&r2=1162966&view=diff
==============================================================================
--- incubator/rave/sandbox/science-gateways/rave-gateway-extensions/src/main/webapp/WEB-INF/web.xml (original)
+++ incubator/rave/sandbox/science-gateways/rave-gateway-extensions/src/main/webapp/WEB-INF/web.xml Mon Aug 29 19:55:35 2011
@@ -39,6 +39,15 @@
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
+
+ <!--
+ This is needed to populate the RequestContextHolder needed by CommunityUserService to
+ get the client's IP address.
+ -->
+ <listener>
+ <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
+ </listener>
+
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>