1 package org.jahia.services.usermanager; 2 3 import java.util.Hashtable ; 4 import javax.naming.Context ; 5 6 13 public class ServerBean { 14 15 private Hashtable publicParameters; 17 private Hashtable privateParameters; 19 20 private int priority; 22 private int maxReconn; 24 private String provider; 26 27 private static final int DEFAULT_PRIORITY = 99; 28 private static final int DEFAULT_RECONN = 1; 29 30 36 public ServerBean (String newPriority, String newProvider, String newMaxReconn) { 37 try { 38 priority = Integer.parseInt (newPriority); 39 } catch (Exception e) { 40 priority = DEFAULT_PRIORITY; 41 } 42 43 try { 44 maxReconn = Integer.parseInt (newMaxReconn); 45 } catch (Exception e) { 46 maxReconn = DEFAULT_RECONN; 47 } 48 49 provider = newProvider; 50 51 publicParameters = new Hashtable (11); 52 privateParameters = new Hashtable (11); 53 } 54 55 59 public int getPriority() { 60 return priority; 61 } 62 63 67 public String getProvider() { 68 return provider; 69 } 70 71 75 public int getMaxReconnection() { 76 return maxReconn; 77 } 78 79 83 public void setFactoryName(String factoryName) { 84 if (factoryName != null && factoryName.length() > 0) { 85 publicParameters.put (Context.INITIAL_CONTEXT_FACTORY, factoryName); 86 privateParameters.put (Context.INITIAL_CONTEXT_FACTORY, factoryName); 87 } 88 } 89 90 94 public void setServerUrl(String url) { 95 if (url != null && url.length() > 0) { 96 publicParameters.put (Context.PROVIDER_URL, url); 97 privateParameters.put (Context.PROVIDER_URL, url); 98 } 99 } 100 101 105 public void setUserName(String userName) { 106 if (userName != null && userName.length() > 0) 107 publicParameters.put (Context.SECURITY_PRINCIPAL, userName); 108 } 109 110 114 public void setAuthenticationMode(String authenticationMode) { 115 if (authenticationMode != null && authenticationMode.length() > 0) { 116 publicParameters.put (Context.SECURITY_AUTHENTICATION, authenticationMode); 117 privateParameters.put (Context.SECURITY_AUTHENTICATION, authenticationMode); 118 } 119 } 120 121 125 public void setUserPassword(String password) { 126 if (password != null && password.length() > 0) 127 publicParameters.put (Context.SECURITY_CREDENTIALS, password); 128 } 129 130 134 public void setReferralBehavior (String behavior) { 135 if (behavior != null && behavior.length() > 0) { 136 publicParameters.put (Context.REFERRAL, behavior); 137 privateParameters.put (Context.REFERRAL, behavior); 138 } 139 } 140 141 145 public Hashtable getPublicConnectionParameters() { 146 return publicParameters; 147 } 148 149 155 public Hashtable getPrivateConnectionParameters(String userName, String password) { 156 privateParameters.put (Context.SECURITY_CREDENTIALS, password); 157 privateParameters.put (Context.SECURITY_PRINCIPAL, userName); 158 159 return privateParameters; 160 } 161 162 166 public String toString() { 167 StringBuffer sb = new StringBuffer ("ServerBean["); 168 sb.append(maxReconn); 169 sb.append("::"); 170 sb.append(provider); 171 sb.append("::"); 172 sb.append(priority); 173 sb.append("::"); 174 sb.append(publicParameters); 175 sb.append("]"); 176 177 return sb.toString(); 178 } 179 } | Popular Tags |