public void print(PrintWriter p) throws IOException { List<Entry> elist = getAllRows(); for(int i = 0; i < elist.size(); i++) { Entry e = elist.get(i); p.printf("[%02d] %s%n", i, e.toString()); } }
synchronized public void serialize(OutputStream ostream, String password) throws HTTPException { try { // Create Key byte deskey[] = password.getBytes(Escape.utf8Charset); DESKeySpec desKeySpec = new DESKeySpec(deskey); //Coverity[RISKY_CRYPTO] SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); SecretKey secretKey = keyFactory.generateSecret(desKeySpec); // Create Cipher Cipher desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); desCipher.init(Cipher.ENCRYPT_MODE, secretKey); // Create crypto stream BufferedOutputStream bos = new BufferedOutputStream(ostream); CipherOutputStream cos = new CipherOutputStream(bos, desCipher); ObjectOutputStream oos = new ObjectOutputStream(cos); oos.writeInt(getAllRows().size()); for(Entry e : getAllRows()) { oos.writeObject(e); } oos.flush(); oos.close(); } catch (Exception e) { throw new HTTPException(e); } }
/** * Search for all equivalent rows, then sort on the path. * * @param scope * @return list of matching entries */ synchronized public List<Entry> search(String principal, AuthScope scope) { List<Entry> matches; if(isdefault || DEFAULT == null) matches = new ArrayList<Entry>(); else matches = DEFAULT.search(principal, scope); if(scope == null || rows.size() == 0) return matches; for(Entry e : getAllRows()) { if(principal != ANY_PRINCIPAL && e.principal.equals(principal)) continue; if(HTTPAuthScope.equivalent(scope, e.scope)) matches.add(e); } Collections.sort(matches); return matches; }