List of usage examples for com.google.gwt.util.tools.shared Md5Utils getMd5Digest
public static byte[] getMd5Digest(String string)
From source file:com.github.nmorel.gwtjackson.rebind.RebindConfiguration.java
License:Apache License
public RebindConfiguration(TreeLogger logger, GeneratorContext context, JacksonTypeOracle typeOracle, JClassType rootMapperClass) throws UnableToCompleteException { this.logger = logger; this.context = context; this.typeOracle = typeOracle; this.rootMapperClass = rootMapperClass; this.rootMapperHash = new BigInteger(1, Md5Utils.getMd5Digest(rootMapperClass.getQualifiedSourceName().getBytes())).toString(16); List<AbstractConfiguration> configurations = getAllConfigurations(); Builder<JClassType> allSupportedSerializationClassBuilder = ImmutableSet.builder(); Builder<JClassType> allSupportedDeserializationClassBuilder = ImmutableSet.builder(); List<String> whitelist = new ArrayList<String>(); JsonAutoDetect.Visibility fieldVisibility = JsonAutoDetect.Visibility.DEFAULT; JsonAutoDetect.Visibility getterVisibility = JsonAutoDetect.Visibility.DEFAULT; JsonAutoDetect.Visibility isGetterVisibility = JsonAutoDetect.Visibility.DEFAULT; JsonAutoDetect.Visibility setterVisibility = JsonAutoDetect.Visibility.DEFAULT; JsonAutoDetect.Visibility creatorVisibility = JsonAutoDetect.Visibility.DEFAULT; for (AbstractConfiguration configuration : configurations) { for (MapperType mapperType : MapperType.values()) { addMappers(configuration, mapperType, allSupportedSerializationClassBuilder, allSupportedDeserializationClassBuilder); }/*from www . j a v a2 s . c o m*/ addMixInAnnotations(configuration.getMapMixInAnnotations(), rootMapperClass.getAnnotation(JsonMixIns.class)); whitelist.addAll(configuration.getWhitelist()); fieldVisibility = configuration.getFieldVisibility(); getterVisibility = configuration.getGetterVisibility(); isGetterVisibility = configuration.getIsGetterVisibility(); setterVisibility = configuration.getSetterVisibility(); creatorVisibility = configuration.getCreatorVisibility(); } this.allSupportedSerializationClass = allSupportedSerializationClassBuilder.build(); this.allSupportedDeserializationClass = allSupportedDeserializationClassBuilder.build(); this.additionalSupportedTypes = new TypeFilter(logger, whitelist); this.defaultFieldVisibility = fieldVisibility; this.defaultGetterVisibility = getterVisibility; this.defaultIsGetterVisibility = isGetterVisibility; this.defaultSetterVisibility = setterVisibility; this.defaultCreatorVisibility = creatorVisibility; }
From source file:eml.studio.server.rpc.AccountServiceImpl.java
License:Open Source License
/** * Register an account/* w w w . j a v a 2s . c o m*/ * * @param account target account * @return "[success]" + account.getUsername() + account.getEmail() or NULL */ @Override public String register(Account account) { try { Account un_tmp = new Account(); un_tmp.setUsername(account.getUsername()); if (SecureDao.getObject(un_tmp) != null) { return "username error"; } else { account.setPassword(BaseDao.password(account.getPassword())); account.setCreatetime(TimeUtils.getTime()); String serialmd5 = Md5Utils.getMd5Digest(UUID.randomUUID().toString().getBytes()).toString(); account.setSerial(serialmd5); String[] setFields = { "username", "password", "createtime", "serial", "company", "position", "verifylink", "power" }; String[] condFields = { "email" }; SecureDao.update(account, setFields, condFields); return "[success]" + " " + " " + account.getUsername() + account.getEmail(); } } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:eml.studio.server.rpc.AccountServiceImpl.java
License:Open Source License
/** * Login an account//w w w . j a v a 2 s . com * @param account target account * @return account object */ @Override public Account login(Account account) { setSessionExpireTime(); if (account.getEmail() == null) { account.setEmail(""); } if (account.getPassword() == null) { account.setPassword(BaseDao.password("")); } else { account.setPassword(BaseDao.password(account.getPassword())); } try { Account query = account; account = SecureDao.getObject(query); if (account != null) { if (account.getSerial() == null || account.getSerial().length() == 0) { String serialmd5 = Md5Utils.getMd5Digest(UUID.randomUUID().toString().getBytes()).toString(); account.setSerial(serialmd5); String[] setFields = { "serial" }; String[] condFields = { "email" }; SecureDao.update(account, setFields, condFields); } HttpServletRequest request = this.getThreadLocalRequest(); HttpSession session = request.getSession(); session.setAttribute("username", account.getUsername()); session.setAttribute("email", account.getEmail()); session.setAttribute("serial", account.getSerial()); return account; } } catch (Exception e) { e.printStackTrace(); return null; } return null; }
From source file:eml.studio.server.rpc.AccountServiceImpl.java
License:Open Source License
/** * Reset the password of user//from w w w . j av a2 s.c om * * @param account format:"email password" * @return status string format:"[success] username email" */ @Override public Account resetPassword(Account account) { Account tmp = new Account(); tmp.setEmail(account.getEmail()); try { Account query = tmp; tmp = SecureDao.getObject(query); if (tmp != null) { Account new_account = new Account(); new_account.setEmail(tmp.getEmail()); new_account.setPassword(account.getPassword()); String serialmd5 = Md5Utils.getMd5Digest(UUID.randomUUID().toString().getBytes()).toString(); new_account.setSerial(serialmd5); new_account.setVerifylink(account.getVerifylink()); String[] setFields = { "password", "serial", "verifylink" }; String[] condFields = { "email" }; SecureDao.update(new_account, setFields, condFields); return new_account; } else { return null; } } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:eml.studio.server.rpc.AccountServiceImpl.java
License:Open Source License
/** * Change the password of user//from ww w . j a v a2 s . co m * * @param account format:"email password" * @return status string, format: "[success] username email" */ @Override public String modifyPassword(String account) { String arr[] = account.split(" "); Account tmp = new Account(); tmp.setEmail(arr[0]); tmp.setPassword(arr[1]); try { Account query = tmp; tmp = SecureDao.getObject(query); if (tmp != null) { Account new_account = new Account(); new_account.setEmail(tmp.getEmail()); new_account.setPassword(arr[2]); String serialmd5 = Md5Utils.getMd5Digest(UUID.randomUUID().toString().getBytes()).toString(); new_account.setSerial(serialmd5); String[] setFields = { "password", "serial" }; String[] condFields = { "email" }; SecureDao.update(new_account, setFields, condFields); return "[success]" + " " + new_account.getUsername() + " " + new_account.getEmail(); } else { return "wrong old password"; // Wrong email } } catch (Exception e) { e.printStackTrace(); } return "new password failed"; // Password modification failed }
From source file:eml.studio.server.rpc.MailServiceImpl.java
License:Open Source License
/** * Send email/*from w w w .j a va 2 s.c o m*/ * * @param base_url * @param account * @param flag * @return boolean, format:true/false */ @Override public String SendMail(String base_url, Account account, String flag) { if (flag.equals("r")) { try { Account new_account = new Account(); String serialmd5 = Md5Utils.getMd5Digest(UUID.randomUUID().toString().getBytes()).toString(); String token = UUID.randomUUID().toString(); new_account.setEmail(account.getEmail()); new_account.setSerial(serialmd5); new_account.setToken(token); new_account.setActivetime(TimeUtils.getTime()); new_account.setCreatetime(TimeUtils.getTime()); JavaMail mail = new JavaMail(); String title = "Register-mail verification"; String content = new_account.getEmail() + " Hello, <br>you are using this mailbox to register your EMLStudio account, " + "Please click on the link for email verification and set the password and personal information after the verification.<br/>" + "<a href='" + LinkUtils.activateLink(base_url, new_account) + "' onClick='" + "'>" + LinkUtils.activateLink(base_url, new_account) + "</a>"; Account tmp = SecureDao.getObject(account); if (tmp != null) { if (!tmp.getPassword().isEmpty()) { return "email existed"; } else { String[] setFields = { "serial", "token", "activetime", "createtime" }; String[] condFields = { "email" }; boolean result = mail.sendMsg(new_account.getEmail(), title, content); if (result) { SecureDao.update(new_account, setFields, condFields); return "success"; } else { return "send email failed"; } } } else { boolean result = mail.sendMsg(new_account.getEmail(), title, content); if (result) { SecureDao.insert(new_account); return "success"; } else { return "send email failed"; } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (flag.equals("m")) { try { Account temp = SecureDao.getObject(account); if (temp != null && !temp.getPassword().isEmpty()) { Account verify_account = new Account(); String token = UUID.randomUUID().toString(); verify_account.setEmail(temp.getEmail()); verify_account.setSerial(temp.getSerial()); verify_account.setToken(token); JavaMail mail = new JavaMail(); String title = "Reset password-mail verification"; String content = verify_account.getEmail() + "Hello, <br>you are using this mailbox to reset your account password," + "Please click on the link for email verification and set your new password after after the verification.<br/>" + "<a href='" + LinkUtils.resetpwdLink(base_url, verify_account) + "' onClick='" + "'>" + LinkUtils.resetpwdLink(base_url, verify_account) + "</a>"; Account update_account = new Account(); update_account.setEmail(temp.getEmail()); update_account.setToken(token); update_account.setActivetime(TimeUtils.getTime()); update_account.setVerifylink(" "); String[] setFields = { "token", "activetime", "verifylink" }; String[] condFields = { "email" }; SecureDao.update(update_account, setFields, condFields); AppController.verifylink = null; boolean result = mail.sendMsg(verify_account.getEmail(), title, content); if (result) { return "success"; } else return "send email failed"; } else return "email doesn't exist"; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; }