1 package com.ca.directory.jxplorer.broker; 2 3 4 import com.ca.commons.cbutil.*; 5 import com.ca.commons.jndi.*; 6 import com.ca.commons.naming.*; 7 import com.ca.commons.security.JXSSLSocketFactory; 8 import com.ca.directory.jxplorer.JXplorer; 9 10 import javax.naming.*; 11 import javax.naming.directory.*; 12 import java.util.ArrayList ; 13 import java.util.logging.Logger ; 14 15 19 public class CBGraphicsOps extends DXOps 20 { 21 public boolean quietMode = false; public boolean errorWhileQuietFlag = false; public Exception quietException = null; private CBpbar pbar = null; 25 26 private static Logger log = Logger.getLogger(CBGraphicsOps.class.getName()); 27 28 31 32 public CBGraphicsOps(DirContext ctx) 33 throws NamingException 34 { 35 super(ctx); 36 } 37 38 41 42 public CBGraphicsOps(ConnectionData cData) 43 throws NamingException 44 { 45 super(addSSLFactoryToConnectionData(cData)); 46 } 47 48 52 53 public void setQuietMode(boolean status) 54 { 55 quietMode = status; 56 57 if (quietMode == true) 58 { 59 errorWhileQuietFlag = false; 60 quietException = null; 61 } 62 } 63 64 71 72 public boolean error(String msg, Exception e) 73 { 74 if (quietMode) 75 { 76 errorWhileQuietFlag = true; 77 quietException = e; 78 79 log.warning(msg+"\n (details) " + ((e==null)?"no error details supplied":e.toString())); 80 } 81 else 82 CBUtility.error(msg, e); 83 84 return false; 85 } 86 87 94 95 public void modifyAttributes(Name dn, ModificationItem[] modList) 96 throws NamingException 97 { 98 super.modifyAttributes(dn, modList); 99 100 if ("true".equalsIgnoreCase(JXplorer.getProperty("option.confirmTableEditorUpdates"))) 101 { 102 CBUtility.confirm(CBIntText.get("Entry: {0} was successfully updated", new String [] {dn.toString()})); } 104 } 105 106 107 108 109 112 113 public void startOperation(String heading, String operationName) 114 { 115 setPbar(new CBpbar(CBUtility.getDefaultDisplay(), heading, operationName)); 116 } 117 118 119 120 123 124 public void stopOperation() 125 { 126 super.stopOperation(); 127 if (getPbar()==null) 128 return; 129 130 getPbar().close(); 131 setPbar(null); 132 } 133 134 135 136 139 140 public void pop() { if (getPbar() != null) getPbar().pop();} 141 142 148 149 public NamingEnumeration push(NamingEnumeration elements) 150 { 151 DXNamingEnumeration DXelements = new DXNamingEnumeration(elements); 152 int size = DXelements.size(); if (getPbar()!=null) getPbar().push(size); 154 return DXelements; 155 } 156 157 163 164 public void push(ArrayList elements) 165 { 166 int size = elements.size(); 167 if (getPbar()!=null) getPbar().push(size); 168 } 169 170 173 174 public void inc() { if (getPbar()!=null) getPbar().inc();} 175 176 177 183 184 public static ConnectionData addSSLFactoryToConnectionData(ConnectionData connectionData) 185 throws NamingException 186 { 187 191 if (connectionData.useSSL) 192 { 193 194 try 203 { 204 JXSSLSocketFactory.init(connectionData.cacerts, connectionData.clientcerts, 205 connectionData.caKeystorePwd, connectionData.clientKeystorePwd, 206 connectionData.caKeystoreType, connectionData.clientKeystoreType, CBUtility.getDefaultDisplay()); 207 208 JXSSLSocketFactory.setDebug(JXplorer.debugLevel >= 9); 209 210 connectionData.sslSocketFactory = "com.ca.commons.security.JXSSLSocketFactory"; 211 } 212 catch (Exception e) 215 { 216 NamingException ne = new NamingException("error pre-initialising SSL for JNDI connection: " + e.toString()); 217 ne.setRootCause(e); 218 throw ne; 219 } 220 } 222 223 224 return connectionData; 225 } 226 227 public CBpbar getPbar() 228 { 229 return pbar; 230 } 231 232 public void setPbar(CBpbar pbar) 233 { 234 this.pbar = pbar; 235 } 236 237 } | Popular Tags |