Created
December 5, 2012 11:18
-
-
Save agnaldo4j/4214821 to your computer and use it in GitHub Desktop.
Conectando ao Bonita, gerenciando processos de desenvolvimento
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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