File Source: RollerCasPopulator.java

     1  /*
     2  * Licensed to the Apache Software Foundation (ASF) under one or more
     3  *  contributor license agreements.  The ASF licenses this file to You
     4  * under the Apache License, Version 2.0 (the "License"); you may not
     5  * use this file except in compliance with the License.
     6  * You may obtain a copy of the License at
     7  *
     8  *     http://www.apache.org/licenses/LICENSE-2.0
     9  *
    10  * Unless required by applicable law or agreed to in writing, software
    11  * distributed under the License is distributed on an "AS IS" BASIS,
    12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  * See the License for the specific language governing permissions and
    14  * limitations under the License.  For additional information regarding
    15  * copyright in this work, please see the NOTICE file in the top level
    16  * directory of this distribution.
    17  */
    18  package org.apache.roller.weblogger.ui.core.security;
    19  
    20  import org.acegisecurity.AuthenticationException;
    21  import org.acegisecurity.GrantedAuthority;
    22  import org.acegisecurity.GrantedAuthorityImpl;
    23  import org.acegisecurity.providers.cas.CasAuthoritiesPopulator;
    24  import org.acegisecurity.userdetails.User;
    25  import org.acegisecurity.userdetails.UserDetails;
    26  import org.acegisecurity.userdetails.UserDetailsService;
    27  import org.apache.log4j.Logger;
    28  
    29  /**
    30   * An implementation of CasAuthoritiesPopulator that uses a UserDetailsService to retrieve
    31   * User object from RollerDB. 
    32   * 
    33   * @author Phillip Rhodes (<a href="mailto:mindcrime@cpphacker.co.uk">mindcrime@cpphacker.co.uk</a>)
    34   */
         /* 
    P/P   *  Method: void org.apache.roller.weblogger.ui.core.security.RollerCasPopulator()
          */
    35  public class RollerCasPopulator implements CasAuthoritiesPopulator {
             /* 
    P/P       *  Method: org.apache.roller.weblogger.ui.core.security.RollerCasPopulator__static_init
              * 
              *  Postconditions:
              *    init'ed(logger)
              */
    36      private static final Logger logger = Logger.getLogger(RollerCasPopulator.class);
    37      private UserDetailsService userDetailsService;
    38  
    39      public void setUserDetailsService(UserDetailsService userDetailsService) {
                 /* 
    P/P           *  Method: void setUserDetailsService(UserDetailsService)
                  * 
                  *  Postconditions:
                  *    this.userDetailsService == userDetailsService
                  *    init'ed(this.userDetailsService)
                  */
    40          this.userDetailsService = userDetailsService;
    41      }
    42  
    43      public UserDetails getUserDetails(String userName) throws AuthenticationException {
                 /* 
    P/P           *  Method: UserDetails getUserDetails(String)
                  * 
                  *  Preconditions:
                  *    this.userDetailsService != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    44          User userObject = (User) userDetailsService.loadUserByUsername(userName);
    45  
    46          // in  a more sophisticated implementation we would look up and insert
    47          // GrantedAuthoritys here.
    48  
    49          return userObject;
    50      }
    51  }








SofCheck Inspector Build Version : 2.18479
RollerCasPopulator.java 2009-Jan-02 14:25:42
RollerCasPopulator.class 2009-Sep-04 03:12:44