Methods Summary |
---|
private boolean | checkAccess()Check whether the calling user is authenticated.
boolean allowed = false;
// Get the username and password from the MessageContext
MessageContext context = endpointContext.getMessageContext();
String callingUser = (String)context.getProperty(HandlerBookServiceConstants.USERNAME_PROPERTY);
String callingPwd = (String)context.getProperty(HandlerBookServiceConstants.PASSWORD_PROPERTY);
if (userName != null && password != null) {
// Authentication is configured.
return userName.equals(callingUser) &&
password.equals(callingPwd);
}
return allowed;
|
public void | destroy()
// Nothing to do
|
public void | getBookAuthor(java.lang.String title, javax.xml.rpc.holders.StringHolder author)Gets the author for a books with a given title
String authorName = HandlerBookServiceServantData.getBookAuthor(title);
if (authorName == null || !checkAccess()) {
throw new HandlerBookServiceException("Unknown author: " + title);
}
author.value = authorName;
|
public int | getBookCount()Gets the number of books known to the service
String[] titles = HandlerBookServiceServantData.getBookTitles();
return titles == null || !checkAccess() ? 0 : titles.length;
|
public java.lang.String | getBookTitle(int index)Gets the title of a given book.
String[] bookTitles = HandlerBookServiceServantData.getBookTitles();
if (bookTitles == null || index < 0 || index >= bookTitles.length || !checkAccess()) {
return null;
}
return bookTitles[index];
|
public void | init(java.lang.Object context)
endpointContext = (ServletEndpointContext)context;
// Get the authorized user name and password from the init parameters
ServletContext servletContext = endpointContext.getServletContext();
userName = servletContext.getInitParameter("UserName");
password = servletContext.getInitParameter("Password");
|
public void | log(java.lang.String value)Makes a log entry.
if (checkAccess()) {
endpointContext.getServletContext().log(new Date() + ": " + value);
}
|