public class WebHookManager extends Object
Constructor and Description |
---|
WebHookManager()
Create a WebHookManager to handle GitLab webhook events.
|
WebHookManager(String secretToken)
Create a WebHookManager to handle GitLab webhook events which will be verified
against the specified secretToken.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(WebHookListener listener)
Adds a WebHook event listener.
|
protected void |
fireBuildEvent(BuildEvent buildEvent) |
void |
fireEvent(Event event)
Fire the event to the registered listeners.
|
protected void |
fireIssueEvent(IssueEvent issueEvent) |
protected void |
fireMergeRequestEvent(MergeRequestEvent mergeRequestEvent) |
protected void |
fireNoteEvent(NoteEvent noteEvent) |
protected void |
firePipelineEvent(PipelineEvent pipelineEvent) |
protected void |
firePushEvent(PushEvent pushEvent) |
protected void |
fireTagPushEvent(TagPushEvent tagPushEvent) |
protected void |
fireWikiPageEvent(WikiPageEvent wikiPageEvent) |
void |
handleEvent(Event event)
Verifies the provided Event and fires it off to the registered listeners.
|
void |
handleEvent(javax.servlet.http.HttpServletRequest request)
Parses and verifies an Event instance from the HTTP request and
fires it off to the registered listeners.
|
boolean |
isValidSecretToken(javax.servlet.http.HttpServletRequest request)
Validate the provided secret token found in the HTTP header against the reference secret token.
|
boolean |
isValidSecretToken(String secretToken)
Validate the provided secret token against the reference secret token.
|
void |
removeListener(WebHookListener listener)
Removes a WebHook event listener.
|
void |
setSecretToken(String secretToken)
Set the secret token that received webhook events should be validated against.
|
public WebHookManager()
public WebHookManager(String secretToken)
secretToken
- the secret token to verify againstpublic void setSecretToken(String secretToken)
secretToken
- the secret token to verify againstpublic boolean isValidSecretToken(String secretToken)
secretToken
- the token to validatepublic boolean isValidSecretToken(javax.servlet.http.HttpServletRequest request)
request
- the HTTP request to verify the secret tokenpublic void handleEvent(javax.servlet.http.HttpServletRequest request) throws GitLabApiException
request
- the HttpServletRequest to read the Event instance fromGitLabApiException
- if the parsed event is not supportedpublic void handleEvent(Event event) throws GitLabApiException
event
- the Event instance to handleGitLabApiException
- if the event is not supportedpublic void addListener(WebHookListener listener)
listener
- the WebHookListener to addpublic void removeListener(WebHookListener listener)
listener
- the WebHookListener to removepublic void fireEvent(Event event) throws GitLabApiException
event
- the Event instance to fire to the registered event listenersGitLabApiException
- if the event is not supportedprotected void fireBuildEvent(BuildEvent buildEvent)
protected void fireIssueEvent(IssueEvent issueEvent)
protected void fireMergeRequestEvent(MergeRequestEvent mergeRequestEvent)
protected void fireNoteEvent(NoteEvent noteEvent)
protected void firePipelineEvent(PipelineEvent pipelineEvent)
protected void firePushEvent(PushEvent pushEvent)
protected void fireTagPushEvent(TagPushEvent tagPushEvent)
protected void fireWikiPageEvent(WikiPageEvent wikiPageEvent)
Copyright © 2017. All rights reserved.