List of usage examples for com.mongodb.util Util hexMD5
public static String hexMD5(final byte[] data)
From source file:com.edgytech.umongo.UserDialog.java
License:Apache License
String _hash(String username, char[] passwd) { ByteArrayOutputStream bout = new ByteArrayOutputStream(username.length() + 20 + passwd.length); try {/*from ww w . ja va 2 s . c o m*/ bout.write(username.getBytes()); bout.write(":mongo:".getBytes()); for (int i = 0; i < passwd.length; i++) { if (passwd[i] >= 128) throw new IllegalArgumentException("can't handle non-ascii passwords yet"); bout.write((byte) passwd[i]); } } catch (IOException ioe) { throw new RuntimeException("impossible", ioe); } return Util.hexMD5(bout.toByteArray()); }
From source file:com.github.nlloyd.hornofmongo.MongoScope.java
License:Open Source License
public static String hex_md5(Context cx, Scriptable thisObj, Object[] args, Function funObj) { // just like mongo native_hex_md5 call, only expects a single string final String str = Context.toString(args[0]); return Util.hexMD5(str.getBytes()); }
From source file:com.joyfulmongo.db.JFMongoCmdLogin.java
License:Apache License
@Override protected JFMongoCmdResult execute() { String md5Password = Util.hexMD5(password.getBytes()); System.out.println("Password " + password + " md5=" + md5Password); JFMongoCmdQuery query = new JFMongoCmdQuery.Builder(JFMongoUser.S_USER_COLLNAME) .projectionExclude(Constants.Props.password.toString()) .whereEquals(Constants.Props.username.toString(), username) .whereEquals(Constants.Props.password.toString(), md5Password).build(); List<JFMongoObject> parseObjs = query.find(); JFMongoCmdResult result = new JFMongoCmdResult(); if (parseObjs.size() > 0) { result.put(JFCConstants.Props.data.toString(), parseObjs.get(0)); } else {/*from w w w .j a v a2 s .c o m*/ JFUserError e = new JFUserError(JFMongoException.VALIDATION_ERROR, "invalid username and password combination"); throw e; } return result; }
From source file:com.joyfulmongo.db.JFMongoCmdSignup.java
License:Apache License
@Override protected JFMongoCmdResult execute() { JFMongoCmdResult result;//from w ww . ja va2 s.co m boolean usernameOkay = verifyUsernameUnique(username); if (usernameOkay) { System.out.println("The password is =" + password); String md5Password = Util.hexMD5(password.getBytes()); getPayload().put(Constants.Props.password.toString(), md5Password); result = super.execute(); } else { throw new JFUserError(202, "username " + username + " already taken"); } return result; }