Example usage for javax.ejb FinderException getMessage

List of usage examples for javax.ejb FinderException getMessage

Introduction

In this page you can find the example usage for javax.ejb FinderException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.idega.core.accesscontrol.business.LoginBusinessBean.java

/**
 * Gets the last login record date before current logged record ( second last
 * entry)/*from   ww  w .  j  a v  a  2 s .c o m*/
 *
 * @param userId
 * @return
 */
public static java.sql.Date getLastLoginByUser(Integer userId) throws RemoteException {
    try {
        return getLoginRecordHome().getLastLoginByUserID(userId);
    } catch (FinderException e) {
        throw new RemoteException(e.getMessage());
    }
}

From source file:com.idega.core.accesscontrol.business.LoginBusinessBean.java

/**
 * Gets the last login record date before current logged record ( second last
 * entry)/*from   w w w  .ja v  a  2 s .  co  m*/
 *
 * @param userId
 * @return
 */
public static java.sql.Date getLastLoginByLogin(Integer loginId) throws RemoteException {
    try {
        return getLoginRecordHome().getLastLoginByLoginID(loginId);
    } catch (FinderException e) {
        throw new RemoteException(e.getMessage());
    }
}

From source file:com.idega.bedework.bussiness.impl.BedeworkCalendarServiceBean.java

@Override
public List<Group> getGroups(Set<Long> groupIDs) {
    GroupHome groupHome = getHomeForEntity(Group.class);
    if (groupHome == null) {
        return null;
    }// w ww  . j av  a  2s. c  om

    List<Group> allGroups = null;
    try {
        Collection<?> groups = null;

        if (ListUtil.isEmpty(groupIDs)) {
            groups = groupHome.findAll();
        } else {
            groups = groupHome.findGroups(groupIDs.toArray(new String[groupIDs.size()]));
        }

        if (ListUtil.isEmpty(groups)) {
            return null;
        }

        allGroups = new ArrayList<Group>();

        for (Object group : groups) {
            if (group instanceof Group) {
                allGroups.add((Group) group);
            }
        }

    } catch (FinderException e) {
        getLogger().log(Level.WARNING, "Unable to get groups: " + e.getMessage());
        return null;
    }

    return allGroups;
}

From source file:org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.java

@Override
public void cleanUserCertDataSN(EndEntityInformation data) throws ObjectNotFoundException {
    if (log.isTraceEnabled()) {
        log.trace(">cleanUserCertDataSN: " + data.getUsername());
    }//from w ww . j  a va 2  s. com
    try {
        cleanUserCertDataSN(data.getUsername());
    } catch (FinderException e) {
        String msg = intres.getLocalizedMessage("authentication.usernotfound", data.getUsername());
        log.info(msg);
        throw new ObjectNotFoundException(e.getMessage());
    } catch (ApprovalException e) {
        // Should never happen
        log.error("ApprovalException: ", e);
        throw new EJBException(e);
    } catch (WaitingForApprovalException e) {
        // Should never happen
        log.error("WaitingForApprovalException: ", e);
        throw new EJBException(e);
    }
    if (log.isTraceEnabled()) {
        log.trace("<cleanUserCertDataSN: " + data.getUsername());
    }
}

From source file:org.ejbca.core.ejb.ra.UserAdminSessionBean.java

@Override
public void cleanUserCertDataSN(UserDataVO data) throws ObjectNotFoundException {
    if (log.isTraceEnabled()) {
        log.trace(">cleanUserCertDataSN: " + data.getUsername());
    }/*ww w.  ja v a 2  s.  com*/
    // This admin can be the public web user, which may not be allowed to
    // change status,
    // this is a bit ugly, but what can a man do...
    Admin statusadmin = Admin.getInternalAdmin();
    try {
        cleanUserCertDataSN(statusadmin, data.getUsername());
    } catch (FinderException e) {
        String msg = intres.getLocalizedMessage("authentication.usernotfound", data.getUsername());
        logSession.log(statusadmin, statusadmin.getCaId(), LogConstants.MODULE_CA, new Date(),
                data.getUsername(), null, LogConstants.EVENT_INFO_USERAUTHENTICATION, msg);
        throw new ObjectNotFoundException(e.getMessage());
    } catch (AuthorizationDeniedException e) {
        // Should never happen
        log.error("AuthorizationDeniedException: ", e);
        throw new EJBException(e);
    } catch (ApprovalException e) {
        // Should never happen
        log.error("ApprovalException: ", e);
        throw new EJBException(e);
    } catch (WaitingForApprovalException e) {
        // Should never happen
        log.error("ApprovalException: ", e);
        throw new EJBException(e);
    }
    if (log.isTraceEnabled()) {
        log.trace("<cleanUserCertDataSN: " + data.getUsername());
    }
}

