List of usage examples for javax.ejb TransactionAttributeType SUPPORTS
TransactionAttributeType SUPPORTS
To view the source code for javax.ejb TransactionAttributeType SUPPORTS.
Click Source Link
REQUIRED
case. From source file:org.ejbca.core.ejb.ca.caadmin.CAAdminSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override//w w w .j a v a2s . c om public String healthCheck() { final StringBuilder sb = new StringBuilder(); final boolean caTokenSignTest = EjbcaConfiguration.getHealthCheckCaTokenSignTest(); if (log.isDebugEnabled()) { log.debug("CaTokenSignTest: " + caTokenSignTest); } final HashMap<Integer, CryptoToken> cryptoTokenMap = new HashMap<Integer, CryptoToken>(); for (final Integer caid : caSession.getAllCaIds()) { try { final CAInfo cainfo = caSession.getCAInfoInternal(caid.intValue()); if (cainfo.getStatus() == CAConstants.CA_ACTIVE && cainfo.getIncludeInHealthCheck()) { // Verify that the CA's mapped keys exist and optionally that the test-key is usable final int cryptoTokenId = cainfo.getCAToken().getCryptoTokenId(); CryptoToken cryptoToken = cryptoTokenMap.get(Integer.valueOf(cryptoTokenId)); if (cryptoToken == null) { cryptoToken = cryptoTokenSession.getCryptoToken(cryptoTokenId); if (cryptoToken != null) { // Cache crypto token lookup locally since multiple CA might use the same and milliseconds count here cryptoTokenMap.put(Integer.valueOf(cryptoTokenId), cryptoToken); } } final int tokenstatus = cainfo.getCAToken().getTokenStatus(caTokenSignTest, cryptoToken); if (tokenstatus == CryptoToken.STATUS_OFFLINE) { sb.append("\nCA: Error CA Token is disconnected, CA Name : ").append(cainfo.getName()); log.error("Error CA Token is disconnected, CA Name : " + cainfo.getName()); } } } catch (CADoesntExistsException e) { if (log.isDebugEnabled()) { log.debug("CA with id '" + caid.toString() + "' does not exist."); } } } return sb.toString(); }
From source file:org.ejbca.core.ejb.ca.caadmin.CAAdminSessionBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public ExtendedCAServiceResponse extendedService(AuthenticationToken admin, int caid, ExtendedCAServiceRequest request) throws ExtendedCAServiceRequestException, IllegalExtendedCAServiceRequestException, ExtendedCAServiceNotActiveException, CADoesntExistsException, AuthorizationDeniedException, CertificateEncodingException, CertificateException, OperatorCreationException { // Get CA that will process request final CA ca = caSession.getCA(admin, caid); if (log.isDebugEnabled()) { log.debug("Extended service with request class '" + request.getClass().getName() + "' called for CA '" + ca.getName() + "'"); }//from www.j a v a 2 s. c o m // We do not yet support using a separate crypto token for key recovery, although we have it stored in the key recovery entry // so everything is prepared for this possibility. final CryptoToken cryptoToken = cryptoTokenSession.getCryptoToken(ca.getCAToken().getCryptoTokenId()); final ExtendedCAServiceResponse resp = ca.extendedService(cryptoToken, request); final String msg = intres.getLocalizedMessage("caadmin.extendedserviceexecuted", request.getClass().getName(), ca.getName()); final Map<String, Object> details = new LinkedHashMap<String, Object>(); details.put("msg", msg); auditSession.log(EjbcaEventTypes.CA_EXTENDEDSERVICE, EventStatus.SUCCESS, ModuleTypes.CA, EjbcaServiceTypes.EJBCA, admin.toString(), String.valueOf(caid), null, null, details); return resp; }
From source file:org.ejbca.core.ejb.ca.caadmin.CAAdminSessionBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public void flushCACache() { // Just forward the call, because in CaSession it is only in the local interface and we // want to be able to use it from CLI caSession.flushCACache();/*from ww w. ja va 2s. c o m*/ }
From source file:org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override//from w w w . ja v a 2 s . c o m public boolean checkIfCertificateBelongToUser(BigInteger certificatesnr, String issuerdn) { if (!WebConfiguration.getRequireAdminCertificateInDatabase()) { if (log.isTraceEnabled()) { log.trace("<checkIfCertificateBelongToUser Configured to ignore if cert belongs to user."); } return true; } final String username = certificateStoreSession.findUsernameByCertSerno(certificatesnr, issuerdn); if (username != null) { if (UserData.findByUsername(entityManager, username) == null) { final String msg = intres.getLocalizedMessage("ra.errorcertnouser", issuerdn, certificatesnr.toString(16)); log.info(msg); return false; } else { return true; } } else { return false; } }
From source file:org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/* w w w.ja va 2 s. c o m*/ public Collection<EndEntityInformation> findAllUsersByStatus(AuthenticationToken admin, int status) { if (log.isTraceEnabled()) { log.trace(">findAllUsersByStatus(" + status + ")"); } if (log.isDebugEnabled()) { log.debug("Looking for users with status: " + status); } Query query = new Query(Query.TYPE_USERQUERY); query.add(UserMatch.MATCH_WITH_STATUS, BasicMatch.MATCH_TYPE_EQUALS, Integer.toString(status)); Collection<EndEntityInformation> returnval = null; try { returnval = query(admin, query, false, null, null, 0); } catch (IllegalQueryException e) { } if (log.isDebugEnabled()) { log.debug("found " + returnval.size() + " user(s) with status=" + status); } if (log.isTraceEnabled()) { log.trace("<findAllUsersByStatus(" + status + ")"); } return returnval; }
From source file:org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/* www .j a v a 2s . c o m*/ public Collection<EndEntityInformation> findAllUsersByCaId(AuthenticationToken admin, int caid) { if (log.isTraceEnabled()) { log.trace(">findAllUsersByCaId(" + caid + ")"); } if (log.isDebugEnabled()) { log.debug("Looking for users with caid: " + caid); } Query query = new Query(Query.TYPE_USERQUERY); query.add(UserMatch.MATCH_WITH_CA, BasicMatch.MATCH_TYPE_EQUALS, Integer.toString(caid)); Collection<EndEntityInformation> returnval = null; try { returnval = query(admin, query, false, null, null, 0); } catch (IllegalQueryException e) { // Ignore ?? log.debug("Illegal query", e); returnval = new ArrayList<EndEntityInformation>(); } if (log.isDebugEnabled()) { log.debug("found " + returnval.size() + " user(s) with caid=" + caid); } if (log.isTraceEnabled()) { log.trace("<findAllUsersByCaId(" + caid + ")"); } return returnval; }
From source file:org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.java
@SuppressWarnings("unchecked") @TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/* w w w. ja va 2 s . co m*/ public List<EndEntityInformation> findUsers(List<Integer> caIds, long timeModified, int status) { String queryString = "SELECT a FROM UserData a WHERE (a.timeModified <=:timeModified) AND (a.status=:status)"; if (caIds.size() > 0) { queryString += " AND (a.caId=:caId0"; for (int i = 1; i < caIds.size(); i++) { queryString += " OR a.caId=:caId" + i; } queryString += ")"; } if (log.isDebugEnabled()) { log.debug("Checking for " + caIds.size() + " CAs"); log.debug("Generated query string: " + queryString); } javax.persistence.Query query = entityManager.createQuery(queryString); query.setParameter("timeModified", timeModified); query.setParameter("status", status); if (caIds.size() > 0) { for (int i = 0; i < caIds.size(); i++) { query.setParameter("caId" + i, caIds.get(i)); } } final List<UserData> queryResult = (List<UserData>) query.getResultList(); final List<EndEntityInformation> ret = new ArrayList<EndEntityInformation>(queryResult.size()); for (UserData userData : queryResult) { ret.add(userData.toEndEntityInformation()); } return ret; }
From source file:org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/*ww w .j av a 2 s . co m*/ public Collection<EndEntityInformation> findAllUsersWithLimit(AuthenticationToken admin) { if (log.isTraceEnabled()) { log.trace(">findAllUsersWithLimit()"); } Collection<EndEntityInformation> returnval = null; try { returnval = query(admin, null, true, null, null, 0); } catch (IllegalQueryException e) { } if (log.isTraceEnabled()) { log.trace("<findAllUsersWithLimit()"); } return returnval; }
From source file:org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/*from w w w . j av a2s . c o m*/ public List<EndEntityInformation> findAllBatchUsersByStatusWithLimit(int status) { if (log.isTraceEnabled()) { log.trace(">findAllUsersByStatusWithLimit()"); } final List<UserData> userDataList = UserData.findAllBatchUsersByStatus(entityManager, status, EndEntityManagementConstants.MAXIMUM_QUERY_ROWCOUNT); final List<EndEntityInformation> returnval = new ArrayList<EndEntityInformation>(userDataList.size()); for (UserData ud : userDataList) { EndEntityInformation endEntityInformation = ud.toEndEntityInformation(); if (endEntityInformation.getPassword() != null && endEntityInformation.getPassword().length() > 0) { returnval.add(endEntityInformation); } } if (log.isTraceEnabled()) { log.trace("<findAllUsersByStatusWithLimit()"); } return returnval; }
From source file:org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override//from ww w . j a va2s .co m public Collection<EndEntityInformation> query(final AuthenticationToken admin, final Query query, final String caauthorizationstring, final String endentityprofilestring, final int numberofrows) throws IllegalQueryException { return query(admin, query, true, caauthorizationstring, endentityprofilestring, numberofrows); }