Permalink
Browse files

Commiting patch from Nick Padilla for Crowd Login Authentication Roll…

…er Integration


https://issues.apache.org/jira/browse/ROL-1933


git-svn-id: https://svn.apache.org/repos/asf/roller/trunk@1243258 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 541e232 commit bbe591a1c294a094824ab65d747e75d090c7dbbb @snoopdave snoopdave committed Feb 12, 2012
@@ -415,6 +415,23 @@ users.sso.autoProvision.className=\
org.apache.roller.weblogger.ui.core.security.BasicUserAutoProvision
+#----------------------------------
+# Atlassian Crowd authentication
+
+# required fields - if even one of these fields are not present we will not attempt crowd auth
+crowd.application.name=
+crowd.application.password=
+crowd.port=
+crowd.host=
+crowd.context=
+#end required fields
+
+#this setting allows the use of https, defaults to false; not present we will use plain socket.
+crowd.useSecureConnection=
+crowd.default.timezone=
+crowd.default.locale=
+
+
#-----------------------------------------------------------------------------
# Rendering system
#-----------------------------------------------------------------------------
View
@@ -4,6 +4,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+
+ <repositories>
+ <repository>
+ <id>com.atlassian</id>
+ <name>Atlassian Repository</name>
+ <url>http://maven.atlassian.com/public</url>
+ </repository>
+ </repositories>
<parent>
<groupId>org.apache.roller</groupId>
@@ -410,6 +418,30 @@
<artifactId>derbyclient</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>com.atlassian.crowd</groupId>
+ <artifactId>crowd-integration-client-rest</artifactId>
+ <version>2.4.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.6.4</version>
+ </dependency>
</dependencies>
@@ -1,59 +1,78 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. The ASF licenses this file to You
-* 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. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * 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. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
package org.apache.roller.weblogger.ui.core.security;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.roller.util.UUIDGenerator;
import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.business.WebloggerFactory;
import org.apache.roller.weblogger.business.UserManager;
import org.apache.roller.weblogger.pojos.User;
+import org.springframework.security.Authentication;
+import org.springframework.security.GrantedAuthority;
+import org.springframework.security.context.SecurityContextHolder;
/**
* @author Elias Torres (<a href="mailto:eliast@us.ibm.com">eliast@us.ibm.com</a>)
*
*/
public class BasicUserAutoProvision implements AutoProvision {
-
- private static Log log = LogFactory.getFactory().getInstance(BasicUserAutoProvision.class);
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.roller.weblogger.ui.core.security.AutoProvision#execute()
- */
- public boolean execute(HttpServletRequest request) {
- User ud = CustomUserRegistry.getUserDetailsFromAuthentication(request);
-
- if(ud != null) {
- UserManager mgr;
- try {
- mgr = WebloggerFactory.getWeblogger().getUserManager();
- mgr.addUser(ud);
- WebloggerFactory.getWeblogger().flush();
- } catch (WebloggerException e) {
- log.warn("Error while auto-provisioning user from SSO.", e);
- }
- }
-
- return true;
- }
+ private static Log log = LogFactory.getFactory().getInstance(BasicUserAutoProvision.class);
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.roller.weblogger.ui.core.security.AutoProvision#execute()
+ */
+ public boolean execute(HttpServletRequest request) {
+ User ud = CustomUserRegistry.getUserDetailsFromAuthentication(request);
+
+ if (ud != null) {
+ UserManager mgr;
+ try {
+ mgr = WebloggerFactory.getWeblogger().getUserManager();
+
+ // need to give an id to the new user if none exist
+ if (ud.getId() == null) {
+ ud.setId(UUIDGenerator.generateUUID());
+ }
+ mgr.addUser(ud);
+
+ // for some reason the User object doesn't contain a isAdmin setting
+ // so it makes it difficult to add grants without that info, so setting
+ // them manually here
+ Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ for (GrantedAuthority auth : authentication.getAuthorities()) {
+ if (auth.getAuthority().contains("admin") || auth.getAuthority().contains("ADMIN")) {
+ mgr.grantRole("admin", ud);
+ }
+ }
+ WebloggerFactory.getWeblogger().flush();
+
+ } catch (WebloggerException e) {
+ log.warn("Error while auto-provisioning user from SSO.", e);
+ }
+ }
+
+ return true;
+ }
}
Oops, something went wrong.

0 comments on commit bbe591a

Please sign in to comment.