/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.security.cert.TrustedCert
 *  com.l7tech.security.cert.TrustedCert$TrustedFor
 *  com.l7tech.security.cert.TrustedCertManager
 */
package com.l7tech.server.identity.cert;

import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.security.cert.TrustedCert;
import com.l7tech.security.cert.TrustedCertManager;
import com.l7tech.server.identity.cert.TrustedCertCache;
import java.util.Collection;
import java.util.Collections;

public class TrustedCertCacheImpl
implements TrustedCertCache {
    private final TrustedCertManager a;

    public TrustedCertCacheImpl(TrustedCertManager trustedCertManager) {
        this.a = trustedCertManager;
    }

    @Override
    public TrustedCert findByPrimaryKey(Goid goid) throws FindException {
        return this.a((TrustedCert)this.a.findByPrimaryKey(goid));
    }

    @Override
    public Collection<TrustedCert> findByName(String string) throws FindException {
        return this.a(this.a.findByName(string));
    }

    @Override
    public Collection<TrustedCert> findByTrustFlag(TrustedCert.TrustedFor trustedFor) throws FindException {
        return this.a(this.a.findByTrustFlag(trustedFor));
    }

    @Override
    public Collection<TrustedCert> findBySubjectDn(String string) throws FindException {
        return this.a(this.a.findBySubjectDn(string));
    }

    private TrustedCert a(TrustedCert trustedCert) {
        if (trustedCert != null) {
            trustedCert.setReadOnly();
        }
        return trustedCert;
    }

    private Collection<TrustedCert> a(Collection<TrustedCert> collection) {
        for (TrustedCert trustedCert : collection) {
            trustedCert.setReadOnly();
        }
        return Collections.unmodifiableCollection(collection);
    }
}

