Java Reference
In-Depth Information
*/
@WebService
public class EmailCheck {
private static String NO_CREDENITALS_MSG =
"You must be registered and supply a " +
"valid username and password to use this service.";
/**
* The single op we'll expose on the service. Checks the
* value of the email address passed in.
* @param email The address clients want to verify.
* @param username The username of a hypoethetically
* pre-registered user so that only authorized users
* can access the service.
* @param password the passsword for this 'registered' user.
* @return a string indicating if the email address is
* valid or not.
*/
public String verify(
@WebParam(mode=WebParam.Mode.IN,
name="email")String email,
@WebParam(mode=WebParam.Mode.INOUT, header=true,
name="username") Holder<String> username,
@WebParam(mode=WebParam.Mode.INOUT, header=true,
name="password") Holder<String> password){
if (!isValidUser(username, password))
return NO_CREDENITALS_MSG;
//Silly check. Robust business logic here...
if (email != null && email.endsWith(".com")) {
return "VALID";
} else {
return "INVALID";
}
}
/*Checks that the supplied username/password combination
is valid. Replace this with a run to a database or LDAP.
*/
private boolean isValidUser(Holder<String> username,
Holder<String> password) {
boolean suppliedUsername = username != null &&
!username.value.isEmpty();
Search WWH ::




Custom Search