Author: mraible
Date: Tue Oct 23 07:20:41 2007
New Revision: 587514
URL: http://svn.apache.org/viewvc?rev=587514&view=rev
Log:
ROL-1582: Added RollerCasPopulator that allows Roller to integrate with CAS
more easily
Added:
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerCasPopulator.java
Added:
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerCasPopulator.java
URL:
http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerCasPopulator.java?rev=587514&view=auto
==============================================================================
---
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerCasPopulator.java
(added)
+++
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerCasPopulator.java
Tue Oct 23 07:20:41 2007
@@ -0,0 +1,49 @@
+/*
+* 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.acegisecurity.AuthenticationException;
+import org.acegisecurity.GrantedAuthority;
+import org.acegisecurity.GrantedAuthorityImpl;
+import org.acegisecurity.providers.cas.CasAuthoritiesPopulator;
+import org.acegisecurity.userdetails.User;
+import org.acegisecurity.userdetails.UserDetails;
+import org.acegisecurity.userdetails.UserDetailsService;
+import org.apache.log4j.Logger;
+
+/**
+ * An implementation of CasAuthoritiesPopulator that uses a UserDetailsService
to retrieve
+ * User object from RollerDB.
+ */
+public class RollerCasPopulator implements CasAuthoritiesPopulator {
+ private static final Logger logger =
Logger.getLogger(RollerCasPopulator.class);
+ private UserDetailsService userDetailsService;
+
+ public void setUserDetailsService(UserDetailsService userDetailsService) {
+ this.userDetailsService = userDetailsService;
+ }
+
+ public UserDetails getUserDetails(String userName) throws
AuthenticationException {
+ User userObject = (User)
userDetailsService.loadUserByUsername(userName);
+
+ // in a more sophisticated implementation we would look up and insert
+ // GrantedAuthoritys here.
+
+ return userObject;
+ }
+}
\ No newline at end of file