-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
126 additions
and
3 deletions.
There are no files selected for viewing
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
50 changes: 50 additions & 0 deletions
50
ebms-provider/src/main/kotlin/no/nav/emottak/ebms/model/EbmsExt.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package no.nav.emottak.ebms.model | ||
|
||
import org.apache.commons.lang3.StringUtils.isNotBlank | ||
import org.oasis_open.committees.ebxml_msg.schema.msg_header_2_0.AckRequested | ||
import org.oasis_open.committees.ebxml_msg.schema.msg_header_2_0.From | ||
import org.oasis_open.committees.ebxml_msg.schema.msg_header_2_0.Manifest | ||
import org.oasis_open.committees.ebxml_msg.schema.msg_header_2_0.MessageHeader | ||
import org.xmlsoap.schemas.soap.envelope.Envelope | ||
|
||
// TODO kan sikkert flytte alt dette til der det brukes. | ||
|
||
fun Envelope.getConversationId() : String { | ||
val header = this.header.any[0] | ||
if (header is MessageHeader) | ||
return header.conversationId | ||
else | ||
throw RuntimeException("Kunne ikke finne conversation ID"); | ||
} | ||
|
||
fun Envelope.getAttachmentId() : String { // TODO: egentlig kan vel det være n+1 attachments | ||
val manifest = this.body.any.find { it is Manifest } as Manifest | ||
return manifest.reference.map { it.href } | ||
.first().replace("cid:", ""); // quickndirty | ||
} | ||
|
||
fun Envelope.getFrom (): From { | ||
return (this.header.any.find { it is MessageHeader } as MessageHeader).from | ||
} | ||
|
||
fun Envelope.getMessageId(): String { | ||
return this.header.any.filterIsInstance<MessageHeader>() | ||
.stream().filter { isNotBlank(it.id) } | ||
.map { it.id }.findFirst().get() | ||
} | ||
|
||
fun Envelope.getVersion(): String { | ||
return this.header.any.filterIsInstance<MessageHeader>() | ||
.stream().filter { isNotBlank(it.version) } | ||
.map { it.version }.findFirst().get() | ||
} | ||
|
||
fun Envelope.getActor(): String { | ||
return this.header.any.filterIsInstance<AckRequested>().stream() | ||
.filter{ isNotBlank(it.actor) }.map { it.actor }.findFirst().get() | ||
} | ||
|
||
fun Envelope.getAckRequestedSigned(): Boolean { | ||
return this.header.any.filterIsInstance<AckRequested>().stream() | ||
.anyMatch { it.isSigned } // Kotlin quirk. Med isSigned menes at en signed Ack er ønsket | ||
} |
44 changes: 44 additions & 0 deletions
44
ebms-provider/src/main/kotlin/no/nav/emottak/ebms/processing/AckRequestedProcessor.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package no.nav.emottak.ebms.processing | ||
|
||
import com.github.labai.jsr305x.api.NotNull | ||
import no.nav.emottak.ebms.model.* | ||
import no.nav.emottak.ebms.xml.xmlMarshaller | ||
import org.apache.commons.lang3.StringUtils.isNotBlank | ||
import org.oasis_open.committees.ebxml_msg.schema.msg_header_2_0.AckRequested | ||
import org.oasis_open.committees.ebxml_msg.schema.msg_header_2_0.Acknowledgment | ||
import org.oasis_open.committees.ebxml_msg.schema.msg_header_2_0.MessageHeader | ||
import org.oasis_open.committees.ebxml_msg.schema.msg_header_2_0.ObjectFactory | ||
import org.w3._2000._09.xmldsig_.ReferenceType | ||
import org.xmlsoap.schemas.soap.envelope.Envelope | ||
import java.time.Instant | ||
import java.util.* | ||
import kotlin.coroutines.Continuation | ||
|
||
class AckRequestedProcessor(): Processor { | ||
|
||
fun createAcknowledgement(envelope: Envelope): Acknowledgment { | ||
val acknowledgment = Acknowledgment() | ||
acknowledgment.id = "ACK_ID" // Identifier for Acknowledgment elementet, IKKE message ID. // TODO avklar, dette er såvidt jeg vet en arbitrær verdi? | ||
acknowledgment.version = envelope.getVersion() | ||
acknowledgment.isMustUnderstand = true // Alltid | ||
acknowledgment.actor = envelope.getActor() | ||
acknowledgment.timestamp = Date.from(Instant.now()) // TODO dette skal være message received date, hente fra context? | ||
acknowledgment.refToMessageId = envelope.getMessageId() | ||
acknowledgment.from = envelope.getFrom() | ||
if(envelope.getAckRequestedSigned()) { | ||
// TODO vi må signere responsen, kan kanskje alltid gjøres uansett? | ||
acknowledgment.reference.addAll(getReferences()) | ||
} | ||
//acknowledgment.otherAttributes | ||
return acknowledgment | ||
} | ||
|
||
fun getReferences(): List<@NotNull ReferenceType> { | ||
return emptyList() // TODO XMLDSIG elements fra signaturen vår | ||
} | ||
|
||
override fun process() { | ||
TODO("Not yet implemented") | ||
} | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
ebms-provider/src/main/kotlin/no/nav/emottak/ebms/processing/Processor.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package no.nav.emottak.ebms.processing | ||
|
||
fun interface Processor { | ||
fun process() // TODO kan sikkert ta imot en context. EbmsMessageContext? | ||
} |
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