Commit c4ab7b22 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Fix bugs

parent 3c37d790
...@@ -193,6 +193,9 @@ func (attr *MetadataAttribute) setValidityDuration(weeks int) { ...@@ -193,6 +193,9 @@ func (attr *MetadataAttribute) setValidityDuration(weeks int) {
} }
func (attr *MetadataAttribute) setExpiryDate(timestamp *Timestamp) error { func (attr *MetadataAttribute) setExpiryDate(timestamp *Timestamp) error {
if timestamp == nil {
return nil
}
expiry := time.Time(*timestamp).Unix() expiry := time.Time(*timestamp).Unix()
signing := attr.SigningDate().Unix() signing := attr.SigningDate().Unix()
attr.setValidityDuration(int((expiry - signing) / ExpiryFactor)) attr.setValidityDuration(int((expiry - signing) / ExpiryFactor))
......
...@@ -48,7 +48,11 @@ type IrmaIdentifierSet struct { ...@@ -48,7 +48,11 @@ type IrmaIdentifierSet struct {
// Parent returns the parent object of this identifier. // Parent returns the parent object of this identifier.
func (oi metaObjectIdentifier) Parent() string { func (oi metaObjectIdentifier) Parent() string {
str := string(oi) str := string(oi)
return str[:strings.LastIndex(str, ".")] if i := strings.LastIndex(str, "."); i != -1 {
return str[:i]
} else {
return str
}
} }
// Name returns the last part of this identifier. // Name returns the last part of this identifier.
...@@ -62,6 +66,15 @@ func (oi metaObjectIdentifier) String() string { ...@@ -62,6 +66,15 @@ func (oi metaObjectIdentifier) String() string {
return string(oi) return string(oi)
} }
func (oi metaObjectIdentifier) Root() string {
str := string(oi)
if i := strings.Index(str, "."); i != -1 {
return str[:i]
} else {
return str
}
}
// NewSchemeManagerIdentifier converts the specified identifier to a SchemeManagerIdentifier. // NewSchemeManagerIdentifier converts the specified identifier to a SchemeManagerIdentifier.
func NewSchemeManagerIdentifier(id string) SchemeManagerIdentifier { func NewSchemeManagerIdentifier(id string) SchemeManagerIdentifier {
return SchemeManagerIdentifier{metaObjectIdentifier(id)} return SchemeManagerIdentifier{metaObjectIdentifier(id)}
......
...@@ -203,9 +203,15 @@ func (dr *IssuanceRequest) Identifiers() *IrmaIdentifierSet { ...@@ -203,9 +203,15 @@ func (dr *IssuanceRequest) Identifiers() *IrmaIdentifierSet {
for _, disjunction := range dr.Disclose { for _, disjunction := range dr.Disclose {
for _, attr := range disjunction.Attributes { for _, attr := range disjunction.Attributes {
dr.identifiers.SchemeManagers[attr.CredentialTypeIdentifier().IssuerIdentifier().SchemeManagerIdentifier()] = struct{}{} var cti CredentialTypeIdentifier
dr.identifiers.Issuers[attr.CredentialTypeIdentifier().IssuerIdentifier()] = struct{}{} if !attr.IsCredential() {
dr.identifiers.CredentialTypes[attr.CredentialTypeIdentifier()] = struct{}{} cti = attr.CredentialTypeIdentifier()
} else {
cti = NewCredentialTypeIdentifier(attr.String())
}
dr.identifiers.SchemeManagers[cti.IssuerIdentifier().SchemeManagerIdentifier()] = struct{}{}
dr.identifiers.Issuers[cti.IssuerIdentifier()] = struct{}{}
dr.identifiers.CredentialTypes[cti] = struct{}{}
} }
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment