signature: Rewrite signature handling and move it into a library.

This commit is contained in:
Harshavardhana
2016-02-15 17:42:39 -08:00
parent b531bb31bb
commit 5a9333a67b
30 changed files with 1193 additions and 1215 deletions

View File

@@ -306,7 +306,7 @@ func (b bucket) WriteObject(objectName string, objectData io.Reader, size int64,
//
// Signature mismatch occurred all temp files to be removed and all data purged.
CleanupWritersOnError(writers)
return ObjectMetadata{}, probe.NewError(signV4.SigDoesNotMatch{})
return ObjectMetadata{}, probe.NewError(SignDoesNotMatch{})
}
}
objMetadata.MD5Sum = hex.EncodeToString(dataMD5sum)

View File

@@ -18,6 +18,13 @@ package xl
import "fmt"
// SignDoesNotMatch - signature does not match.
type SignDoesNotMatch struct{}
func (e SignDoesNotMatch) Error() string {
return "Signature does not match."
}
// InvalidArgument invalid argument
type InvalidArgument struct{}

View File

@@ -226,7 +226,7 @@ func (xl API) createObjectPart(bucket, key, uploadID string, partID int, content
return "", err.Trace()
}
if !ok {
return "", probe.NewError(signV4.SigDoesNotMatch{})
return "", probe.NewError(SignDoesNotMatch{})
}
}
}
@@ -342,7 +342,7 @@ func (xl API) completeMultipartUploadV2(bucket, key, uploadID string, data io.Re
return nil, err.Trace()
}
if !ok {
return nil, probe.NewError(signV4.SigDoesNotMatch{})
return nil, probe.NewError(SignDoesNotMatch{})
}
}
parts := &CompleteMultipartUpload{}

View File

@@ -376,7 +376,7 @@ func (xl API) completeMultipartUpload(bucket, object, uploadID string, data io.R
return ObjectMetadata{}, err.Trace()
}
if !ok {
return ObjectMetadata{}, probe.NewError(signV4.SigDoesNotMatch{})
return ObjectMetadata{}, probe.NewError(SignDoesNotMatch{})
}
}
parts := &CompleteMultipartUpload{}

View File

@@ -392,7 +392,7 @@ func (xl API) createObject(bucket, key, contentType, expectedMD5Sum string, size
if !ok {
// Delete perhaps the object is already saved, due to the nature of append()
xl.objects.Delete(objectKey)
return ObjectMetadata{}, probe.NewError(signV4.SigDoesNotMatch{})
return ObjectMetadata{}, probe.NewError(SignDoesNotMatch{})
}
}
@@ -435,7 +435,7 @@ func (xl API) MakeBucket(bucketName, acl string, location io.Reader, signature *
return err.Trace()
}
if !ok {
return probe.NewError(signV4.SigDoesNotMatch{})
return probe.NewError(SignDoesNotMatch{})
}
}