-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathiselogparser.go
58 lines (52 loc) · 1.58 KB
/
iselogparser.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package ciscoiselogparser
import (
"encoding/json"
"errors"
)
const (
eapPeapAllowedProtocols = "EAP-PEAP-ALLOWED-PROTOCOLS"
hostLookupAllowedProtocols = "HOST-LOOKUP-ALLOWED-PROTOCOLS"
papAllowedProtocols = "PAP-ALLOWED-PROTOCOLS"
)
// IseLogAccessService contains the AccessService, which will determine the shape of the EventLog
type IseLogAccessService struct {
AccessService string `json:"access_service,omitempty"`
EventLog
}
// EventLog will either be a PAP Allowed Protocol, Host Lookup Allowed Protocol, or EAP-PEAP Allowed Protocol Log
type EventLog interface{}
// UnmarshalJSON for *IseLogAccessService
func (iseLog *IseLogAccessService) UnmarshalJSON(data []byte) error {
type Alias IseLogAccessService
aux := &struct {
*Alias
}{
Alias: (*Alias)(iseLog),
}
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
switch aux.AccessService {
case papAllowedProtocols:
var papProtocolISELog PAPAllowedProtocolsLog
if err := json.Unmarshal(data, &papProtocolISELog); err != nil {
return err
}
iseLog.EventLog = papProtocolISELog
case hostLookupAllowedProtocols:
var HostProtocolISELog HostLookupAllowedProtocolsLog
if err := json.Unmarshal(data, &HostProtocolISELog); err != nil {
return err
}
iseLog.EventLog = HostProtocolISELog
case eapPeapAllowedProtocols:
var EapProtocolISELog EAPPEAPAllowedProtocolsLog
if err := json.Unmarshal(data, &EapProtocolISELog); err != nil {
return err
}
iseLog.EventLog = EapProtocolISELog
default:
return errors.New("ISE Log Protocol was not found or is not supported")
}
return nil
}