//# 0 errors, 116 messages
//#
package net.sourceforge.pebble.security;
    //#defaultuserdetailsservice.java:1:1: class: net.sourceforge.pebble.security.DefaultUserDetailsService

import org.acegisecurity.userdetails.UserDetails;
import org.acegisecurity.userdetails.UserDetailsService;
import org.acegisecurity.userdetails.UsernameNotFoundException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Implementation of the UserDetailsService that gets authentication
 * credentials from a SecurityRealm implementation.
 *
 * @author    Simon Brown
 */
public class DefaultUserDetailsService implements UserDetailsService {
    //#defaultuserdetailsservice.java:15: method: void net.sourceforge.pebble.security.DefaultUserDetailsService.net.sourceforge.pebble.security.DefaultUserDetailsService()
    //#defaultuserdetailsservice.java:15: end of method: void net.sourceforge.pebble.security.DefaultUserDetailsService.net.sourceforge.pebble.security.DefaultUserDetailsService()

  private static final Log log = LogFactory.getLog(DefaultUserDetailsService.class);
    //#defaultuserdetailsservice.java:17: method: net.sourceforge.pebble.security.DefaultUserDetailsService.net.sourceforge.pebble.security.DefaultUserDetailsService__static_init
    //#defaultuserdetailsservice.java:17: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.security.DefaultUserDetailsService
    //#    method: net.sourceforge.pebble.security.DefaultUserDetailsService__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(net.sourceforge.pebble.security.DefaultUserDetailsService__static_init): __Descendant_Table[net/sourceforge/pebble/security/DefaultUserDetailsService]
    //#output(net.sourceforge.pebble.security.DefaultUserDetailsService__static_init): __Dispatch_Table.getSecurityRealm()Lnet/sourceforge/pebble/security/SecurityRealm;
    //#output(net.sourceforge.pebble.security.DefaultUserDetailsService__static_init): __Dispatch_Table.loadUserByUsername(Ljava/lang/String;)Lorg/acegisecurity/userdetails/UserDetails;
    //#output(net.sourceforge.pebble.security.DefaultUserDetailsService__static_init): __Dispatch_Table.setSecurityRealm(Lnet/sourceforge/pebble/security/SecurityRealm;)V
    //#output(net.sourceforge.pebble.security.DefaultUserDetailsService__static_init): log
    //#post(net.sourceforge.pebble.security.DefaultUserDetailsService__static_init): __Descendant_Table[net/sourceforge/pebble/security/DefaultUserDetailsService] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.security.DefaultUserDetailsService__static_init): __Dispatch_Table.getSecurityRealm()Lnet/sourceforge/pebble/security/SecurityRealm; == &getSecurityRealm
    //#post(net.sourceforge.pebble.security.DefaultUserDetailsService__static_init): __Dispatch_Table.loadUserByUsername(Ljava/lang/String;)Lorg/acegisecurity/userdetails/UserDetails; == &loadUserByUsername
    //#post(net.sourceforge.pebble.security.DefaultUserDetailsService__static_init): __Dispatch_Table.setSecurityRealm(Lnet/sourceforge/pebble/security/SecurityRealm;)V == &setSecurityRealm
    //#post(net.sourceforge.pebble.security.DefaultUserDetailsService__static_init): init'ed(log)
    //#defaultuserdetailsservice.java:17: end of method: net.sourceforge.pebble.security.DefaultUserDetailsService.net.sourceforge.pebble.security.DefaultUserDetailsService__static_init

  private SecurityRealm securityRealm;

