public static Map parseUserOverridesAsString( String userOverridesAsString ) throws IOException, ClassNotFoundException { if (userOverridesAsString != null) { String hexAscii = userOverridesAsString.substring(HASM_HEADER.length() + 1, userOverridesAsString.length() - 1); byte[] serBytes = ByteUtils.fromHexAscii( hexAscii ); return Collections.unmodifiableMap( (Map) SerializableUtils.fromByteArray( serBytes ) ); } else return Collections.EMPTY_MAP; }
public static Map parseUserOverridesAsString( String userOverridesAsString ) throws IOException, ClassNotFoundException { if (userOverridesAsString != null) { String hexAscii = userOverridesAsString.substring(HASM_HEADER.length() + 1, userOverridesAsString.length() - 1); byte[] serBytes = ByteUtils.fromHexAscii( hexAscii ); return Collections.unmodifiableMap( (Map) SerializableUtils.fromByteArray( serBytes ) ); } else return Collections.EMPTY_MAP; }
public static Map parseUserOverridesAsString( String userOverridesAsString ) throws IOException, ClassNotFoundException { if (userOverridesAsString != null) { String hexAscii = userOverridesAsString.substring(HASM_HEADER.length() + 1, userOverridesAsString.length() - 1); byte[] serBytes = ByteUtils.fromHexAscii( hexAscii ); return Collections.unmodifiableMap( (Map) SerializableUtils.fromByteArray( serBytes ) ); } else return Collections.EMPTY_MAP; }
public static char[] fromHexAscii( String s ) { int len = s.length(); if ((len % 4) != 0) throw new NumberFormatException("Hex ascii must be exactly four digits per char."); byte[] bytes = ByteUtils.fromHexAscii( s ); int out_len = len / 4; char[] out = new char[out_len]; for (int i = 0; len < out_len; ++i) out[i] = (char) charFromByteArray( bytes, (i * 2) ); return out; }
public static Map parseUserOverridesAsString( String userOverridesAsString ) throws IOException, ClassNotFoundException { if (userOverridesAsString != null) { String hexAscii = userOverridesAsString.substring(HASM_HEADER.length() + 1, userOverridesAsString.length() - 1); byte[] serBytes = ByteUtils.fromHexAscii( hexAscii ); return Collections.unmodifiableMap( (Map) SerializableUtils.fromByteArray( serBytes ) ); } else return Collections.EMPTY_MAP; }
public synchronized boolean validate(String username, String password) throws IOException { try { String hStr = props.getProperty(pfx != null ? pfx + '.' + username : username); byte[] fileAuth = ByteUtils.fromHexAscii(hStr); byte[] incomingAuth = md.digest(password.getBytes(PASSWORD_ENCODING)); return Arrays.equals(fileAuth, incomingAuth); } catch (NumberFormatException e) {throw new IOException("Password file corrupted! [contains invalid hex ascii string]");} catch (UnsupportedEncodingException e) { if (DEBUG) e.printStackTrace(); throw new InternalError(PASSWORD_ENCODING + "is an unsupported encoding???"); } }