Example usage for javax.ejb LockType WRITE

List of usage examples for javax.ejb LockType WRITE

Introduction

In this page you can find the example usage for javax.ejb LockType WRITE.

Prototype

LockType WRITE

To view the source code for javax.ejb LockType WRITE.

Click Source Link

Document

For exclusive access to the bean instance.

Usage

From source file:br.ufac.sion.service.EnviaEmailService.java

@Lock(LockType.WRITE)
public void processaEnvioDeEmail(InfoEmail infoEmail) throws NegocioException {
    if (infoEmail == null) {
        throw new NegocioException("No foi possvel enviar o e-mail. Contedo vzio!");
    } else {//from  w  w w. ja v a2  s  .  c o  m
        if (StringUtils.isBlank(infoEmail.getPara())) {
            throw new NegocioException("No foi possvel enviar o e-mail. Remetente invlido!");
        }
    }
    context.createProducer().send(emailQueue, infoEmail);
}

From source file:be.fedict.hsm.model.KeyStoreSingletonBean.java

@PostConstruct
@Lock(LockType.WRITE)
public void loadKeys() {
    LOG.debug("load keys...");
    this.privateKeyEntries = new HashMap<Long, Map<String, PrivateKeyEntry>>();
    List<KeyStoreEntity> keyStoreEntities = KeyStoreEntity.getList(this.entityManager);
    for (KeyStoreEntity keyStoreEntity : keyStoreEntities) {
        load(keyStoreEntity);/*from w  w  w.  j  a  v  a 2s . com*/
    }
}

From source file:io.hops.hopsworks.common.security.OpensslOperations.java

@Lock(LockType.WRITE)
public String createUserCertificate(String projectName, String userName, String countryCode, String city,
        String organization, String email, String orcid, String userKeyPassword) throws IOException {

    return createServiceCertificate(Utils.getProjectUsername(projectName, userName), countryCode, city,
            organization, email, orcid, userKeyPassword);
}

From source file:io.hops.hopsworks.common.security.OpensslOperations.java

@Lock(LockType.WRITE)
public String createServiceCertificate(String service, String countryCode, String city, String organization,
        String email, String orcid, String userKeyPassword) throws IOException {

    String intermediateCADir = pki.getCAParentPath(PKI.CAType.INTERMEDIATE);
    File certificateFile = pki.getCertPath(PKI.CAType.INTERMEDIATE, service).toFile();
    File keyFile = pki.getKeyPath(PKI.CAType.INTERMEDIATE, service).toFile();

    if (certificateFile.exists() || keyFile.exists()) {
        String errorMsg = "X.509 key-pair already exists in " + certificateFile.getAbsolutePath() + " and "
                + keyFile.getAbsolutePath();
        LOG.log(Level.SEVERE, errorMsg);
        throw new IOException(errorMsg);
    }// w  ww  .j  a  v  a  2  s . com

    // Need to execute CreatingUserCerts.sh as 'root' using sudo.
    // Solution is to add them to /etc/sudoers.d/glassfish file. Chef cookbook does this for us.
    List<String> commands = new ArrayList<>(9);
    commands.add(SUDO);
    commands.add(Paths.get(intermediateCADir, Settings.SSL_CREATE_CERT_SCRIPTNAME).toString());
    commands.add(service);
    commands.add(countryCode);
    commands.add(city);
    commands.add(organization);
    commands.add(email);
    commands.add(orcid);
    commands.add(userKeyPassword);

    return executeCommand(commands, false);
}

From source file:be.fedict.hsm.model.KeyStoreSingletonBean.java

@Lock(LockType.WRITE)
public boolean newKeyStore(long keyStoreId) {
    KeyStoreEntity keyStoreEntity = this.entityManager.find(KeyStoreEntity.class, keyStoreId);
    LOG.debug("new key store: " + keyStoreId);
    return load(keyStoreEntity);
}

From source file:be.fedict.hsm.model.KeyStoreSingletonBean.java

@Lock(LockType.WRITE)
public List<String> getKeyStoreAliases(long keyStoreId) {
    Map<String, PrivateKeyEntry> keyStorePrivateKeys = this.privateKeyEntries.get(keyStoreId);
    if (null == keyStorePrivateKeys) {
        return new LinkedList<String>();
    }/*from w ww . ja va  2 s  .  c  o m*/
    List<String> aliases = new LinkedList<String>();
    for (String alias : keyStorePrivateKeys.keySet()) {
        LOG.debug("key store alias: " + alias);
        aliases.add(alias);
    }
    return aliases;
}

From source file:io.hops.hopsworks.common.security.OpensslOperations.java

@Lock(LockType.WRITE)
public String deleteUserCertificate(String projectSpecificUsername) throws IOException {
    String intermediateCADir = pki.getCAParentPath(PKI.CAType.INTERMEDIATE);
    List<String> commands = new ArrayList<>(3);
    commands.add(SUDO);//from  w w  w.  j a va2  s . c  o  m
    commands.add(Paths.get(intermediateCADir, Settings.SSL_DELETE_CERT_SCRIPTNAME).toString());
    commands.add(projectSpecificUsername);

    return executeCommand(commands, false);
}

From source file:be.fedict.hsm.model.KeyStoreSingletonBean.java

@Lock(LockType.WRITE)
public void removeKeyStore(long keyStoreId) {
    this.privateKeyEntries.remove(keyStoreId);
}

From source file:be.fedict.hsm.model.KeyStoreSingletonBean.java

@Lock(LockType.WRITE)
public boolean reload(long keyStoreId) {
    this.privateKeyEntries.remove(keyStoreId);
    KeyStoreEntity keyStoreEntity = this.entityManager.find(KeyStoreEntity.class, keyStoreId);
    return load(keyStoreEntity);
}

From source file:io.hops.hopsworks.common.security.OpensslOperations.java

@Lock(LockType.WRITE)
public String deleteProjectCertificate(String projectName) throws IOException {
    String intermediateCADir = pki.getCAParentPath(PKI.CAType.INTERMEDIATE);
    List<String> commands = new ArrayList<>(3);
    commands.add(SUDO);/*from   w w w . j  a  v  a 2s. c  o m*/
    commands.add(Paths.get(intermediateCADir, Settings.SSL_DELETE_PROJECT_CERTS_SCRIPTNAME).toString());
    commands.add(projectName);

    return executeCommand(commands, false);
}