com.alu.e3.prov.restapi.model.Error error = new Error();
error.setErrorText("");
boolean inError = false;
// Do some validation
AuthType authType = auth.getType();
if(authType == null){
inError = true;
error.setErrorText("Could not determine auth-type from request.");
} else {
if(authType.equals(AuthType.BASIC)){
BasicAuth basicAuth = auth.getBasicAuth();
if(basicAuth == null){
inError = true;
error.setErrorText("Request did not contain BasicAuth info.");
} else {
if(basicAuth.getUsername() == null || basicAuth.getUsername().isEmpty()){
inError = true;
error.setErrorText("Username must not be empty for Basic authentication type.");
}
if(basicAuth.getPassword() == null || basicAuth.getPassword().length <= 0){
inError = true;
error.setErrorText(error.getErrorText()+" Password must not be empty for Basic authentication type.");
}
}
}
else if(authType.equals(AuthType.WSSE)){
WSSEAuth basicAuth = auth.getWsseAuth();
if(basicAuth == null){
inError = true;
error.setErrorText("Request did not contain WsseAuth info.");
} else {
if(basicAuth.getUsername() == null || basicAuth.getUsername().isEmpty()){
inError = true;
error.setErrorText("Username must not be empty for WSSE authentication type.");
}
if(basicAuth.getPassword() == null || basicAuth.getPassword().length <= 0){
inError = true;
error.setErrorText(error.getErrorText()+" Passowrd must not be empty for WSSE authentication type.");
}
}
}
else if(authType.equals(AuthType.AUTHKEY)){
AuthKeyAuth authKeyAuth = auth.getAuthKeyAuth();
if(authKeyAuth == null) {
inError = true;
error.setErrorText("Request did not contain AuthKeyAuth info.");
} else {
if(authKeyAuth.getKeyValue()== null || authKeyAuth.getKeyValue().isEmpty()){
inError = true;
error.setErrorText("authKey must not be empty for AuthKey authentication type.");
}
}
}
else if(authType.equals(AuthType.IP_WHITE_LIST)){
IpWhiteList ipWhiteListAuth = auth.getIpWhiteListAuth();
if(ipWhiteListAuth == null) {
inError = true;
error.setErrorText("Request did not contain ipWhiteListAuth info.");
} else {