Exemplo n.º 1
0
static void 
s_load_certs_from_disk (zcertstore_t *self)
{
    s_empty_store (self);
    zdir_t *dir = zdir_new (self->location, NULL);
    if (dir) {
        //  Load all certificates including those in subdirectories
        zfile_t **filelist = zdir_flatten (dir);
        uint index;
        for (index = 0;; index++) {
            zfile_t *file = filelist [index];
            if (!file)
                break;      //  End of list
            if (zfile_is_regular (file)) {
                zcert_t *cert = zcert_load (zfile_filename (file, NULL));
                if (cert)
                    zcertstore_insert (self, &cert);
            }
        }
        zdir_flatten_free (&filelist);
        self->modified = zdir_modified (dir);
        self->count = zdir_count (dir);
        self->cursize = zdir_cursize (dir);

        zdir_destroy (&dir);
    }
}
Exemplo n.º 2
0
static void
s_disk_loader (zcertstore_t *certstore)
{
    disk_loader_state *state = (disk_loader_state *)certstore->state;
    zdir_t *dir = zdir_new (state->location, NULL);
    if (dir
    && (state->modified != zdir_modified (dir)
    ||  state->count != zdir_count (dir)
    ||  state->cursize != (size_t) zdir_cursize (dir)))
    {
        zhashx_purge (certstore->certs);

        //  Load all certificates including those in subdirectories
        zfile_t **filelist = zdir_flatten (dir);
        assert (filelist);
        zrex_t *rex = zrex_new ("_secret$");
        assert (rex);

        uint index;
        for (index = 0;; index++) {
            zfile_t *file = filelist [index];
            if (!file)
                break;      //  End of list
            if (zfile_is_regular (file)
            && !zrex_matches (rex, zfile_filename (file, NULL))) {
                zcert_t *cert = zcert_load (zfile_filename (file, NULL));
                if (cert)
                    zcertstore_insert (certstore, &cert);
            }
        }
        zdir_flatten_free (&filelist);
        state->modified = zdir_modified (dir);
        state->count = zdir_count (dir);
        state->cursize = zdir_cursize (dir);

        zrex_destroy (&rex);
    }
    zdir_destroy (&dir);
}
Exemplo n.º 3
0
zcert_t *
zcertstore_lookup (zcertstore_t *self, char *public_key)
{
    //  If directory has changed, reload all certificates
    if (self->location) {
        zdir_t *dir = zdir_new (self->location, NULL);
        if (dir
        && (self->modified != zdir_modified (dir)
        ||  self->count    != zdir_count (dir)
        ||  self->cursize  != zdir_cursize (dir))) {
            s_load_certs_from_disk (self);
        }
        zdir_destroy (&dir);
    }
    return (zcert_t *) zhash_lookup (self->cert_hash, public_key);
}
Exemplo n.º 4
0
JNIEXPORT jlong JNICALL
Java_org_zeromq_czmq_Zdir__1_1modified (JNIEnv *env, jclass c, jlong self)
{
    jlong modified_ = (jlong) zdir_modified ((zdir_t *) (intptr_t) self);
    return modified_;
}