1 22 23 24 package com.mchange.v2.c3p0.impl; 25 26 import java.util.Enumeration ; 27 import java.util.Properties ; 28 29 public class AuthMaskingProperties extends Properties 30 { 31 public AuthMaskingProperties() 32 { super(); } 33 34 public AuthMaskingProperties( Properties p ) 35 { super( p ); } 36 37 public static AuthMaskingProperties fromAnyProperties( Properties p ) 38 { 39 AuthMaskingProperties out = new AuthMaskingProperties(); 40 for( Enumeration e = p.propertyNames(); e.hasMoreElements(); ) 41 { 42 String key = (String ) e.nextElement(); 43 out.setProperty( key, p.getProperty( key ) ); 44 } 45 return out; 46 } 47 48 private String normalToString() 49 { return super.toString(); } 50 51 public String toString() 52 { 53 boolean hasUser = (this.get("user") != null); 54 boolean hasPassword = (this.get("password") != null); 55 if ( hasUser || hasPassword ) 56 { 57 AuthMaskingProperties clone = (AuthMaskingProperties) this.clone(); 58 if (hasUser) 59 clone.put("user", "******"); 60 if (hasPassword) 61 clone.put("password", "******"); 62 return clone.normalToString(); 63 } 64 else 65 return this.normalToString(); 66 } 67 } | Popular Tags |