  /**
   * Looks up and returns user details for the given username.
   *
   * @param username    the username to find details for
   * @return  a PebbleUserDetails instance
   * @throws org.acegisecurity.userdetails.UsernameNotFoundException
   */
  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    try {
      PebbleUserDetails user = securityRealm.getUser(username);
    //#defaultuserdetailsservice.java:30: method: UserDetails net.sourceforge.pebble.security.DefaultUserDetailsService.loadUserByUsername(String)
    //#defaultuserdetailsservice.java:30: Warning: method not available
    //#    -- call on PebbleUserDetails getUser(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.security.DefaultUserDetailsService
    //#    method: UserDetails loadUserByUsername(String)
    //#    unanalyzed callee: PebbleUserDetails getUser(String)
    //#input(UserDetails loadUserByUsername(String)): net/sourceforge/pebble/security/DefaultSecurityRealm.__Descendant_Table[net/sourceforge/pebble/security/DefaultSecurityRealm]
    //#input(UserDetails loadUserByUsername(String)): net/sourceforge/pebble/security/DefaultSecurityRealm.__Descendant_Table[others]
    //#input(UserDetails loadUserByUsername(String)): net/sourceforge/pebble/security/DefaultSecurityRealm.__Dispatch_Table.getFileForRealm()Ljava/io/File;
    //#input(UserDetails loadUserByUsername(String)): net/sourceforge/pebble/security/DefaultSecurityRealm.__Dispatch_Table.getFileForUser(Ljava/lang/String;)Ljava/io/File;
    //#input(UserDetails loadUserByUsername(String)): net/sourceforge/pebble/security/DefaultSecurityRealm.__Dispatch_Table.getUser(Ljava/lang/String;)Lnet/sourceforge/pebble/security/PebbleUserDetails;
    //#input(UserDetails loadUserByUsername(String)): net/sourceforge/pebble/security/SecurityRealm.__Descendant_Table[net/sourceforge/pebble/security/DefaultSecurityRealm]
    //#input(UserDetails loadUserByUsername(String)): net/sourceforge/pebble/security/SecurityRealm.__Descendant_Table[net/sourceforge/pebble/security/SecurityRealm]
    //#input(UserDetails loadUserByUsername(String)): net/sourceforge/pebble/security/SecurityRealm.__Descendant_Table[others]
    //#input(UserDetails loadUserByUsername(String)): net/sourceforge/pebble/security/SecurityRealm.__Dispatch_Table.getUser(Ljava/lang/String;)Lnet/sourceforge/pebble/security/PebbleUserDetails;
    //#input(UserDetails loadUserByUsername(String)): this
    //#input(UserDetails loadUserByUsername(String)): this.securityRealm
    //#input(UserDetails loadUserByUsername(String)): this.securityRealm.__Tag
    //#input(UserDetails loadUserByUsername(String)): this.securityRealm.configuration
    //#input(UserDetails loadUserByUsername(String)): username
    //#output(UserDetails loadUserByUsername(String)): new HashMap(PebbleUserDetails#1) num objects
    //#output(UserDetails loadUserByUsername(String)): new HashMap(getUser#3) num objects
    //#output(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4) num objects
    //#output(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4).__Tag
    //#output(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4).detailsUpdateable
    //#output(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4).emailAddress
    //#output(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4).grantedAuthories
    //#output(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4).name
    //#output(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4).password
    //#output(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4).preferences
    //#output(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4).profile
    //#output(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4).username
    //#output(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4).website
    //#output(UserDetails loadUserByUsername(String)): return_value
    //#new obj(UserDetails loadUserByUsername(String)): new HashMap(PebbleUserDetails#1)
    //#new obj(UserDetails loadUserByUsername(String)): new HashMap(getUser#3)
    //#new obj(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4)
    //#pre[2] (UserDetails loadUserByUsername(String)): this.securityRealm != null
    //#pre[3] (UserDetails loadUserByUsername(String)): this.securityRealm.__Tag == net/sourceforge/pebble/security/DefaultSecurityRealm
    //#pre[4] (UserDetails loadUserByUsername(String)): this.securityRealm.configuration != null
    //#presumption(UserDetails loadUserByUsername(String)): java.io.File:exists(...)@103 == 1
    //#presumption(UserDetails loadUserByUsername(String)): java.util.Iterator:hasNext(...)@126 == 0
    //#post(UserDetails loadUserByUsername(String)): return_value == &new PebbleUserDetails(getUser#4)
    //#post(UserDetails loadUserByUsername(String)): new HashMap(PebbleUserDetails#1) num objects == 1
    //#post(UserDetails loadUserByUsername(String)): new HashMap(getUser#3) num objects == 1
    //#post(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4) num objects == 1
    //#post(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4).__Tag == net/sourceforge/pebble/security/PebbleUserDetails
    //#post(UserDetails loadUserByUsername(String)): init'ed(new PebbleUserDetails(getUser#4).detailsUpdateable)
    //#post(UserDetails loadUserByUsername(String)): init'ed(new PebbleUserDetails(getUser#4).emailAddress)
    //#post(UserDetails loadUserByUsername(String)): init'ed(new PebbleUserDetails(getUser#4).grantedAuthories)
    //#post(UserDetails loadUserByUsername(String)): init'ed(new PebbleUserDetails(getUser#4).name)
    //#post(UserDetails loadUserByUsername(String)): init'ed(new PebbleUserDetails(getUser#4).password)
    //#post(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4).preferences == &new HashMap(getUser#3)
    //#post(UserDetails loadUserByUsername(String)): init'ed(new PebbleUserDetails(getUser#4).profile)
    //#post(UserDetails loadUserByUsername(String)): new PebbleUserDetails(getUser#4).username == username
    //#post(UserDetails loadUserByUsername(String)): init'ed(new PebbleUserDetails(getUser#4).username)
    //#post(UserDetails loadUserByUsername(String)): init'ed(new PebbleUserDetails(getUser#4).website)
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:net.sourceforge.pebble.Configuration:getDataDirectory
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.io.File
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:getFileForUser
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.io.File:exists
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.io.FileInputStream
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.util.Properties
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.util.Properties:load
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.io.FileInputStream:close
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.util.Properties:getProperty
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.lang.String:split
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.lang.String:equalsIgnoreCase
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.util.HashMap
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.util.Properties:keySet
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.util.Set:iterator
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.lang.String:startsWith
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.lang.String:length
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.lang.String:substring
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.util.Map:put
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.util.HashSet
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.lang.String:trim
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:org.acegisecurity.GrantedAuthorityImpl
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.util.Set:add
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.util.Set:toArray
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:net.sourceforge.pebble.PebbleException
    //#unanalyzed(UserDetails loadUserByUsername(String)): Effects-of-calling:java.lang.String:valueOf
      if (user == null) {
        throw new UsernameNotFoundException("A user with username " + username + " does not exist");
      } else {
        return user;
      }
    } catch (SecurityRealmException e) {
      throw new UsernameNotFoundException("User details not found", e);
    //#defaultuserdetailsservice.java:37: end of method: UserDetails net.sourceforge.pebble.security.DefaultUserDetailsService.loadUserByUsername(String)
    }
  }

  public SecurityRealm getSecurityRealm() {
    return securityRealm;
    //#defaultuserdetailsservice.java:42: method: SecurityRealm net.sourceforge.pebble.security.DefaultUserDetailsService.getSecurityRealm()
    //#input(SecurityRealm getSecurityRealm()): this
    //#input(SecurityRealm getSecurityRealm()): this.securityRealm
    //#output(SecurityRealm getSecurityRealm()): return_value
    //#pre[2] (SecurityRealm getSecurityRealm()): init'ed(this.securityRealm)
    //#post(SecurityRealm getSecurityRealm()): return_value == this.securityRealm
    //#post(SecurityRealm getSecurityRealm()): init'ed(return_value)
    //#defaultuserdetailsservice.java:42: end of method: SecurityRealm net.sourceforge.pebble.security.DefaultUserDetailsService.getSecurityRealm()
  }

  public void setSecurityRealm(SecurityRealm securityRealm) {
    this.securityRealm = securityRealm;
    //#defaultuserdetailsservice.java:46: method: void net.sourceforge.pebble.security.DefaultUserDetailsService.setSecurityRealm(SecurityRealm)
    //#input(void setSecurityRealm(SecurityRealm)): securityRealm
    //#input(void setSecurityRealm(SecurityRealm)): this
    //#output(void setSecurityRealm(SecurityRealm)): this.securityRealm
    //#post(void setSecurityRealm(SecurityRealm)): this.securityRealm == securityRealm
    //#post(void setSecurityRealm(SecurityRealm)): init'ed(this.securityRealm)
  }
    //#defaultuserdetailsservice.java:47: end of method: void net.sourceforge.pebble.security.DefaultUserDetailsService.setSecurityRealm(SecurityRealm)

}    //#defaultuserdetailsservice.java:: end of class: net.sourceforge.pebble.security.DefaultUserDetailsService
