String username = arg0.getHeader(SSO_userParam);
String errorMsg = "";
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><username = " + username);
if (username == null) {
errorMsg = "A Utente disconnesso. <a href=\"javascript:self.close()\">[CHIUDERE]</a> la finestra per tornare al Portale.";
throw new AuthenticationServiceException(errorMsg);
}
System.out.println("AuthenticationSSOFilter.attemptAuthentication() 1");
username = username.trim();
String key = arg0.getParameter("key");
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><key = " + key);
if (key == null) {
errorMsg = "B Utente disconnesso. <a href=\"javascript:self.close()\">[CHIUDERE]</a> la finestra per tornare al Portale.";
throw new AuthenticationServiceException(errorMsg);
}
System.out.println("AuthenticationSSOFilter.attemptAuthentication() 2");
String verificaUrl;
try {
verificaUrl = StringsUtils.postForString(new URL(SSO_verificaToken_URL), "key=" + key + "&" + SSO_verificaToken_URL_params);
if (verificaUrl.indexOf("KO") != -1) {
errorMsg = "Si è verificato un errore nella verifica dell'utente (keytest)";
throw new AuthenticationServiceException(errorMsg);
}
arg0.getSession().setAttribute("alfresco_token", key);
System.out.println("keykeykeykeykeykeykeykeykeykey "+key);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("AuthenticationSSOFilter.attemptAuthentication() 3");
try {
String regSessUrl = StringsUtils.postForString(new URL(SSO_regSession_URL), "key=" + key + "&SESSIONAPL=" + URLEncoder.encode("JSESSIONID=", "utf-8") + arg0.getSession().getId() + "&" + SSO_regSession_URL_params);
if (regSessUrl.indexOf("KO") != -1) {
errorMsg = "Si è verificato un errore nella verifica dell'utente (regsess)";
throw new AuthenticationServiceException(errorMsg);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();