private String getResponse(){ byte[] response; if (myResponse.length > myPosition) { response = new byte[myPosition]; for (int i = 0; i < myPosition; i++) { response[i] = myResponse[i]; } } else { response = myResponse; } return SVNBase64.byteArrayToBase64(response); }
/** * Translates the specified SVNBase64 string (as per Preferences.get(byte[])) * into a byte array. * * @throws IllegalArgumentException * if <tt>s</tt> is not a valid SVNBase64 string. */ public static int base64ToByteArray(StringBuffer s, byte[] buffer) { return base64ToByteArray(s, buffer, false); }
public static String getAuthHeader(String token, SVNNTSecurityParameters params) throws SVNException { byte[] input = null; if (token != null) { StringBuffer tokenBuffer = new StringBuffer(token); byte[] tmp = new byte[tokenBuffer.length()]; StringBuffer sb = SVNBase64.normalizeBase64(tokenBuffer); int resultLength = SVNBase64.base64ToByteArray(sb, tmp); input = new byte[resultLength]; System.arraycopy(tmp, 0, input, 0, resultLength); } byte[] nextTokenBytes = getNextToken(params, input); if (nextTokenBytes == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Internal authentication error"); SVNErrorManager.error(err, SVNLogType.DEFAULT); } return SVNBase64.byteArrayToBase64(nextTokenBytes); }
protected SVNPropertyValue createPropertyValueFromBase64(DAVElement element, String propertyName, StringBuffer cdata) { StringBuffer sb = SVNBase64.normalizeBase64(cdata); byte[] buffer = allocateBuffer(sb.length()); int length = SVNBase64.base64ToByteArray(sb, buffer); if (useStringProperty(element, propertyName)) { String str; try { str = new String(buffer, 0, length, "UTF-8"); } catch (UnsupportedEncodingException e) { str = new String(buffer, 0, length); } return SVNPropertyValue.create(str); } return SVNPropertyValue.create(propertyName, buffer, 0, length); }
public String generateType3Msg(String userName, char[] password, String domain, String ws, String token) throws NTLMEngineException { final byte[] buffer = new byte[token.length()]; final int length = SVNBase64.base64ToByteArray(new StringBuffer(token), buffer); final byte[] tokenBytes = new byte[length]; System.arraycopy(buffer, 0, tokenBytes, 0, length); try { final Class<?> type2MessageClass = Class.forName("jcifs.ntlmssp.Type2Message"); final Class<?> type3MessageClass = Class.forName("jcifs.ntlmssp.Type3Message"); final Constructor<?> type2Constructor = type2MessageClass.getConstructor(byte[].class); final Constructor<?> type3Constructor = type3MessageClass.getConstructor(type2MessageClass, String.class, String.class, String.class, String.class, Integer.TYPE); final Object type2MessageObject = type2Constructor.newInstance(tokenBytes); final Method getFlags = type2MessageClass.getMethod("getFlags"); final int type2Flags = (Integer) getFlags.invoke(type2MessageObject); final int type3Flags = type2Flags & (~(0x00010000 /*NtlmFlags.NTLMSSP_TARGET_TYPE_DOMAIN*/ | 0x00020000 /*NtlmFlags.NTLMSSP_TARGET_TYPE_SERVER*/)); final Object type3MessageObject = type3Constructor.newInstance(type2MessageObject, new String(password), domain, userName, ws, type3Flags); final Method toByteArray = type3MessageClass.getMethod("toByteArray"); final byte[] message = (byte[]) toByteArray.invoke(type3MessageObject); return SVNBase64.byteArrayToBase64(message); } catch (Exception e) { throw new NTLMEngineException(e.getMessage(), e); } } }
int numFullGroups = numGroups; if (sLen != 0) { if (charAt(s, sLen - 1) == '=') { missingBytesInLastGroup++; numFullGroups--; if (charAt(s, sLen - 2) == '=') missingBytesInLastGroup++; int ch0 = alphaToInt[charAt(s, inCursor++)]; int ch1 = alphaToInt[charAt(s, inCursor++)]; int ch2 = alphaToInt[charAt(s, inCursor++)]; int ch3 = alphaToInt[charAt(s, inCursor++)]; result[outCursor++] = (byte) ((ch0 << 2) | (ch1 >> 4)); result[outCursor++] = (byte) ((ch1 << 4) | (ch2 >> 2)); int ch0 = alphaToInt[charAt(s, inCursor++)]; int ch1 = alphaToInt[charAt(s, inCursor++)]; result[outCursor++] = (byte) ((ch0 << 2) | (ch1 >> 4)); int ch2 = alphaToInt[charAt(s, inCursor++)]; result[outCursor++] = (byte) ((ch1 << 4) | (ch2 >> 2));
myOwner = cdata.toString(); if (myIsBase64) { StringBuffer sb = SVNBase64.normalizeBase64(new StringBuffer(myOwner)); byte[] buffer = allocateBuffer(sb.length()); int length = SVNBase64.base64ToByteArray(sb, buffer); try { myOwner = new String(buffer, 0, length, "UTF-8"); StringBuffer sb = SVNBase64.normalizeBase64(new StringBuffer(myComment)); byte[] buffer = allocateBuffer(sb.length()); int length = SVNBase64.base64ToByteArray(sb, buffer); try { myComment = new String(buffer, 0, length, "UTF-8");
private String getResponse(){ byte[] response; if (myResponse.length > myPosition) { response = new byte[myPosition]; for (int i = 0; i < myPosition; i++) { response[i] = myResponse[i]; } } else { response = myResponse; } return SVNBase64.byteArrayToBase64(response); }
myOwner = cdata.toString(); if (myIsBase64) { StringBuffer sb = SVNBase64.normalizeBase64(new StringBuffer(myOwner)); byte[] buffer = allocateBuffer(sb.length()); int length = SVNBase64.base64ToByteArray(sb, buffer); try { myOwner = new String(buffer, 0, length, "UTF-8"); StringBuffer sb = SVNBase64.normalizeBase64(new StringBuffer(myComment)); byte[] buffer = allocateBuffer(sb.length()); int length = SVNBase64.base64ToByteArray(sb, buffer); try { myComment = new String(buffer, 0, length, "UTF-8");
/** * Translates the specified SVNBase64 string (as per Preferences.get(byte[])) * into a byte array. * * @throws IllegalArgumentException * if <tt>s</tt> is not a valid SVNBase64 string. */ public static int base64ToByteArray(StringBuffer s, byte[] buffer) { return base64ToByteArray(s, buffer, false); }
public static String getAuthHeader(String token, SVNNTSecurityParameters params) throws SVNException { byte[] input = null; if (token != null) { StringBuffer tokenBuffer = new StringBuffer(token); byte[] tmp = new byte[tokenBuffer.length()]; StringBuffer sb = SVNBase64.normalizeBase64(tokenBuffer); int resultLength = SVNBase64.base64ToByteArray(sb, tmp); input = new byte[resultLength]; System.arraycopy(tmp, 0, input, 0, resultLength); } byte[] nextTokenBytes = getNextToken(params, input); if (nextTokenBytes == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Internal authentication error"); SVNErrorManager.error(err, SVNLogType.DEFAULT); } return SVNBase64.byteArrayToBase64(nextTokenBytes); }
private String getResponse(){ byte[] response; if (myResponse.length > myPosition) { response = new byte[myPosition]; for (int i = 0; i < myPosition; i++) { response[i] = myResponse[i]; } } else { response = myResponse; } return SVNBase64.byteArrayToBase64(response); }
myOwner = cdata.toString(); if (myIsBase64) { StringBuffer sb = SVNBase64.normalizeBase64(new StringBuffer(myOwner)); byte[] buffer = allocateBuffer(sb.length()); int length = SVNBase64.base64ToByteArray(sb, buffer); try { myOwner = new String(buffer, 0, length, "UTF-8"); StringBuffer sb = SVNBase64.normalizeBase64(new StringBuffer(myComment)); byte[] buffer = allocateBuffer(sb.length()); int length = SVNBase64.base64ToByteArray(sb, buffer); try { myComment = new String(buffer, 0, length, "UTF-8");
/** * Translates the specified SVNBase64 string (as per Preferences.get(byte[])) * into a byte array. * * @throws IllegalArgumentException * if <tt>s</tt> is not a valid SVNBase64 string. */ public static int base64ToByteArray(StringBuffer s, byte[] buffer) { return base64ToByteArray(s, buffer, false); }
public static String byteArrayToBase64(byte[] a) { return byteArrayToBase64(a, false); }
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 static int base64ToByteArray(char[] s, byte[] buffer) { try { return base64ToByteArray(s, buffer, false); } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("Invalid SVNBase64 string: " + s.toString(), e); } }
private static String toBase64(byte[] src) { return SVNBase64.byteArrayToBase64(src); }
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 respondTo(String challenge) { if (challenge == null) { myToken = new byte[0]; myTokenLength = 0; } else { myToken = new byte[(challenge.length() * 3 + 3) / 4]; myTokenLength = SVNBase64.base64ToByteArray(new StringBuffer(challenge), myToken); } }