//# 0 errors, 143 messages
//#
/*
    //#CustomUserRegistry.java:1:1: class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
 * 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.Locale;
import java.util.TimeZone;

import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;

import org.acegisecurity.Authentication;
import org.acegisecurity.context.SecurityContextHolder;
import org.acegisecurity.userdetails.UserDetails;
import org.acegisecurity.userdetails.ldap.LdapUserDetails;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.config.WebloggerConfig;
import org.apache.roller.weblogger.pojos.User;

/**
 * @author Elias Torres (<a href="mailto:eliast@us.ibm.com">eliast@us.ibm.com</a>)
 *
 */
public class CustomUserRegistry {
    //#CustomUserRegistry.java:40: method: void org.apache.roller.weblogger.ui.core.security.CustomUserRegistry.org.apache.roller.weblogger.ui.core.security.CustomUserRegistry()
    //#CustomUserRegistry.java:40: end of method: void org.apache.roller.weblogger.ui.core.security.CustomUserRegistry.org.apache.roller.weblogger.ui.core.security.CustomUserRegistry()
    
    private static Log log = LogFactory.getLog(CustomUserRegistry.class);
    //#CustomUserRegistry.java:42: method: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry.org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init
    //#CustomUserRegistry.java:42: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): DEFAULT_EMAIL_LDAP_ATTRIBUTE
    //#output(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): DEFAULT_LOCALE_LDAP_ATTRIBUTE
    //#output(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): DEFAULT_NAME_LDAP_ATTRIBUTE
    //#output(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): DEFAULT_SNAME_LDAP_ATTRIBUTE
    //#output(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): DEFAULT_TIMEZONE_LDAP_ATTRIBUTE
    //#output(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): EMAIL_LDAP_PROPERTY
    //#output(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): LOCALE_LDAP_PROPERTY
    //#output(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): NAME_LDAP_PROPERTY
    //#output(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): SNAME_LDAP_PROPERTY
    //#output(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): TIMEZONE_LDAP_PROPERTY
    //#output(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/core/security/CustomUserRegistry]
    //#output(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): log
    //#post(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): DEFAULT_EMAIL_LDAP_ATTRIBUTE == &"mail"
    //#post(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): DEFAULT_LOCALE_LDAP_ATTRIBUTE == &"locale"
    //#post(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): DEFAULT_NAME_LDAP_ATTRIBUTE == &"cn"
    //#post(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): DEFAULT_SNAME_LDAP_ATTRIBUTE == &"screenname"
    //#post(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): DEFAULT_TIMEZONE_LDAP_ATTRIBUTE == &"timezone"
    //#post(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): EMAIL_LDAP_PROPERTY == &"users.sso.registry.ldap.attributes.email"
    //#post(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): LOCALE_LDAP_PROPERTY == &"users.sso.registry.ldap.attributes.locale"
    //#post(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): NAME_LDAP_PROPERTY == &"users.sso.registry.ldap.attributes.name"
    //#post(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): SNAME_LDAP_PROPERTY == &"users.sso.registry.ldap.attributes.screenname"
    //#post(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): TIMEZONE_LDAP_PROPERTY == &"users.sso.registry.ldap.attributes.timezone"
    //#post(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/core/security/CustomUserRegistry] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init): init'ed(log)
    
    private static String DEFAULT_SNAME_LDAP_ATTRIBUTE = "screenname";
    private static String DEFAULT_NAME_LDAP_ATTRIBUTE = "cn";
    private static String DEFAULT_EMAIL_LDAP_ATTRIBUTE = "mail";
    private static String DEFAULT_LOCALE_LDAP_ATTRIBUTE = "locale";
    private static String DEFAULT_TIMEZONE_LDAP_ATTRIBUTE = "timezone";
    
    private static String SNAME_LDAP_PROPERTY = "users.sso.registry.ldap.attributes.screenname";
    private static String NAME_LDAP_PROPERTY = "users.sso.registry.ldap.attributes.name";
    private static String EMAIL_LDAP_PROPERTY = "users.sso.registry.ldap.attributes.email";
    private static String LOCALE_LDAP_PROPERTY = "users.sso.registry.ldap.attributes.locale";
    private static String TIMEZONE_LDAP_PROPERTY = "users.sso.registry.ldap.attributes.timezone";
    //#CustomUserRegistry.java:54: end of method: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry.org.apache.roller.weblogger.ui.core.security.CustomUserRegistry__static_init
    
    public static User getUserDetailsFromAuthentication() {
        boolean usingSSO = WebloggerConfig.getBooleanProperty("users.sso.enabled");
    //#CustomUserRegistry.java:57: method: User org.apache.roller.weblogger.ui.core.security.CustomUserRegistry.getUserDetailsFromAuthentication()
    //#CustomUserRegistry.java:57: Warning: method not available
    //#    -- call on bool org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: bool org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty(String)
    //#input(User getUserDetailsFromAuthentication()): DEFAULT_EMAIL_LDAP_ATTRIBUTE
    //#input(User getUserDetailsFromAuthentication()): DEFAULT_LOCALE_LDAP_ATTRIBUTE
    //#input(User getUserDetailsFromAuthentication()): DEFAULT_NAME_LDAP_ATTRIBUTE
    //#input(User getUserDetailsFromAuthentication()): DEFAULT_SNAME_LDAP_ATTRIBUTE
    //#input(User getUserDetailsFromAuthentication()): DEFAULT_TIMEZONE_LDAP_ATTRIBUTE
    //#input(User getUserDetailsFromAuthentication()): EMAIL_LDAP_PROPERTY
    //#input(User getUserDetailsFromAuthentication()): LOCALE_LDAP_PROPERTY
    //#input(User getUserDetailsFromAuthentication()): NAME_LDAP_PROPERTY
    //#input(User getUserDetailsFromAuthentication()): SNAME_LDAP_PROPERTY
    //#input(User getUserDetailsFromAuthentication()): TIMEZONE_LDAP_PROPERTY
    //#input(User getUserDetailsFromAuthentication()): java.lang.Boolean.FALSE
    //#input(User getUserDetailsFromAuthentication()): java.lang.Boolean.TRUE
    //#input(User getUserDetailsFromAuthentication()): log
    //#input(User getUserDetailsFromAuthentication()): org/apache/roller/weblogger/ui/core/security/RollerUserDetails.__Descendant_Table[org/apache/roller/weblogger/ui/core/security/RollerUserDetails]
    //#input(User getUserDetailsFromAuthentication()): org/apache/roller/weblogger/ui/core/security/RollerUserDetails.__Descendant_Table[others]
    //#input(User getUserDetailsFromAuthentication()): org/apache/roller/weblogger/ui/core/security/RollerUserDetails.__Dispatch_Table.getFullName()Ljava/lang/String;
    //#input(User getUserDetailsFromAuthentication()): org/apache/roller/weblogger/ui/core/security/RollerUserDetails.__Dispatch_Table.getLocale()Ljava/lang/String;
    //#input(User getUserDetailsFromAuthentication()): org/apache/roller/weblogger/ui/core/security/RollerUserDetails.__Dispatch_Table.getScreenName()Ljava/lang/String;
    //#input(User getUserDetailsFromAuthentication()): org/apache/roller/weblogger/ui/core/security/RollerUserDetails.__Dispatch_Table.getTimeZone()Ljava/lang/String;
    //#output(User getUserDetailsFromAuthentication()): new User(getUserDetailsFromAuthentication#1) num objects
    //#output(User getUserDetailsFromAuthentication()): return_value
    //#new obj(User getUserDetailsFromAuthentication()): new User(getUserDetailsFromAuthentication#1)
    //#pre[1] (User getUserDetailsFromAuthentication()): (soft) init'ed(DEFAULT_EMAIL_LDAP_ATTRIBUTE)
    //#pre[2] (User getUserDetailsFromAuthentication()): (soft) init'ed(DEFAULT_LOCALE_LDAP_ATTRIBUTE)
    //#pre[3] (User getUserDetailsFromAuthentication()): (soft) init'ed(DEFAULT_NAME_LDAP_ATTRIBUTE)
    //#pre[4] (User getUserDetailsFromAuthentication()): (soft) init'ed(DEFAULT_SNAME_LDAP_ATTRIBUTE)
    //#pre[5] (User getUserDetailsFromAuthentication()): (soft) init'ed(DEFAULT_TIMEZONE_LDAP_ATTRIBUTE)
    //#pre[6] (User getUserDetailsFromAuthentication()): (soft) init'ed(EMAIL_LDAP_PROPERTY)
    //#pre[7] (User getUserDetailsFromAuthentication()): (soft) init'ed(LOCALE_LDAP_PROPERTY)
    //#pre[8] (User getUserDetailsFromAuthentication()): (soft) init'ed(NAME_LDAP_PROPERTY)
    //#pre[9] (User getUserDetailsFromAuthentication()): (soft) init'ed(SNAME_LDAP_PROPERTY)
    //#pre[10] (User getUserDetailsFromAuthentication()): (soft) init'ed(TIMEZONE_LDAP_PROPERTY)
    //#pre[11] (User getUserDetailsFromAuthentication()): (soft) log != null
    //#presumption(User getUserDetailsFromAuthentication()): init'ed(java.lang.Boolean.FALSE)
    //#presumption(User getUserDetailsFromAuthentication()): init'ed(java.lang.Boolean.TRUE)
    //#presumption(User getUserDetailsFromAuthentication()): java.util.Locale:getDefault(...)@98 != null
    //#presumption(User getUserDetailsFromAuthentication()): java.util.TimeZone:getDefault(...)@99 != null
    //#presumption(User getUserDetailsFromAuthentication()): org.acegisecurity.context.SecurityContextHolder:getContext(...)@63 != null
    //#post(User getUserDetailsFromAuthentication()): return_value in Addr_Set{null,&new User(getUserDetailsFromAuthentication#1)}
    //#post(User getUserDetailsFromAuthentication()): new User(getUserDetailsFromAuthentication#1) num objects <= 1
    //#unanalyzed(User getUserDetailsFromAuthentication()): Effects-of-calling:javax.naming.directory.Attributes:get
    //#unanalyzed(User getUserDetailsFromAuthentication()): Effects-of-calling:javax.naming.directory.Attribute:get
    //#unanalyzed(User getUserDetailsFromAuthentication()): Effects-of-calling:java.lang.Object:toString
    //#unanalyzed(User getUserDetailsFromAuthentication()): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#test_vector(User getUserDetailsFromAuthentication()): getLocale(...)@115: Addr_Set{null}, Inverse{null}
    //#test_vector(User getUserDetailsFromAuthentication()): getTimeZone(...)@111: Addr_Set{null}, Inverse{null}
    //#test_vector(User getUserDetailsFromAuthentication()): org.acegisecurity.Authentication:getPrincipal(...)@70: Inverse{null}, Addr_Set{null}
    //#test_vector(User getUserDetailsFromAuthentication()): org.acegisecurity.context.SecurityContext:getAuthentication(...)@63: Inverse{null}, Addr_Set{null}
    //#test_vector(User getUserDetailsFromAuthentication()): org.acegisecurity.userdetails.UserDetails:instanceof(...)@77: {1}, {0}
    //#test_vector(User getUserDetailsFromAuthentication()): org.acegisecurity.userdetails.ldap.LdapUserDetails:instanceof(...)@119: {0}, {1}
    //#test_vector(User getUserDetailsFromAuthentication()): org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty(...)@57: {1}, {0}
    //#test_vector(User getUserDetailsFromAuthentication()): org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty(...)@92: {1}, {0}
    //#test_vector(User getUserDetailsFromAuthentication()): userDetails.__Tag@70: {0..388_607, 388_609..+Inf}, {388_608}
        if(!usingSSO) {
            log.info("SSO is not enabled. Skipping CustomUserRegistry functionality.");
    //#CustomUserRegistry.java:59: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
            return null;
        }
        
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    //#CustomUserRegistry.java:63: Warning: method not available
    //#    -- call on SecurityContext org.acegisecurity.context.SecurityContextHolder:getContext()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: SecurityContext org.acegisecurity.context.SecurityContextHolder:getContext()
    //#CustomUserRegistry.java:63: Warning: method not available
    //#    -- call on Authentication org.acegisecurity.context.SecurityContext:getAuthentication()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: Authentication org.acegisecurity.context.SecurityContext:getAuthentication()
        
        if(authentication == null) {
            log.warn("No Authentication found in SecurityContextHolder.");
    //#CustomUserRegistry.java:66: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:warn(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:warn(Object)
            return null;
        }
        
        Object oPrincipal = authentication.getPrincipal();
    //#CustomUserRegistry.java:70: Warning: method not available
    //#    -- call on Object org.acegisecurity.Authentication:getPrincipal()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: Object org.acegisecurity.Authentication:getPrincipal()
        
        if(oPrincipal == null) {
            log.warn("Principal is null. Skipping auto-registration.");
    //#CustomUserRegistry.java:73: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:warn(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:warn(Object)
            return null;
        }
        
        if (!(oPrincipal instanceof UserDetails)) {
            log.warn("Unsupported Principal type in Authentication. Skipping auto-registration.");
    //#CustomUserRegistry.java:78: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:warn(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:warn(Object)
            return null;
        }
        
        UserDetails userDetails = (UserDetails) oPrincipal;
        
        String userName = userDetails.getUsername();
    //#CustomUserRegistry.java:84: Warning: method not available
    //#    -- call on String org.acegisecurity.userdetails.UserDetails:getUsername()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String org.acegisecurity.userdetails.UserDetails:getUsername()
        String password = userDetails.getPassword();
    //#CustomUserRegistry.java:85: Warning: method not available
    //#    -- call on String org.acegisecurity.userdetails.UserDetails:getPassword()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String org.acegisecurity.userdetails.UserDetails:getPassword()
        boolean enabled = userDetails.isEnabled();
    //#CustomUserRegistry.java:86: Warning: method not available
    //#    -- call on bool org.acegisecurity.userdetails.UserDetails:isEnabled()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: bool org.acegisecurity.userdetails.UserDetails:isEnabled()
        
        User ud = new User();
    //#CustomUserRegistry.java:88: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User()
        ud.setId(null);
    //#CustomUserRegistry.java:89: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setId(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setId(String)
        ud.setUserName(userName);
    //#CustomUserRegistry.java:90: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setUserName(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setUserName(String)
        
        boolean storePassword = WebloggerConfig.getBooleanProperty("users.sso.passwords.save");
    //#CustomUserRegistry.java:92: Warning: method not available
    //#    -- call on bool org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: bool org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty(String)
        if(!storePassword) {
            password = WebloggerConfig.getProperty("users.sso.passwords.defaultValue","<unknown>");
    //#CustomUserRegistry.java:94: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String, String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String, String)
        }
        ud.setPassword(password);
    //#CustomUserRegistry.java:96: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setPassword(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setPassword(String)
        ud.setEnabled(enabled ? Boolean.TRUE : Boolean.FALSE);
    //#CustomUserRegistry.java:97: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setEnabled(Boolean)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setEnabled(Boolean)
        ud.setLocale(Locale.getDefault().toString());
    //#CustomUserRegistry.java:98: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setLocale(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setLocale(String)
        ud.setTimeZone(TimeZone.getDefault().getID());
    //#CustomUserRegistry.java:99: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setTimeZone(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setTimeZone(String)
        ud.setDateCreated(new java.util.Date());
    //#CustomUserRegistry.java:100: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setDateCreated(Date)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setDateCreated(Date)
        
        if(userDetails instanceof RollerUserDetails) {
            RollerUserDetails rollerDetails = (RollerUserDetails) userDetails;
            
            ud.setScreenName(rollerDetails.getScreenName());
    //#CustomUserRegistry.java:105: Warning: method not available
    //#    -- call on String getScreenName()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String getScreenName()
    //#CustomUserRegistry.java:105: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setScreenName(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setScreenName(String)
            
            ud.setFullName(rollerDetails.getFullName());
    //#CustomUserRegistry.java:107: Warning: method not available
    //#    -- call on String getFullName()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String getFullName()
    //#CustomUserRegistry.java:107: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setFullName(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setFullName(String)

            //TODO: Bug here as setting email addy to a full name value?
            ud.setEmailAddress(rollerDetails.getFullName());
    //#CustomUserRegistry.java:110: Warning: method not available
    //#    -- call on String getFullName()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String getFullName()
    //#CustomUserRegistry.java:110: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setEmailAddress(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setEmailAddress(String)
            if(rollerDetails.getTimeZone() != null) {
    //#CustomUserRegistry.java:111: Warning: method not available
    //#    -- call on String getTimeZone()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String getTimeZone()
                ud.setTimeZone(rollerDetails.getTimeZone());
    //#CustomUserRegistry.java:112: Warning: method not available
    //#    -- call on String getTimeZone()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String getTimeZone()
    //#CustomUserRegistry.java:112: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setTimeZone(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setTimeZone(String)
            }
            
            if(rollerDetails.getLocale() != null) {
    //#CustomUserRegistry.java:115: Warning: method not available
    //#    -- call on String getLocale()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String getLocale()
                ud.setLocale(rollerDetails.getLocale());
    //#CustomUserRegistry.java:116: Warning: method not available
    //#    -- call on String getLocale()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String getLocale()
    //#CustomUserRegistry.java:116: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setLocale(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setLocale(String)
            }
            
        } else if(userDetails instanceof LdapUserDetails) {
            LdapUserDetails ldapDetails = (LdapUserDetails) userDetails;
            Attributes attributes = ldapDetails.getAttributes();
    //#CustomUserRegistry.java:121: Warning: method not available
    //#    -- call on Attributes org.acegisecurity.userdetails.ldap.LdapUserDetails:getAttributes()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: Attributes org.acegisecurity.userdetails.ldap.LdapUserDetails:getAttributes()
            String sname = getLdapAttribute(attributes, WebloggerConfig.getProperty(SNAME_LDAP_PROPERTY, DEFAULT_SNAME_LDAP_ATTRIBUTE));
    //#CustomUserRegistry.java:122: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String, String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String, String)
            String name = getLdapAttribute(attributes, WebloggerConfig.getProperty(NAME_LDAP_PROPERTY, DEFAULT_NAME_LDAP_ATTRIBUTE));
    //#CustomUserRegistry.java:123: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String, String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String, String)
            String email = getLdapAttribute(attributes, WebloggerConfig.getProperty(EMAIL_LDAP_PROPERTY, DEFAULT_EMAIL_LDAP_ATTRIBUTE));
    //#CustomUserRegistry.java:124: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String, String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String, String)

            ud.setScreenName(sname);
    //#CustomUserRegistry.java:126: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setScreenName(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setScreenName(String)
            ud.setFullName(name);
    //#CustomUserRegistry.java:127: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setFullName(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setFullName(String)
            ud.setEmailAddress(email);
    //#CustomUserRegistry.java:128: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setEmailAddress(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setEmailAddress(String)
            
            String locale = getLdapAttribute(attributes, WebloggerConfig.getProperty(LOCALE_LDAP_PROPERTY, DEFAULT_LOCALE_LDAP_ATTRIBUTE));
    //#CustomUserRegistry.java:130: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String, String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String, String)
            String timezone = getLdapAttribute(attributes, WebloggerConfig.getProperty(TIMEZONE_LDAP_PROPERTY, DEFAULT_TIMEZONE_LDAP_ATTRIBUTE));
    //#CustomUserRegistry.java:131: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String, String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String, String)
            
            if(locale != null) {
                ud.setLocale(locale);
    //#CustomUserRegistry.java:134: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setLocale(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setLocale(String)
            }
            if(timezone != null) {
                ud.setTimeZone(timezone);
    //#CustomUserRegistry.java:137: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.pojos.User:setTimeZone(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: User getUserDetailsFromAuthentication()
    //#    unanalyzed callee: void org.apache.roller.weblogger.pojos.User:setTimeZone(String)
            }
        }
        
        return ud;
    //#CustomUserRegistry.java:141: end of method: User org.apache.roller.weblogger.ui.core.security.CustomUserRegistry.getUserDetailsFromAuthentication()
    }
    
    private static String getLdapAttribute(Attributes attributes, String name) {
        if(attributes == null) {
    //#CustomUserRegistry.java:145: method: String org.apache.roller.weblogger.ui.core.security.CustomUserRegistry.getLdapAttribute(Attributes, String)
    //#input(String getLdapAttribute(Attributes, String)): attributes
    //#input(String getLdapAttribute(Attributes, String)): name
    //#output(String getLdapAttribute(Attributes, String)): java.lang.Object:toString(...)._tainted
    //#output(String getLdapAttribute(Attributes, String)): return_value
    //#new obj(String getLdapAttribute(Attributes, String)): java.lang.Object:toString(...)
    //#post(String getLdapAttribute(Attributes, String)): java.lang.Object:toString(...)._tainted == 0
    //#post(String getLdapAttribute(Attributes, String)): return_value in Addr_Set{null,&java.lang.Object:toString(...)}
    //#test_vector(String getLdapAttribute(Attributes, String)): attributes: Inverse{null}, Addr_Set{null}
    //#test_vector(String getLdapAttribute(Attributes, String)): javax.naming.directory.Attribute:get(...)@157: Inverse{null}, Addr_Set{null}
    //#test_vector(String getLdapAttribute(Attributes, String)): javax.naming.directory.Attributes:get(...)@149: Inverse{null}, Addr_Set{null}
            return null;
        }
        
        Attribute attribute = attributes.get(name);
        
        if(attribute == null) {
            return null;
        }
        
        Object oValue  = null;
    //#CustomUserRegistry.java:155: Warning: unused assignment
    //#    unused assignment into oValue
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
    //#    method: String getLdapAttribute(Attributes, String)
    //#    Attribs:  Uncertain
        try {
            oValue = attribute.get();
        } catch (NamingException e) {
            return null;
        }
        
        if(oValue == null) {
            return null;
        }
        
        return oValue.toString();
    //#CustomUserRegistry.java:166: end of method: String org.apache.roller.weblogger.ui.core.security.CustomUserRegistry.getLdapAttribute(Attributes, String)
    }
    
}
    //#CustomUserRegistry.java:: end of class: org.apache.roller.weblogger.ui.core.security.CustomUserRegistry
