-
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.
Merge pull request #25 from Kilemonn/authenticated-sub-queue
Authenticated sub queue
- Loading branch information
Showing
73 changed files
with
5,327 additions
and
1,260 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
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
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
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
56 changes: 56 additions & 0 deletions
56
src/main/kotlin/au/kilemon/messagequeue/authentication/AuthenticationMatrix.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,56 @@ | ||
package au.kilemon.messagequeue.authentication | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore | ||
import java.io.Serializable | ||
import javax.persistence.* | ||
|
||
/** | ||
* An object that holds subqueue authentication information. | ||
* If a specific sub-queue is in restricted mode it will have a matching [AuthenticationMatrix] created which will | ||
* be checked to verify if a specific sub-queue can be operated on. | ||
* This object is used for `In-memory`, `SQL` and `Redis`. | ||
* | ||
* @author github.com/Kilemonn | ||
*/ | ||
@Entity | ||
@Table(name = AuthenticationMatrix.TABLE_NAME) | ||
class AuthenticationMatrix(@Column(name = "subqueue", nullable = false) var subQueue: String): Serializable | ||
{ | ||
companion object | ||
{ | ||
const val TABLE_NAME: String = "multiqueueauthenticationmatrix" | ||
} | ||
|
||
@JsonIgnore | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
var id: Long? = null | ||
|
||
/** | ||
* Required for MySQL. | ||
*/ | ||
constructor() : this("") | ||
|
||
/** | ||
* Overriding to only include specific properties when checking if messages are equal. | ||
* This checks the following are equal in order to return `true`: | ||
* - subQueue | ||
*/ | ||
override fun equals(other: Any?): Boolean | ||
{ | ||
if (other == null || other !is AuthenticationMatrix) | ||
{ | ||
return false | ||
} | ||
|
||
return other.subQueue == this.subQueue | ||
} | ||
|
||
/** | ||
* Only performs a hashcode on the properties checked in [AuthenticationMatrix.equals]. | ||
*/ | ||
override fun hashCode(): Int | ||
{ | ||
return subQueue.hashCode() | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/au/kilemon/messagequeue/authentication/AuthenticationMatrixDocument.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,24 @@ | ||
package au.kilemon.messagequeue.authentication | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore | ||
import org.springframework.data.annotation.Id | ||
import org.springframework.data.mongodb.core.mapping.Document | ||
|
||
/** | ||
* A holder object for the restricted sub-queues. Refer to [AuthenticationMatrix]. | ||
* This is used only for `Mongo`. | ||
* | ||
* @author github.com/Kilemonn | ||
*/ | ||
@Document(value = AuthenticationMatrixDocument.DOCUMENT_NAME) | ||
class AuthenticationMatrixDocument(var subQueue: String) | ||
{ | ||
companion object | ||
{ | ||
const val DOCUMENT_NAME: String = "multiqueueauthenticationmatrix" | ||
} | ||
|
||
@JsonIgnore | ||
@Id | ||
var id: Long? = null | ||
} |
Oops, something went wrong.