Search in sources :

Example 1 with RpObject

use of io.jans.ca.server.persistence.modal.RpObject in project jans by JanssenProject.

the class JansPersistenceService method getRp.

public Rp getRp(String rpId) {
    try {
        RpObject rpFromGluuPersistance = getRpObject(rpId, new String[0]);
        Rp rp = MigrationService.parseRp(rpFromGluuPersistance.getData());
        if (rp != null) {
            LOG.debug("Found RP id: {}, RP : {} ", rpId, rp);
            return rp;
        }
        LOG.error("Failed to fetch RP by id: {} ", rpId);
        return null;
    } catch (Exception e) {
        LOG.error("Failed to update rpId: {} ", rpId, e);
    }
    return null;
}
Also used : RpObject(io.jans.ca.server.persistence.modal.RpObject) Rp(io.jans.ca.server.service.Rp) SQLException(java.sql.SQLException) EntryPersistenceException(io.jans.orm.exception.EntryPersistenceException)

Example 2 with RpObject

use of io.jans.ca.server.persistence.modal.RpObject in project jans by JanssenProject.

the class JansPersistenceService method update.

public boolean update(Rp rp) {
    try {
        RpObject rpObj = new RpObject(getDnForRp(rp.getRpId()), rp.getRpId(), Jackson2.serializeWithoutNulls(rp));
        this.persistenceEntryManager.merge(rpObj);
        LOG.debug("RP updated successfully. RP : {} ", rpObj);
        return true;
    } catch (Exception e) {
        LOG.error("Failed to update RP: {} ", rp, e);
    }
    return false;
}
Also used : RpObject(io.jans.ca.server.persistence.modal.RpObject) SQLException(java.sql.SQLException) EntryPersistenceException(io.jans.orm.exception.EntryPersistenceException)

Example 3 with RpObject

use of io.jans.ca.server.persistence.modal.RpObject in project jans by JanssenProject.

the class JansPersistenceService method create.

public boolean create(Rp rp) {
    try {
        RpObject rpObj = new RpObject(getDnForRp(rp.getRpId()), rp.getRpId(), Jackson2.serializeWithoutNulls(rp));
        this.persistenceEntryManager.persist(rpObj);
        LOG.debug("RP created successfully. RP : {} ", rp);
        return true;
    } catch (Exception e) {
        LOG.error("Failed to create RP: {} ", rp, e);
    }
    return false;
}
Also used : RpObject(io.jans.ca.server.persistence.modal.RpObject) SQLException(java.sql.SQLException) EntryPersistenceException(io.jans.orm.exception.EntryPersistenceException)

Example 4 with RpObject

use of io.jans.ca.server.persistence.modal.RpObject in project jans by JanssenProject.

the class JansPersistenceService method getRps.

public Set<Rp> getRps() {
    try {
        List<RpObject> rpObjects = this.persistenceEntryManager.findEntries(String.format("%s,%s", new Object[] { getRpOu(), getClientApiDn() }), RpObject.class, null);
        Set<Rp> result = new HashSet();
        for (RpObject ele : rpObjects) {
            Rp rp = MigrationService.parseRp(ele.getData());
            if (rp != null) {
                result.add(rp);
            } else {
                LOG.error("Failed to parse rp, id: {}, dn: {} ", ele.getId(), ele.getDn());
            }
        }
        return result;
    } catch (Exception e) {
        if (((e instanceof EntryPersistenceException)) && (e.getMessage().contains("Failed to find entries"))) {
            LOG.warn("Failed to fetch RpObjects. {} ", e.getMessage());
            return null;
        }
        LOG.error("Failed to fetch rps. Error: {} ", e.getMessage(), e);
    }
    return null;
}
Also used : RpObject(io.jans.ca.server.persistence.modal.RpObject) EntryPersistenceException(io.jans.orm.exception.EntryPersistenceException) RpObject(io.jans.ca.server.persistence.modal.RpObject) ExpiredObject(io.jans.ca.common.ExpiredObject) Rp(io.jans.ca.server.service.Rp) SQLException(java.sql.SQLException) EntryPersistenceException(io.jans.orm.exception.EntryPersistenceException)

Aggregations

RpObject (io.jans.ca.server.persistence.modal.RpObject)4 EntryPersistenceException (io.jans.orm.exception.EntryPersistenceException)4 SQLException (java.sql.SQLException)4 Rp (io.jans.ca.server.service.Rp)2 ExpiredObject (io.jans.ca.common.ExpiredObject)1