Holger's Java API

## com.antelmann.servlet
Class ServletUtils

    java.lang.Object
      com.antelmann.servlet.ServletUtils

    public class ServletUtils

extends Object

provides generally useful methods for handling Servlets within this framework

Since:
  09.04.2009, 14:11:41
Author:
  Holger Antelmann

Method Summary
`static User` `authenticate(javax.servlet.http.HttpServletRequest req, Iterable<User> users, Filter<? super User> filter)` returns true only if any of the given users match the authorization scheme from the given request
`static User` `authenticate(javax.servlet.ServletRequest req, UserLoginStore uls, Filter<? super User> filter)` implements authentication via BasicAuth
`static HashMap<String,String>` `createSimpleParameterMap(javax.servlet.ServletRequest request)` creates a new mutable map where only the first occurring value of a parameter is mapped as value
`static String` `getAuthenticatedUserName(javax.servlet.http.HttpServletRequest req)`
`static String` `getAuthenticatedUserPassword(javax.servlet.http.HttpServletRequest req)`
`static String` `getFileName(javax.servlet.http.Part part)`
`static String` `getRemoteAddress(javax.servlet.ServletRequest request)`
`static AbstractLogWriter<String>` `getServletLogWriter(javax.servlet.ServletContext sc)`
`static File` `getTempDir(javax.servlet.ServletContext context)`
`static User` `getUserFromHeader(UserLoginStore uls, javax.servlet.ServletRequest request, String userKey, String pwdKey, boolean hashedPassword, Filter<? super User> filter)`
`static User` `getUserFromParams(UserLoginStore uls, javax.servlet.ServletRequest request, String userKey, String pwdKey, boolean hashedPassword, Filter<? super User> filter)`
`static void` `sendAuthorizationFailure(String realm, javax.servlet.ServletResponse response)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getTempDir

    public static File getTempDir(javax.servlet.ServletContext context)

### createSimpleParameterMap

    public static HashMap<String,String> createSimpleParameterMap(javax.servlet.ServletRequest request)

  creates a new mutable map where only the first occurring value of a parameter is mapped as value

  See Also:
    `ServletRequest.getParameterMap()`

### getUserFromParams

    public static User getUserFromParams(UserLoginStore uls,
                                         javax.servlet.ServletRequest request,
                                         String userKey,
                                         String pwdKey,
                                         boolean hashedPassword,
                                         Filter<? super User> filter)
                                  throws DatabaseException

  Throws:
    `DatabaseException`

### getUserFromHeader

    public static User getUserFromHeader(UserLoginStore uls,
                                         javax.servlet.ServletRequest request,
                                         String userKey,
                                         String pwdKey,
                                         boolean hashedPassword,
                                         Filter<? super User> filter)
                                  throws DatabaseException

  Throws:
    `DatabaseException`

### getAuthenticatedUserName

    public static String getAuthenticatedUserName(javax.servlet.http.HttpServletRequest req)

### getAuthenticatedUserPassword

    public static String getAuthenticatedUserPassword(javax.servlet.http.HttpServletRequest req)

### authenticate

    public static User authenticate(javax.servlet.ServletRequest req,
                                    UserLoginStore uls,
                                    Filter<? super User> filter)
                             throws DatabaseException

  implements authentication via BasicAuth

  Throws:
    `DatabaseException`

### authenticate

    public static User authenticate(javax.servlet.http.HttpServletRequest req,
                                    Iterable<User> users,
                                    Filter<? super User> filter)

  returns true only if any of the given users match the authorization scheme from the given request

### sendAuthorizationFailure

    public static void sendAuthorizationFailure(String realm,
                                                javax.servlet.ServletResponse response)
                                         throws IOException

  Throws:
    `IOException`

### getRemoteAddress

    public static String getRemoteAddress(javax.servlet.ServletRequest request)

### getServletLogWriter

    public static AbstractLogWriter<String> getServletLogWriter(javax.servlet.ServletContext sc)

### getFileName

    public static String getFileName(javax.servlet.http.Part part)

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads