Skip to content

Commit

Permalink
session id, url and hash are now part of one json object
Browse files Browse the repository at this point in the history
  • Loading branch information
neowit committed Jul 9, 2014
1 parent b369c54 commit eba5205
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/main/scala/com/neowit/apex/Session.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ class Session(config: Config) extends Logging {
def storeSessionData() {
config.storeSessionProps()
}
def getSavedConnectionData = {
def getSavedConnectionData :(Option[String], Option[String])= {

val emptySession = (None, None)
if (!callingAnotherOrg) {
sessionProperties.getPropertyOption("checksum") match {
case Some(checksum) if checksum == getChecksum =>
(sessionProperties.getPropertyOption("sessionId"), sessionProperties.getPropertyOption("serviceEndpoint"))
val connectionData = getData("session")
connectionData.get("checksum") match {
case Some(checksum) =>
if (checksum == getChecksum)
(connectionData.get("sessionId").map(_.toString), connectionData.get("serviceEndpoint").map(_.toString))
else
emptySession
case None =>
emptySession
}
Expand All @@ -84,12 +88,13 @@ class Session(config: Config) extends Logging {

def storeConnectionData(connectionConfig: com.sforce.ws.ConnectorConfig) {
if (!callingAnotherOrg) {
sessionProperties.setProperty("sessionId", connectionConfig.getSessionId)
sessionProperties.setProperty("serviceEndpoint", connectionConfig.getServiceEndpoint)
sessionProperties.setProperty("checksum", getChecksum)
sessionProperties.setJsonData("session", Map(
"sessionId" -> connectionConfig.getSessionId,
"serviceEndpoint" -> connectionConfig.getServiceEndpoint,
"checksum" -> getChecksum
))
} else {
sessionProperties.remove("sessionId")
sessionProperties.remove("checksum")
sessionProperties.remove("session")
}
storeSessionData()
}
Expand Down Expand Up @@ -360,9 +365,7 @@ class Session(config: Config) extends Logging {
}
}
def reset() {
sessionProperties.remove("sessionId")
sessionProperties.remove("serviceEndpoint")
sessionProperties.remove("checksum")
sessionProperties.remove("session")
storeSessionData()
connectionPartner = None
connectionMetadata = None
Expand Down

0 comments on commit eba5205

Please sign in to comment.