This does not require a customization. You can use an LDAP directory to manage your users out-of-the-box and simply configure Alfresco to point to the LDAP directory.
If you literally want to use a database instead of an LDAP directory that is a customization. You might take a look at the authentication providers that ship with the product to see how they work and then use those as a pattern to follow for your new custom one.
We are developing a custom java web application and we are planning to use Alfresco for content management and workflow. So is it possible for us to use the custom web application database as user database for alfresco authentication.