From source file:org.ejbca.core.protocol.ws.EjbcaWS.java

private void revokeCert(final String issuerDN, final String certificateSN, final int reason, Date date,
        IPatternLogger logger) throws CADoesntExistsException, AuthorizationDeniedException, NotFoundException,
        EjbcaException, ApprovalException, WaitingForApprovalException, AlreadyRevokedException,
        RevokeBackDateNotAllowedForProfileException {
    if (log.isDebugEnabled()) {
        log.debug("Revoke cert with serial number '" + certificateSN + "' from issuer '" + issuerDN
                + "' with reason '" + reason + "'.");
    }/*from   w  w  w.  j  av  a 2s.  com*/
    try {
        final EjbcaWSHelper ejbhelper = new EjbcaWSHelper(wsContext, authorizationSession, caAdminSession,
                caSession, certificateProfileSession, certificateStoreSession, endEntityAccessSession,
                endEntityProfileSession, hardTokenSession, endEntityManagementSession, webAuthenticationSession,
                cryptoTokenManagementSession);
        final AuthenticationToken admin = ejbhelper.getAdmin();
        logAdminName(admin, logger);
        final int caid = CertTools.stringToBCDNString(issuerDN).hashCode();
        caSession.verifyExistenceOfCA(caid);
        final BigInteger serno = new BigInteger(certificateSN, 16);
        // Revoke or unrevoke, will throw appropriate exceptions if parameters are wrong, such as trying to unrevoke a certificate
        // that was permanently revoked
        endEntityManagementSession.revokeCert(admin, serno, date, issuerDN, reason, true);
    } catch (FinderException e) {
        throw new NotFoundException(e.getMessage());
    } catch (RuntimeException e) { // EJBException, ClassCastException, ...
        throw EjbcaWSHelper.getInternalException(e, logger);
    }
}

From source file:org.ejbca.core.protocol.ws.EjbcaWS.java

@Override
public void revokeUser(String username, int reason, boolean deleteUser)
        throws CADoesntExistsException, AuthorizationDeniedException, NotFoundException,
        AlreadyRevokedException, EjbcaException, ApprovalException, WaitingForApprovalException {

    final IPatternLogger logger = TransactionLogger.getPatternLogger();
    try {//from   ww w .j a  va 2s . c o  m
        EjbcaWSHelper ejbhelper = new EjbcaWSHelper(wsContext, authorizationSession, caAdminSession, caSession,
                certificateProfileSession, certificateStoreSession, endEntityAccessSession,
                endEntityProfileSession, hardTokenSession, endEntityManagementSession, webAuthenticationSession,
                cryptoTokenManagementSession);
        AuthenticationToken admin = ejbhelper.getAdmin();
        logAdminName(admin, logger);

        // check username
        EndEntityInformation userdata = endEntityAccessSession.findUser(admin, username);
        if (userdata == null) {
            log.info(intres.getLocalizedMessage("ra.errorentitynotexist", username));
            String msg = intres.getLocalizedMessage("ra.wrongusernameorpassword");
            throw new NotFoundException(msg);
        }
        // Check caid
        int caid = userdata.getCAId();
        caSession.verifyExistenceOfCA(caid);
        if (!authorizationSession.isAuthorizedNoLogging(admin, StandardRules.CAACCESS.resource() + caid)) {
            final String msg = intres.getLocalizedMessage("authorization.notuathorizedtoresource",
                    StandardRules.CAACCESS.resource() + caid, null);
            throw new AuthorizationDeniedException(msg);
        }
        if (deleteUser) {
            endEntityManagementSession.revokeAndDeleteUser(admin, username, reason);
        } else {
            endEntityManagementSession.revokeUser(admin, username, reason);
        }
    } catch (FinderException e) {
        throw new NotFoundException(e.getMessage());
    } catch (RemoveException e) {
        throw EjbcaWSHelper.getInternalException(e, logger);
    } catch (RuntimeException e) { // EJBException, ClassCastException, ...
        throw EjbcaWSHelper.getInternalException(e, logger);
    } finally {
        logger.writeln();
        logger.flush();
    }
}