GSSAPIAuthenticator(final MongoCredentialWithCache credential) { super(credential); if (getMongoCredential().getAuthenticationMechanism() != GSSAPI) { throw new MongoException("Incorrect mechanism: " + getMongoCredential().getMechanism()); } }
@Override public Map<String, ?> properties(RequestContext ctx) throws Exception { Map properties = new HashMap<>(); properties.put(MECHANISM, mongoCredential.getMechanism()); properties.put(USERNAME, mongoCredential.getUserName()); //only the MONGODB CR has a password and database option, the GSS one only accepts a username if (mongoCredential.getMechanism().equals(MongoCredential.MONGODB_CR_MECHANISM)) { properties.put(PASSWORD, new String(mongoCredential.getPassword())); properties.put(DB, mongoCredential.getSource()); } return properties; }
public static String toString(MongoCredential cr) { StringBuilder bld = new StringBuilder(); bld.append("{mechanism:").append(cr.getMechanism()); if (cr.getUserName() != null) { bld.append(" userName:").append(cr.getUserName()); } if (cr.getPassword() != null) { bld.append(" password:").append(cr.getPassword()); } if (cr.getSource() != null) { bld.append(" source:").append(cr.getSource()); } bld.append('}'); return bld.toString(); }
public static String toString(MongoCredential cr) { StringBuilder bld = new StringBuilder(); bld.append("{mechanism:").append(cr.getMechanism()); if (cr.getUserName() != null) { bld.append(" userName:").append(cr.getUserName()); } if (cr.getPassword() != null) { bld.append(" password:").append(cr.getPassword()); } if (cr.getSource() != null) { bld.append(" source:").append(cr.getSource()); } bld.append('}'); return bld.toString(); }
GSSAPIAuthenticator(final MongoCredentialWithCache credential) { super(credential); if (getMongoCredential().getAuthenticationMechanism() != GSSAPI) { throw new MongoException("Incorrect mechanism: " + getMongoCredential().getMechanism()); } }