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.ra.EndEntityManagementSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override// w w w . j a v a2s. c o m public boolean checkForEndEntityProfileId(int endentityprofileid) { if (log.isTraceEnabled()) { log.trace(">checkForEndEntityProfileId(" + endentityprofileid + ")"); } long count = UserData.countByEndEntityProfileId(entityManager, endentityprofileid); if (log.isTraceEnabled()) { log.trace("<checkForEndEntityProfileId(" + endentityprofileid + "): " + count); } return count > 0; }
From source file:org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/* www .j av a 2 s . c o m*/ public List<String> findByCertificateProfileId(int certificateprofileid) { if (log.isTraceEnabled()) { log.trace(">checkForCertificateProfileId(" + certificateprofileid + ")"); } final javax.persistence.Query query = entityManager .createQuery("SELECT a FROM UserData a WHERE a.certificateProfileId=:certificateProfileId"); query.setParameter("certificateProfileId", certificateprofileid); List<String> result = new ArrayList<String>(); for (Object userDataObject : query.getResultList()) { result.add(((UserData) userDataObject).getUsername()); } if (log.isTraceEnabled()) { log.trace("<checkForCertificateProfileId(" + certificateprofileid + "): " + result.size()); } return result; }
From source file:org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override// ww w .j a v a 2 s . c o m public boolean checkForCAId(int caid) { if (log.isTraceEnabled()) { log.trace(">checkForCAId()"); } return UserData.countByCaId(entityManager, caid) > 0; }
From source file:org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/* www. j av a 2s. co m*/ public boolean checkForHardTokenProfileId(int profileid) { if (log.isTraceEnabled()) { log.trace(">checkForHardTokenProfileId()"); } return UserData.countByHardTokenProfileId(entityManager, profileid) > 0; }
From source file:org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/*from w ww.ja v a 2 s . c om*/ public boolean existsUser(String username) { boolean returnval = true; if (UserData.findByUsername(entityManager, username) == null) { returnval = false; } return returnval; }
From source file:org.ejbca.core.ejb.ra.raadmin.EndEntityProfileSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/*from w w w . ja va2 s . co m*/ public List<String> getEndEntityProfilesUsingCertificateProfile(final int certificateProfileId) { String[] availprofiles = null; List<String> result = new ArrayList<String>(); for (EndEntityProfileData profileData : EndEntityProfileData.findAll(entityManager)) { availprofiles = profileData.getProfile().getValue(EndEntityProfile.AVAILCERTPROFILES, 0) .split(EndEntityProfile.SPLITCHAR); for (String profileId : availprofiles) { if (Integer.parseInt(profileId) == certificateProfileId) { result.add(profileData.getProfileName()); break; } } } return result; }
From source file:org.ejbca.core.ejb.ra.raadmin.EndEntityProfileSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override//from ww w .j a v a2 s. c o m public boolean existsCAInEndEntityProfiles(final int caid) { String[] availablecas = null; boolean exists = false; final Collection<EndEntityProfileData> result = EndEntityProfileData.findAll(entityManager); final Iterator<EndEntityProfileData> i = result.iterator(); while (i.hasNext() && !exists) { final EndEntityProfileData ep = i.next(); availablecas = ep.getProfile().getValue(EndEntityProfile.AVAILCAS, 0).split(EndEntityProfile.SPLITCHAR); for (int j = 0; j < availablecas.length; j++) { if (StringUtils.isNotEmpty(availablecas[j])) { if (Integer.parseInt(availablecas[j]) == caid) { exists = true; if (LOG.isDebugEnabled()) { LOG.debug("CA exists in entity profile " + ep.getProfileName()); } break; } } else if (LOG.isDebugEnabled()) { LOG.debug("One of the availableCAs is empty string, fishy, but we ignore it. EE profile: " + ep.getProfileName()); } } } return exists; }
From source file:org.ejbca.core.ejb.ra.raadmin.EndEntityProfileSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/*from www. ja va 2s. c om*/ public EndEntityProfile getEndEntityProfile(final String profilename) { if (LOG.isTraceEnabled()) { LOG.trace(">getEndEntityProfile(" + profilename + ")"); } EndEntityProfile returnval = getEndEntityProfileNoClone(profilename); try { if (returnval != null) { returnval = (EndEntityProfile) returnval.clone(); } } catch (CloneNotSupportedException e) { LOG.error("Should never happen: ", e); throw new RuntimeException(e); } if (LOG.isTraceEnabled()) { LOG.trace("<getEndEntityProfile(" + profilename + "): " + (returnval == null ? "null" : "not null")); } return returnval; }
From source file:org.ejbca.core.ejb.ra.raadmin.EndEntityProfileSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/*from w ww.j a va 2 s. c o m*/ public EndEntityProfile getEndEntityProfileNoClone(final String profilename) { if (LOG.isTraceEnabled()) { LOG.trace(">getEndEntityProfileNoClone(" + profilename + ")"); } EndEntityProfile returnval = null; if (profilename.equals(EMPTY_ENDENTITYPROFILENAME)) { returnval = new EndEntityProfile(true); } else { final Integer id = profileCache.getNameIdMapCache(entityManager).get(profilename); if (id != null) { returnval = getEndEntityProfileNoClone(id); } } if (LOG.isTraceEnabled()) { LOG.trace("<getEndEntityProfileNoClone(" + profilename + "): " + (returnval == null ? "null" : "not null")); } return returnval; }
From source file:org.ejbca.core.ejb.ra.raadmin.EndEntityProfileSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override//w w w. java 2 s. c o m public Collection<Integer> getAuthorizedEndEntityProfileIds(final AuthenticationToken admin) { final ArrayList<Integer> returnval = new ArrayList<Integer>(); final HashSet<Integer> authorizedcaids = new HashSet<Integer>(caSession.getAuthorizedCaIds(admin)); final HashSet<Integer> allcaids = new HashSet<Integer>(caSession.getAllCaIds()); // If this is the special value ALLCAs we are authorized authorizedcaids.add(Integer.valueOf(SecConst.ALLCAS)); final boolean rootAccess = authSession.isAuthorizedNoLogging(admin, StandardRules.ROLE_ROOT.resource()); if (authSession.isAuthorizedNoLogging(admin, AccessRulesConstants.ENDENTITYPROFILEBASE + "/" + SecConst.EMPTY_ENDENTITYPROFILE + AccessRulesConstants.CREATE_END_ENTITY)) { returnval.add(SecConst.EMPTY_ENDENTITYPROFILE); } try { for (final Entry<Integer, EndEntityProfile> entry : profileCache.getProfileCache(entityManager) .entrySet()) { // Check if all profiles available CAs exists in authorizedcaids. final String availableCasString = entry.getValue().getValue(EndEntityProfile.AVAILCAS, 0); if (availableCasString != null) { boolean authorizedToProfile = true; for (final String caidString : availableCasString.split(EndEntityProfile.SPLITCHAR)) { final int caIdInt = Integer.parseInt(caidString); // with root rule access you can edit profiles with missing CA ids if (!authorizedcaids.contains(caIdInt) && (!rootAccess || allcaids.contains(caIdInt))) { authorizedToProfile = false; if (LOG.isDebugEnabled()) { LOG.debug("Profile " + entry.getKey().toString() + " not authorized to CA with ID " + caIdInt); } break; } } if (authorizedToProfile && authSession.isAuthorizedNoLogging(admin, AccessRulesConstants.ENDENTITYPROFILEBASE + "/" + entry.getKey() + AccessRulesConstants.CREATE_END_ENTITY)) { returnval.add(entry.getKey()); } } } } catch (Exception e) { LOG.error(INTRES.getLocalizedMessage("ra.errorgetids"), e); } return returnval; }