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) {
}
func (attr *MetadataAttribute) setExpiryDate(timestamp *Timestamp) error {
if timestamp == nil {
return nil
}
expiry := time.Time(*timestamp).Unix()
signing := attr.SigningDate().Unix()
attr.setValidityDuration(int((expiry - signing) / ExpiryFactor))
......
......@@ -48,7 +48,11 @@ type IrmaIdentifierSet struct {
// Parent returns the parent object of this identifier.
func (oi metaObjectIdentifier) Parent() string {
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.
......@@ -62,6 +66,15 @@ func (oi metaObjectIdentifier) String() string {
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.
func NewSchemeManagerIdentifier(id string) SchemeManagerIdentifier {
return SchemeManagerIdentifier{metaObjectIdentifier(id)}
......
......@@ -203,9 +203,15 @@ func (dr *IssuanceRequest) Identifiers() *IrmaIdentifierSet {
for _, disjunction := range dr.Disclose {
for _, attr := range disjunction.Attributes {
dr.identifiers.SchemeManagers[attr.CredentialTypeIdentifier().IssuerIdentifier().SchemeManagerIdentifier()] = struct{}{}
dr.identifiers.Issuers[attr.CredentialTypeIdentifier().IssuerIdentifier()] = struct{}{}
dr.identifiers.CredentialTypes[attr.CredentialTypeIdentifier()] = struct{}{}
var cti CredentialTypeIdentifier
if !attr.IsCredential() {
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{}{}
}
}
}
......
Markdown is supported
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