Author: snoopdave
Date: Sun Feb 12 14:57:08 2012
New Revision: 1243258

URL: http://svn.apache.org/viewvc?rev=1243258&view=rev
Log:
Commiting patch from Nick Padilla for Crowd Login Authentication Roller 
Integration
https://issues.apache.org/jira/browse/ROL-1933

Added:
    
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/CrowdAuthenticationProvider.java
    
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/CrowdRollerUserDetails.java
Modified:
    
roller/trunk/weblogger-business/src/main/resources/org/apache/roller/weblogger/config/roller.properties
    roller/trunk/weblogger-web/pom.xml
    
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/BasicUserAutoProvision.java
    roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/security.xml

Modified: 
roller/trunk/weblogger-business/src/main/resources/org/apache/roller/weblogger/config/roller.properties
URL: 
http://svn.apache.org/viewvc/roller/trunk/weblogger-business/src/main/resources/org/apache/roller/weblogger/config/roller.properties?rev=1243258&r1=1243257&r2=1243258&view=diff
==============================================================================
--- 
roller/trunk/weblogger-business/src/main/resources/org/apache/roller/weblogger/config/roller.properties
 (original)
+++ 
roller/trunk/weblogger-business/src/main/resources/org/apache/roller/weblogger/config/roller.properties
 Sun Feb 12 14:57:08 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
 #-----------------------------------------------------------------------------

Modified: roller/trunk/weblogger-web/pom.xml
URL: 
http://svn.apache.org/viewvc/roller/trunk/weblogger-web/pom.xml?rev=1243258&r1=1243257&r2=1243258&view=diff
==============================================================================
--- roller/trunk/weblogger-web/pom.xml (original)
+++ roller/trunk/weblogger-web/pom.xml Sun Feb 12 14:57:08 2012
@@ -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>
 

Modified: 
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/BasicUserAutoProvision.java
URL: 
http://svn.apache.org/viewvc/roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/BasicUserAutoProvision.java?rev=1243258&r1=1243257&r2=1243258&view=diff
==============================================================================
--- 
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/BasicUserAutoProvision.java
 (original)
+++ 
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/BasicUserAutoProvision.java
 Sun Feb 12 14:57:08 2012
@@ -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:[email protected]";>[email protected]</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);
-      }
-    }
+       private static Log log = 
LogFactory.getFactory().getInstance(BasicUserAutoProvision.class);
 
