Skip to content

Instantly share code, notes, and snippets.

@agnaldo4j
Created December 5, 2012 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save agnaldo4j/4214821 to your computer and use it in GitHub Desktop.
Save agnaldo4j/4214821 to your computer and use it in GitHub Desktop.
Conectando ao Bonita, gerenciando processos de desenvolvimento
package com.softsimples.bpm
import javax.security.auth.login.LoginContext
import org.ow2.bonita.util.{AccessorUtil, SimpleCallbackHandler, BonitaConstants}
import scala.collection.JavaConversions._
import org.ow2.bonita.facade.identity.User
import org.bonitasoft.console.security.server.api.{ICredentialsEncryptionAPI, SecurityAPIFactory}
object BPMConnector {
private val jaasFile = getClass.getResource("jaas-standard.cfg").getFile
private val BONITA_HOME = getClass.getClassLoader.getResource("bonita_home").getFile
def buildBPMConnector(login:String, password:String): BPMConnector = {
println(BONITA_HOME)
System.setProperty(BonitaConstants.API_TYPE_PROPERTY, "REST")
System.setProperty(BonitaConstants.REST_SERVER_ADDRESS_PROPERTY, "http://localhost:8080/bonita-server-rest/")
System.setProperty(BonitaConstants.JAAS_PROPERTY, jaasFile)
System.setProperty("BONITA_HOME", BONITA_HOME);
var loginContext = new LoginContext("BonitaAuth", new SimpleCallbackHandler(login, password))
loginContext.login()
loginContext.logout()
loginContext = new LoginContext("BonitaStore", new SimpleCallbackHandler(login, password))
loginContext.login()
val identity = AccessorUtil.getIdentityAPI
for(cada <- identity.getUsers.toSet[User] ) println(cada.getFirstName)
val credentialsAPI = SecurityAPIFactory.getCredentialsEncryptionAPI()
val encryptedCredentials = credentialsAPI.encryptCredential(login + ICredentialsEncryptionAPI.USER_CREDENTIALS_SEPARATOR + password);
println(AccessorUtil.getWebAPI().generateTemporaryToken(encryptedCredentials));
new BPMConnector()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment