protected void endElement(DAVElement parent, DAVElement element, StringBuffer cdata) throws SVNException { if (element == APPLY_TEXT_DELTA) { setDeltaProcessing(false); } else if (element == CHANGE_FILE_PROPERTY || element == CHANGE_DIR_PROPERTY) { if (cdata != null && !"".equals(cdata.toString()) && myPropertyName == null) { SVNErrorMessage err = SVNErrorMessage.create( SVNErrorCode.RA_DAV_MALFORMED_DATA, "Got cdata content for a prop delete"); SVNErrorManager.error(err, SVNLogType.NETWORK); } if (myPropertyName != null) { StringBuffer sb = SVNBase64.normalizeBase64(cdata); byte[] buffer = allocateBuffer(sb.length()); int length = SVNBase64.base64ToByteArray(sb, buffer); SVNPropertyValue property = SVNPropertyValue.create(myPropertyName, buffer, 0, length); if (element == CHANGE_FILE_PROPERTY) { myEditor.changeFileProperty(myPath, myPropertyName, property); } else { myEditor.changeDirProperty(myPropertyName, property); } } } }
public void checkServerTrusted(X509Certificate[] certs, String algorithm) throws CertificateException { if (certs != null && certs.length > 0 && certs[0] != null) { String data = SVNBase64.byteArrayToBase64(certs[0].getEncoded()); String stored = (String) myAuthManager.getRuntimeAuthStorage().getData("svn.ssl.server", myRealm); if (data.equals(stored)) { return; } stored = getStoredServerCertificate(myRealm); if (data.equals(stored)) { return; } ISVNAuthenticationProvider authProvider = myAuthManager.getAuthenticationProvider(); int failures = SVNSSLUtil.getServerCertificateFailures(certs[0], myURL.getHost()); // compose bit mask. // 8 is default // check dates for 1 and 2 // check host name for 4 if (authProvider != null) { boolean store = myAuthManager.isAuthStorageEnabled(myURL); boolean trustServer = checkServerTrustedByDefault(certs, algorithm); int result; if (trustServer) { result = ISVNAuthenticationProvider.ACCEPTED; } else { result = authProvider.acceptServerAuthentication(myURL, myRealm, certs[0], store); } if (result == ISVNAuthenticationProvider.ACCEPTED && store) { try { storeServerCertificate(myRealm, data, failures); } catch (SVNException e) { // ignore that exception, as we only need to trust now and may save data later. // throw new SVNSSLUtil.CertificateNotTrustedException("svn: Server SSL certificate for // '" + myRealm + "' cannot be saved"); SVNDebugLog.getDefaultLog().logError(SVNLogType.NETWORK, e); } } if (result != ISVNAuthenticationProvider.REJECTED) { myAuthManager.getRuntimeAuthStorage().putData("svn.ssl.server", myRealm, data); return; } throw new SVNSSLUtil.CertificateNotTrustedException( "svn: Server SSL certificate for '" + myRealm + "' rejected"); } // like as tmp. accepted. } }
protected void endElement(DAVElement parent, DAVElement element, StringBuffer cdata) throws SVNException { if (element == FILE_REVISION) { if (myPath != null && myFileRevisionsHandler != null) { // handle file revision if was not handled yet (no tx delta). if (myProperties == null) { myProperties = Collections.EMPTY_MAP; } if (myPropertiesDelta == null) { myPropertiesDelta = Collections.EMPTY_MAP; } SVNFileRevision revision = new SVNFileRevision(myPath, myRevision, myProperties, myPropertiesDelta); myFileRevisionsHandler.openRevision(revision); } // handle close revision with props? if (myFileRevisionsHandler != null) { myFileRevisionsHandler.closeRevision(myPath); } myPath = null; myProperties = null; myPropertiesDelta = null; myPropertyEncoding = null; myPropertyName = null; } else if (element == TX_DELTA) { setDeltaProcessing(false); myCount++; } else if (element == REVISION_PROPERTY) { if (myProperties == null) { myProperties = new HashMap(); } myProperties.put(myPropertyName, cdata != null ? cdata.toString() : ""); myPropertyName = null; } else if (element == SET_PROPERTY) { if (myPropertiesDelta == null) { myPropertiesDelta = new HashMap(); } if (myPropertyName != null) { String value; if ("base64".equals(myPropertyEncoding)) { byte[] bytes = allocateBuffer(cdata.length()); int length = SVNBase64.base64ToByteArray(new StringBuffer(cdata.toString().trim()), bytes); try { value = new String(bytes, 0, length, "UTF-8"); } catch (UnsupportedEncodingException e) { value = new String(bytes, 0, length); } } else { value = cdata.toString(); } myPropertiesDelta.put(myPropertyName, value); } myPropertyName = null; myPropertyEncoding = null; } else if (element == DELETE_PROPERTY) { if (myPropertiesDelta == null) { myPropertiesDelta = new HashMap(); } if (myPropertyName != null) { myPropertiesDelta.put(myPropertyName, null); } myPropertyEncoding = null; myPropertyName = null; } }