-    return true;
-  }
+       /*
+        * (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;
+       }
 }

Added: 
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/CrowdAuthenticationProvider.java
URL: 
http://svn.apache.org/viewvc/roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/CrowdAuthenticationProvider.java?rev=1243258&view=auto
==============================================================================
--- 
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/CrowdAuthenticationProvider.java
 (added)
+++ 
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/CrowdAuthenticationProvider.java
 Sun Feb 12 14:57:08 2012
@@ -0,0 +1,234 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.config.WebloggerConfig;
+import org.springframework.context.support.MessageSourceAccessor;
+import org.springframework.security.Authentication;
+import org.springframework.security.AuthenticationException;
+import org.springframework.security.AuthenticationServiceException;
+import org.springframework.security.BadCredentialsException;
+import org.springframework.security.CredentialsExpiredException;
+import org.springframework.security.DisabledException;
+import org.springframework.security.GrantedAuthority;
+import org.springframework.security.GrantedAuthorityImpl;
+import org.springframework.security.SpringSecurityMessageSource;
+import org.springframework.security.providers.AuthenticationProvider;
+import 
org.springframework.security.providers.UsernamePasswordAuthenticationToken;
+import org.springframework.security.userdetails.UsernameNotFoundException;
+import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
+
+import com.atlassian.crowd.exception.ApplicationPermissionException;
+import com.atlassian.crowd.exception.ExpiredCredentialException;
+import com.atlassian.crowd.exception.InactiveAccountException;
+import com.atlassian.crowd.exception.InvalidAuthenticationException;
+import com.atlassian.crowd.exception.OperationFailedException;
+import com.atlassian.crowd.exception.UserNotFoundException;
+import 
com.atlassian.crowd.integration.rest.service.factory.RestCrowdClientFactory;
+import com.atlassian.crowd.model.group.Group;
+import com.atlassian.crowd.model.user.User;
+import com.atlassian.crowd.service.client.CrowdClient;
+
+/**
+ * Provides authentication and permissions assignment from a Atlassian Crowd 
instance.  Must have the crowd settings in
+ * the roller-custom.properties file.  Here is an example file:
+ * <br/>
+ *     <pre>
+ *             #required fields
+ *             crowd.application.name=roller
+ *             crowd.application.password=password
+ *             crowd.port=8095
+ *             crowd.host=localhost
+ *             crowd.context=crowd
+ *             #end required fields
+ *             #this setting allows the use of https, defaults to false; not 
present we will use plain socket.
+ *             crowd.useSecureConnection=false
+ *             crowd.default.timezone=
+ *             crowd.default.locale=
+ *     </pre>
+ * <br/>
+ * If the required fields are not provided crowd authentication is not 
attempted.  There will be a LOG out if this
+ * condition occurs.  
+ * <br/>
+ * <br/>
+ * Here are the other settings needed in the roller-custom.properties file to 
make CrowdAuthentication work with Roller.
+ * <br/>
+ *  <pre>
+ *             # Crowd Auth, need these settings to be enabled
+ *             users.sso.enabled=true
+ *             users.sso.autoProvision.enabled=true
+ *     </pre>
+ * <br/>
+ * If these are not set Crowd authentication will not work correctly.  The 
AutoProvision is what makes this all work, the users from 
+ * Crowd and not in Roller will be saved to Rollers db the first time the log 
in. The reason this is needed is so that permissions can 
+ * be written for Roller. Will still need to add some code to ensure when 
users get promoted or demoted, those changes make it to the
+ * Roller DB.
+ * <br/>
+ * <br/>
+ * <b>NOTE:</b> Once an Roller user has been authenticated by Crowd the user 
account will not longer authenticate through Roller.  If
+ * the Crowd user doesn't exist in the Roller db the user will be created in 
Roller.  There are two types of users "editor" and "admin".
+ * If a user doesn't belong to any group when the Roller account is created 
then the user will only have "editor" rights.  User has 
+ * to belong to an "admin" group to be considered an Admin in Roller, an 
"editor" group is not needed but good to ensure easy administration
+ * of users.
+ * <br/>
+ * @author Nicholas Padilla (<a 
href="mailto:[email protected]";>[email protected]</a>)
+ *
+ */
+public class CrowdAuthenticationProvider implements AuthenticationProvider {
+       private static Log LOG = 
LogFactory.getLog(CrowdAuthenticationProvider.class);
+
+       private MessageSourceAccessor messages = 
SpringSecurityMessageSource.getAccessor();
+
+       private CrowdClient crowdClient = null;
+       private String crowdTimezone = "";
+       private String crowdLocale = "";
+
+       public CrowdAuthenticationProvider() {
+               String appName = 
WebloggerConfig.getProperty("crowd.application.name");
+               String appPass = 
WebloggerConfig.getProperty("crowd.application.password");
+               String crowdHost = WebloggerConfig.getProperty("crowd.host");
+               String crowdPort = WebloggerConfig.getProperty("crowd.port");
+               crowdTimezone = 
WebloggerConfig.getProperty("crowd.default.timezone");
+               crowdLocale = 
WebloggerConfig.getProperty("crowd.default.locale");
+               String crowdUrlContext = 
WebloggerConfig.getProperty("crowd.context");
+               boolean useSecureLogin = 
WebloggerConfig.getBooleanProperty("crowd.useSecureConnection", false);
+
+               if(!appName.isEmpty() 
+                               && !appPass.isEmpty() 
+                               && !crowdHost.isEmpty()
+                               && !crowdPort.isEmpty() 
+                               && !crowdUrlContext.isEmpty()){
+
+                       String url = "";
+                       if(useSecureLogin){
+                               url = "https://";;
+                       } else {
+                               url = "http://";;
+                       }
+                       url += crowdHost + ":" + crowdPort + "/" + 
crowdUrlContext;
+                       crowdClient = new 
RestCrowdClientFactory().newInstance(url, appName, appPass);
+               }else{
+                       LOG.warn("Required Crowd Properties Not Found! - Crowd 
Authentication Not Attempted!");
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see 
org.springframework.security.providers.AuthenticationProvider#authenticate(org.springframework.security.Authentication)
+        */
+       public Authentication authenticate(Authentication authentication) 
throws AuthenticationException {
+               Assert.isInstanceOf(UsernamePasswordAuthenticationToken.class, 
authentication, 
+                               
messages.getMessage("AbstractUserDetailsAuthenticationProvider.onlySupports",
+                                               "Only 
UsernamePasswordAuthenticationToken is supported"));
+
+               UsernamePasswordAuthenticationToken authenticationToken = null;
+               if(crowdClient != null){
+                       UsernamePasswordAuthenticationToken userToken = 
(UsernamePasswordAuthenticationToken)authentication;
+                       String password = (String) 
authentication.getCredentials();
+                       String username = userToken.getName();
+
+                       Assert.notNull(password, "Null password was supplied in 
authentication token");
+
+                       if(!StringUtils.hasLength(username)) {
+                               throw new 
BadCredentialsException(messages.getMessage("CrowdAuthenticationProvider.emptyUsername",
 "Empty Username"));
+                       }
+
+                       if(password.length() == 0) {
+                               LOG.debug("Rejecting empty password for user " 
+ username);
+                               throw new 
BadCredentialsException(messages.getMessage("CrowdAuthenticationProvider.emptyPassword",
 "Empty Password"));
+                       }                       
+
+                       try {
+
+                               User user = 
crowdClient.authenticateUser(authentication.getName(), 
authentication.getCredentials().toString());
+
+                               GrantedAuthority[] grantedAuthorities = 
getGrantedAuthorities(user);
+                               // this is the required constructor, since we 
don't know any of the boolean values
+                               // and we can assume if the employee is active 
and we have gotten this far, these values
+                               // can be set to the isActive() field on the 
crowd User object.
+                               // NOTE: null values for timeZone and locale 
are okay, they are dealt with at another level.
+                               CrowdRollerUserDetails crowdRollerUserDetails = 
+                                               new 
CrowdRollerUserDetails(user, authentication.getCredentials().toString(), 
crowdTimezone, crowdLocale, grantedAuthorities);
+
+                               authenticationToken = new 
UsernamePasswordAuthenticationToken(crowdRollerUserDetails, 
authentication.getCredentials(), grantedAuthorities);
+
+                       } catch (UserNotFoundException e) {
+                               throw new 
UsernameNotFoundException(e.getMessage(), e);
+                       } catch (InactiveAccountException e) {
+                               throw new DisabledException(e.getMessage(), e);
+                       } catch (ExpiredCredentialException e) {
+                               throw new 
CredentialsExpiredException(e.getMessage(), e);
+                       } catch (InvalidAuthenticationException e) {
+                               throw new 
BadCredentialsException(e.getMessage(), e);
+                       } catch (ApplicationPermissionException e) {
+                               throw new 
AuthenticationServiceException(e.getMessage(), e);
+                       } catch (OperationFailedException e) {
+                               throw new 
AuthenticationServiceException(e.getMessage(), e);
+                       }
+               }
+               return authenticationToken;
+       }
+
+       /* (non-Javadoc)
+        * @see 
org.springframework.security.providers.AuthenticationProvider#supports(java.lang.Class)
+        */
+       @SuppressWarnings("rawtypes")
+       public boolean supports(Class authentication) {
+               return 
(UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication));
+       }
+
+       private List<String> getPermissions(User user)  throws 
OperationFailedException, InvalidAuthenticationException,
+                                                                               
                                        ApplicationPermissionException, 
UserNotFoundException {
+               List<String> authorities = new ArrayList<String>();
+               // not sure why this is needed??
+               authorities.add("ROLE_USER");
+
+               // Optional: Define granted authorities based on
+               // groups to which the user is a member.
+               List<Group> groups = 
crowdClient.getGroupsForUser(user.getName(), 0, -1);
+               for(Group group: groups) {
+                       if(group.isActive()){
+                               if (group.getName().contains("admin") || 
group.getName().contains("ADMIN")){
+                                       // setup admin here
+                                       authorities.add("admin");
+                               }else if(group.getName().contains("editor") || 
group.getName().contains("EDITOR")){
+                                       // setup editor
+                                       authorities.add("editor");
+                               }
+                       }
+               }
+               return authorities;
+       }
+
+       private GrantedAuthority[] getGrantedAuthorities(User user) throws 
UserNotFoundException, OperationFailedException, 
+                                                                               
                                                                
InvalidAuthenticationException, ApplicationPermissionException {
+               List<String> roles = getPermissions(user);
+               GrantedAuthority[] authorities = new 
GrantedAuthorityImpl[roles.size()];
+               int i = 0;
+               for (String role : roles) {
+                       authorities[i++] = new GrantedAuthorityImpl(role);
+               }
+               return authorities;
+       }
+
+}

Added: 
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/CrowdRollerUserDetails.java
URL: 
http://svn.apache.org/viewvc/roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/CrowdRollerUserDetails.java?rev=1243258&view=auto
==============================================================================
--- 
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/CrowdRollerUserDetails.java
 (added)
+++ 
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/core/security/CrowdRollerUserDetails.java
 Sun Feb 12 14:57:08 2012
@@ -0,0 +1,147 @@
+/*
+ * 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 org.springframework.security.GrantedAuthority;
+
+import com.atlassian.crowd.model.user.User;
+
+/**
+ * Provides a {@link RollerUserDetails} that gets populated by the Atlassian 
Crowd Spring Security integration so that Roller 
+ * can correctly build a Roller {@link org.apache.roller.weblogger.pojos.User}.
+ * @author Nicholas Padilla (<a 
href="mailto:[email protected]";>[email protected]</a>)
+ *
+ */
+public class CrowdRollerUserDetails implements RollerUserDetails {
+       
+       /**
+        * 
+        */
+       private static final long serialVersionUID = -7160979756917382584L;
+       private User user;
+       private String password;
+       private String timeZone;
+       private String locale;
+       private GrantedAuthority[] grantedAuthorities;
+
+       /**
+        * This constructor will build all the needed data needed to correctly 
authenticate
+        * and persist a roller user. This is needed because of the need to 
control the 
+        * actions based on roller_user_permissions table.  Authentication will 
still 
+        * happen on Crowd side.
+        * @param user
+        * @param password
+        * @param timeZone
+        * @param locale
+        * @param grantedAuthorities
+        */
+       public CrowdRollerUserDetails(User user, String password, String 
timeZone,
+                       String locale, GrantedAuthority[] grantedAuthorities) {
+               super();
+               this.user = user;
+               this.password = password;
+               this.timeZone = timeZone;
+               this.locale = locale;
+               this.grantedAuthorities = grantedAuthorities;
+       }
+
+       /* (non-Javadoc)
+        * @see 
org.springframework.security.userdetails.UserDetails#getAuthorities()
+        */
+       public GrantedAuthority[] getAuthorities() {
+               return grantedAuthorities;
+       }
+
+       /* (non-Javadoc)
+        * @see 
org.springframework.security.userdetails.UserDetails#getPassword()
+        */
+       public String getPassword() {
+               return password;
+       }
+
+       /* (non-Javadoc)
+        * @see 
org.springframework.security.userdetails.UserDetails#getUsername()
+        */
+       public String getUsername() {
+               return user.getName();
+       }
+
+       /* (non-Javadoc)
+        * @see 
org.springframework.security.userdetails.UserDetails#isAccountNonExpired()
+        */
+       public boolean isAccountNonExpired() {
+               return user.isActive();
+       }
+
+       /* (non-Javadoc)
+        * @see 
org.springframework.security.userdetails.UserDetails#isAccountNonLocked()
+        */
+       public boolean isAccountNonLocked() {
+               return user.isActive();
+       }
+
+       /* (non-Javadoc)
+        * @see 
org.springframework.security.userdetails.UserDetails#isCredentialsNonExpired()
+        */
+       public boolean isCredentialsNonExpired() {
+               return user.isActive();
+       }
+
+       /* (non-Javadoc)
+        * @see org.springframework.security.userdetails.UserDetails#isEnabled()
+        */
+       public boolean isEnabled() {
+               return user.isActive();
+       }
+
+       /* (non-Javadoc)
+        * @see 
org.apache.roller.weblogger.ui.core.security.RollerUserDetails#getTimeZone()
+        */
+       public String getTimeZone() {
+               return timeZone;
+       }
+
+       /* (non-Javadoc)
+        * @see 
org.apache.roller.weblogger.ui.core.security.RollerUserDetails#getLocale()
+        */
+       public String getLocale() {
+               return locale;
+       }
+
+       /* (non-Javadoc)
+        * @see 
org.apache.roller.weblogger.ui.core.security.RollerUserDetails#getScreenName()
+        */
+       public String getScreenName() {
+               return user.getDisplayName();
+       }
+
+       /* (non-Javadoc)
+        * @see 
org.apache.roller.weblogger.ui.core.security.RollerUserDetails#getFullName()
+        */
+       public String getFullName() {
+               return user.getFirstName() + " " + user.getLastName();
+       }
+
+       /* (non-Javadoc)
+        * @see 
org.apache.roller.weblogger.ui.core.security.RollerUserDetails#getEmailAddress()
+        */
+       public String getEmailAddress() {
+               return user.getEmailAddress();
+       }
+
+}

Modified: roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/security.xml
URL: 
http://svn.apache.org/viewvc/roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/security.xml?rev=1243258&r1=1243257&r2=1243258&view=diff
==============================================================================
--- roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/security.xml 
(original)
+++ roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/security.xml Sun Feb 
12 14:57:08 2012
@@ -97,5 +97,10 @@ http://www.springframework.org/schema/se
         <beans:property name="authenticationManager" 
ref="authenticationManagerAlias"/>
         <custom-filter position="OPENID_PROCESSING_FILTER"/>
     </beans:bean>
+    
+    <beans:bean id="rollerCrowdAuthenticationService"
+                
class="org.apache.roller.weblogger.ui.core.security.CrowdAuthenticationProvider">
+           <custom-authentication-provider/>
+    </beans:bean>  
 
 </beans:beans>


Reply via email to