* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import com.datastax.driver.core.Row;
/**
- * CredDAO manages credentials.
+ * CredDAO manages credentials.
* @author Jonathan
* Date: 7/19/13
*/
public class CertDAO extends CassDAOImpl<AuthzTrans,CertDAO.Data> {
public static final String TABLE = "x509";
public static final int CACHE_SEG = 0x40; // yields segment 0x0-0x3F
-
+
private HistoryDAO historyDAO;
private CIDAO<AuthzTrans> infoDAO;
private PSInfo psX500,psID;
-
+
public CertDAO(AuthzTrans trans, Cluster cluster, String keyspace) throws APIException, IOException {
super(trans, CertDAO.class.getSimpleName(),cluster, keyspace, Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
init(trans);
infoDAO = ciDao;
init(trans);
}
-
+
public static final int KEYLIMIT = 2;
public static class Data extends CacheableData implements Bytification {
-
+
public String ca;
public BigInteger serial;
public String id;
seg(cache,ca,serial)
};
}
-
+
@Override
public ByteBuffer bytify() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
CertLoader.deflt.marshal(this,new DataOutputStream(baos));
return ByteBuffer.wrap(baos.toByteArray());
}
-
+
@Override
public void reconstitute(ByteBuffer bb) throws IOException {
CertLoader.deflt.unmarshal(this, toDIS(bb));
private static class CertLoader extends Loader<Data> implements Streamer<Data>{
public static final int MAGIC=85102934;
public static final int VERSION=1;
- public static final int BUFF_SIZE=48; // Note:
+ public static final int BUFF_SIZE=48; // Note:
public static final CertLoader deflt = new CertLoader(KEYLIMIT);
public CertLoader(int keylimit) {
obj[++idx] = data.x500;
obj[++idx] = data.x509;
-
+
}
@Override
}
}
}
-
+
public Result<List<CertDAO.Data>> read(AuthzTrans trans, Object ... key) {
// Translate BigInteger to Byte array for lookup
return super.read(trans, key[0],ByteBuffer.wrap(((BigInteger)key[1]).toByteArray()));
psX500 = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
" WHERE x500 = ?", CertLoader.deflt,readConsistency);
-
+
}
-
+
public Result<List<Data>> readX500(AuthzTrans trans, String x500) {
return psX500.read(trans, R_TEXT, new Object[]{x500});
}