![JAR search and dependency download from the Maven repository](/logo.png)
net.binggl.ninja.mongodb.MongoAuthMechanism Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ninja-mongodb-module Show documentation
Show all versions of ninja-mongodb-module Show documentation
This is an easly plugable module for the Ninja web framework to work with MongoDB and optional moprhia (a MongoDB ORM)
by providing convinent services, all required dependencies and some testing utilities. The original author is Sven Kubiak (https://github.com/svenkubiak).
This is a recreation of the module because the orginal module/github repository was deleted.
package net.binggl.ninja.mongodb;
import org.apache.commons.lang.StringUtils;
/**
* define the possible mongoDB authentication mechanisms
* @author henrik
*/
public enum MongoAuthMechanism {
SCRAM_SHA_1("SCRAM-SHA-1"), MONGODB_CR("MONGODB-CR"), MONGO_X509("MONGO-X509");
private String text;
MongoAuthMechanism(String text) {
this.text = text;
}
public String getText() {
return this.text;
}
public static MongoAuthMechanism fromString(String text) {
if(StringUtils.isNotEmpty(text)) {
String t = replaceUnwantedChars(text);
for (MongoAuthMechanism b : MongoAuthMechanism.values()) {
String enumText = replaceUnwantedChars(b.text);
if (t.equalsIgnoreCase(enumText)) {
return b;
}
}
}
throw new IllegalArgumentException("No constant with text " + text + " found");
}
private static String replaceUnwantedChars(String text) {
String t = text;
for(String s : new String[]{"_", "-"}) {
t = t.replace(s, "");
}
return t;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy