protected void doInit() throws Exception { if (_companyId > 0) { Company company = CompanyLocalServiceUtil.getCompany(_companyId); _domain = company.getMx(); _userName = PrefsPropsUtil.getString(_companyId, PropsKeys.GOOGLE_APPS_USERNAME); _password = PrefsPropsUtil.getString(_companyId, PropsKeys.GOOGLE_APPS_PASSWORD); } Http.Options options = new Http.Options(); options.addPart("accountType", "HOSTED"); String emailAddress = _userName; if (!emailAddress.contains(StringPool.AT)) { emailAddress = _userName.concat(StringPool.AT).concat(_domain); } options.addPart("Email", emailAddress); options.addPart("Passwd", _password); options.addPart("service", "apps"); options.setLocation("https://www.google.com/accounts/ClientLogin"); options.setPost(true); String content = HttpUtil.URLtoString(options); Properties properties = PropertiesUtil.load(content); _error = properties.getProperty("Error"); if (_error != null) { _log.info("Unable to initialize authentication token: " + _error); } _authenticationToken = properties.getProperty("Auth"); if (_authenticationToken != null) { _log.info("Authentication token " + _authenticationToken); } _initTime = System.currentTimeMillis(); }