Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SOCIAL-292: Added a SpringSecurity implementation of UserIdSource. Up…

…dated Gradle wrapper to 1.1.
  • Loading branch information...
commit dd4d460946e8f0ea601db6e8c8d2e40fb546ff3d 1 parent 11e295f
Craig Walls authored
View
43 build.gradle
@@ -17,18 +17,18 @@ configure(allprojects) {
sourceCompatibility=1.5
targetCompatibility=1.5
- h2Version = '1.3.168'
- hamcrestVersion = '1.3'
- httpComponentsVersion = '4.2.1'
- jacksonVersion = '1.9.9'
- javaxInjectVersion = '1'
- junitVersion = '4.10'
- mockitoVersion = '1.9.0'
- servletApiVersion = '2.5'
- springVersion = '3.1.2.RELEASE'
- springSecurityCryptoVersion = '3.1.1.RELEASE'
- springTestMvcVersion = '1.0.0.M1'
- jspApiVersion = '2.2.1'
+ ext.h2Version = '1.3.168'
+ ext.hamcrestVersion = '1.3'
+ ext.httpComponentsVersion = '4.2.1'
+ ext.jacksonVersion = '1.9.9'
+ ext.javaxInjectVersion = '1'
+ ext.junitVersion = '4.10'
+ ext.mockitoVersion = '1.9.0'
+ ext.servletApiVersion = '2.5'
+ ext.springVersion = '3.1.2.RELEASE'
+ ext.springSecurityVersion = '3.1.1.RELEASE'
+ ext.springTestMvcVersion = '1.0.0.M1'
+ ext.jspApiVersion = '2.2.1'
[compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:none']
@@ -97,10 +97,10 @@ configure(subprojects) { subproject ->
project('spring-social-core') {
description = 'Foundational module containing the ServiceProvider Connect Framework and Service API invocation support.'
dependencies {
- compile ("org.springframework:spring-jdbc:$springVersion") { optional = true }
+ compile ("org.springframework:spring-jdbc:$springVersion", optional)
compile ("org.springframework:spring-web:$springVersion")
- compile ("org.springframework.security:spring-security-crypto:$springSecurityCryptoVersion") { optional = true }
- compile ("org.apache.httpcomponents:httpclient:$httpComponentsVersion") { optional = true }
+ compile ("org.springframework.security:spring-security-crypto:$springSecurityVersion", optional)
+ compile ("org.apache.httpcomponents:httpclient:$httpComponentsVersion", optional)
testCompile "com.h2database:h2:$h2Version"
testCompile "org.springframework:spring-test-mvc:$springTestMvcVersion"
testCompile "org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion"
@@ -113,8 +113,8 @@ project('spring-social-web') {
compile ("javax.inject:javax.inject:$javaxInjectVersion")
compile "org.springframework:spring-web:$springVersion"
compile "org.springframework:spring-webmvc:$springVersion"
- compile ("javax.servlet:servlet-api:$servletApiVersion") { provided = true }
- compile ("javax.servlet.jsp:javax.servlet.jsp-api:$jspApiVersion") { provided = true }
+ compile ("javax.servlet:servlet-api:$servletApiVersion", provided)
+ compile ("javax.servlet.jsp:javax.servlet.jsp-api:$jspApiVersion", provided)
compile project(':spring-social-core')
testCompile "org.springframework:spring-test-mvc:$springTestMvcVersion"
testCompile "org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion"
@@ -130,7 +130,8 @@ project('spring-social-config') {
compile project(':spring-social-web')
compile ("org.springframework.social:spring-social-twitter:$version") { transitive = false }
compile ("org.springframework.social:spring-social-facebook:$version") { transitive = false }
- testCompile ("javax.servlet:servlet-api:$servletApiVersion") { provided = true }
+ compile ("org.springframework.security:spring-security-core:$springSecurityVersion", optional)
+ testCompile ("javax.servlet:servlet-api:$servletApiVersion", provided)
testCompile "com.h2database:h2:$h2Version"
testCompile "org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion"
}
@@ -142,7 +143,7 @@ configure(rootProject) {
apply plugin: 'docbook-reference'
reference {
- sourceDir = file('src/reference/docbook')
+ ext.sourceDir = file('src/reference/docbook')
}
// don't publish the default jar for the root project
@@ -224,7 +225,7 @@ configure(rootProject) {
description = "Builds -${classifier} archive, containing all jars and docs, " +
"suitable for community download page."
- baseDir = "${project.name}-${project.version}";
+ ext.baseDir = "${project.name}-${project.version}";
from('src/dist') {
include 'readme.txt'
@@ -263,7 +264,7 @@ configure(rootProject) {
task wrapper(type: Wrapper) {
description = 'Generates gradlew[.bat] scripts'
- gradleVersion = '1.0-milestone-8a'
+ gradleVersion = '1.1'
}
}
View
4 gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Thu Feb 23 13:43:17 CET 2012
+#Wed Aug 29 09:43:10 CDT 2012
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.0-milestone-8a-bin.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.1-bin.zip
View
4 gradlew
@@ -9,10 +9,6 @@
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
-# ADDED BY HAND -- DO NOT ACCIDENTALLY DELETE WHEN UPGRADING GRADLE WRAPPER!
-GRADLE_OPTS="-XX:MaxPermSize=1024m -Xmx1024m $GRADLE_OPTS"
-# END ADDED BY HAND
-
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
View
0  gradlew.bat 100755 → 100644
File mode changed
View
35 ...a/org/springframework/social/config/xml/SpringSecurityAuthenticationNameUserIdSource.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.social.config.xml;
+
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+/**
+ * Implementation of UserIdSource that returns the Spring Security {@link Authentication}'s name as the user ID.
+ * @author Craig Walls
+ */
+public class SpringSecurityAuthenticationNameUserIdSource implements UserIdSource {
+
+ public String getUserId() {
+ Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ if (authentication == null) {
+ throw new IllegalStateException("Unable to get a ConnectionRepository: no user signed in");
+ }
+ return authentication.getName();
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.