// to work as expected.
SecurityContext secCtx = SecurityContext.getCurrent();
assert (secCtx != null); // since login succeeded above
WebPrincipal principal = new WebPrincipal(user, password, secCtx);
req.setUserPrincipal(principal);
req.setAuthType(WEBAUTH_PROGRAMMATIC);
if(logger.isLoggable(Level.FINE)){
logger.log(Level.FINE, "Programmatic login set principal in http request to: "+