Install SeisComP and scanloc ARM64 nightly packages
This commit is contained in:
@ -70,8 +70,8 @@ void encodeBase64(std::string& target, const Container& data) {
|
||||
translate_out;
|
||||
|
||||
std::copy(
|
||||
translate_out(BOOST_MAKE_PFTO_WRAPPER(static_cast<const typename Container::value_type*>(&data[0]))),
|
||||
translate_out(BOOST_MAKE_PFTO_WRAPPER(static_cast<const typename Container::value_type*>(&data[0] + data.size()))),
|
||||
translate_out(BOOST_MAKE_PFTO_WRAPPER(static_cast<const typename Container::value_type*>(data.data()))),
|
||||
translate_out(BOOST_MAKE_PFTO_WRAPPER(static_cast<const typename Container::value_type*>(data.data() + data.size()))),
|
||||
std::back_inserter(target)
|
||||
);
|
||||
}
|
||||
|
||||
@ -80,11 +80,11 @@ class SC_SYSTEM_CORE_API CertificateContext : public Core::BaseObject {
|
||||
* against the reference signature.
|
||||
* @param digest Address pointing to the digest
|
||||
* @param nDigest Number of digest bytes
|
||||
* @param signature OpenSSL ECDSA signature
|
||||
* @param sig OpenSSL ECDSA signature
|
||||
* @return A certficate or null
|
||||
*/
|
||||
const X509 *findCertificate(const char *digest, size_t nDigest,
|
||||
const ECDSA_SIG *signature) const;
|
||||
const unsigned char *sig, unsigned int siglen) const;
|
||||
|
||||
// /**
|
||||
// * @brief Checks if an certificate has been revoked
|
||||
@ -202,12 +202,12 @@ class SC_SYSTEM_CORE_API CertificateStore : public Core::BaseObject {
|
||||
*/
|
||||
bool validate(const char *authority, size_t len,
|
||||
const char *digest, size_t nDigest,
|
||||
const ECDSA_SIG *signature,
|
||||
const unsigned char *sig, unsigned int siglen,
|
||||
const X509 **matchedCertificate = 0);
|
||||
|
||||
bool validate(const std::string &authority,
|
||||
const char *digest, size_t nDigest,
|
||||
const ECDSA_SIG *signature,
|
||||
const unsigned char *sig, unsigned int siglen,
|
||||
const X509 **matchedCertificate = 0);
|
||||
|
||||
/**
|
||||
|
||||
@ -122,7 +122,7 @@ class SC_SYSTEM_CORE_API WildcardStringFirewall : public StringFirewall {
|
||||
* @param s The input string
|
||||
* @return true if it may pass, false otherwise
|
||||
*/
|
||||
virtual bool isAllowed(const std::string &s) const;
|
||||
virtual bool isAllowed(const std::string &s) const override;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@ -23,6 +23,9 @@
|
||||
|
||||
|
||||
#include <seiscomp/core.h>
|
||||
#include <seiscomp/core/strings.h>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
@ -90,12 +93,72 @@ class SC_SYSTEM_CORE_API UnitConverter {
|
||||
*/
|
||||
static const UnitConversion *get(const std::string &fromUnit);
|
||||
|
||||
/**
|
||||
* @brief Convertes a string to a numeric value in the requested unit.
|
||||
*
|
||||
* An example string is "1.23 km". If the requested unit is "m" then
|
||||
* 1230 will be returned. If the requested unit is "m" and the input
|
||||
* string is "1.23" then "1.23" will be returned.
|
||||
*
|
||||
* If the input cannot be converted, an exception is thrown.
|
||||
*
|
||||
* @param str The input string to be converted
|
||||
* @param unit The requested unit of the value
|
||||
* @return The value which will populated with the parsed value.
|
||||
*/
|
||||
template <typename T>
|
||||
static T parse(std::string_view str, const std::string &unit) {
|
||||
if ( str.empty() ) {
|
||||
throw std::invalid_argument("input string empty");
|
||||
}
|
||||
|
||||
auto outputConv = get(unit);
|
||||
if ( !outputConv ) {
|
||||
throw std::invalid_argument("invalid target unit");
|
||||
}
|
||||
|
||||
size_t p = str.size();
|
||||
while ( p > 0 ) {
|
||||
--p;
|
||||
|
||||
if ( (str[p] >= '0') && (str[p] <= '9') ) {
|
||||
// Found digit
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
++p;
|
||||
|
||||
T value;
|
||||
|
||||
if ( !Core::fromString(value, str.substr(0, p)) ) {
|
||||
throw std::invalid_argument("invalid value string");
|
||||
}
|
||||
|
||||
if ( p < str.size() ) {
|
||||
auto inputUnit = Core::trimFront(str.substr(p));
|
||||
auto inputConv = get(std::string(inputUnit));
|
||||
if ( !inputConv) {
|
||||
throw std::invalid_argument(Core::stringify("invalid input unit: '%s'", inputUnit));
|
||||
}
|
||||
|
||||
if ( inputConv->toUnit != outputConv->toUnit ) {
|
||||
// Incompatible units
|
||||
throw std::invalid_argument("units are not compatible");
|
||||
}
|
||||
|
||||
value = inputConv->convert(outputConv->revert(value));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Private members
|
||||
// ----------------------------------------------------------------------
|
||||
private:
|
||||
typedef std::map<std::string, UnitConversion> ConversionMap;
|
||||
using ConversionMap = std::map<std::string, UnitConversion>;
|
||||
static ConversionMap _conversionMap;
|
||||
};
|
||||
|
||||
|
||||
@ -23,10 +23,11 @@
|
||||
|
||||
|
||||
#include <seiscomp/core.h>
|
||||
|
||||
#include <seiscomp/core/enumeration.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <cinttypes>
|
||||
|
||||
|
||||
namespace Seiscomp {
|
||||
@ -38,20 +39,49 @@ namespace Util {
|
||||
*
|
||||
* The general layout of an URL is:
|
||||
* scheme://username:password@host:port/path?query#fragment
|
||||
*
|
||||
* There is no support for the generic form:
|
||||
* scheme:<scheme-specific-part>
|
||||
*
|
||||
* The scheme must be separated from the scheme specific part
|
||||
* with "://".
|
||||
*/
|
||||
class SC_SYSTEM_CORE_API Url {
|
||||
// ----------------------------------------------------------------------
|
||||
// Public types
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
typedef std::map<std::string, std::string> QueryItems;
|
||||
using QueryItems = std::map<std::string, std::string>;
|
||||
|
||||
MAKEENUM(
|
||||
Status,
|
||||
EVALUES(
|
||||
STATUS_OK,
|
||||
STATUS_EMPTY,
|
||||
STATUS_SCHEME_ERROR,
|
||||
STATUS_EMPTY_USER_INFO,
|
||||
STATUS_EMPTY_USERNAME,
|
||||
STATUS_INVALID_HOST,
|
||||
STATUS_PORT_IS_NO_NUMBER,
|
||||
STATUS_PORT_OUT_OF_RANGE
|
||||
),
|
||||
ENAMES(
|
||||
"OK",
|
||||
"URL is empty",
|
||||
"Scheme is required",
|
||||
"Empty user info not allowed",
|
||||
"Empty username not allowed",
|
||||
"Invalid host",
|
||||
"Expected port as number",
|
||||
"Port out of range"
|
||||
)
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// X'truction
|
||||
// ----------------------------------------------------------------------
|
||||
public:
|
||||
Url(const std::string &url = std::string());
|
||||
Url(const std::string &url = {});
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@ -62,27 +92,99 @@ class SC_SYSTEM_CORE_API Url {
|
||||
/**
|
||||
* @brief Sets a URL from string and decomposes it into its parts.
|
||||
* @param url The URL string
|
||||
* @return true if the URL could be parsed, false in case of an
|
||||
* @return true if the URL could be parsed, false in case of any
|
||||
* invalid URL.
|
||||
*/
|
||||
bool setUrl(const std::string &url);
|
||||
|
||||
/**
|
||||
* @brief Returns the URL scheme
|
||||
* @return The URL scheme
|
||||
*/
|
||||
const std::string &scheme() const;
|
||||
|
||||
/**
|
||||
* @brief Returns the authoriry part of the URL
|
||||
* @return The authority
|
||||
*/
|
||||
const std::string &authority() const;
|
||||
|
||||
/**
|
||||
* @brief Returns the username as extracted from the user info
|
||||
* @return The username
|
||||
*/
|
||||
const std::string &username() const;
|
||||
|
||||
/**
|
||||
* @brief Returns the password as extracted from the user info
|
||||
* @return The password
|
||||
*/
|
||||
const std::string &password() const;
|
||||
|
||||
/**
|
||||
* @brief Returns the host from the authority part
|
||||
* @return The host, IP or host name
|
||||
*/
|
||||
const std::string &host() const;
|
||||
size_t port() const;
|
||||
|
||||
/**
|
||||
* @brief Returns the optional port from authority part.
|
||||
* @return Returns the port
|
||||
*/
|
||||
OPT(uint16_t) port() const;
|
||||
|
||||
/**
|
||||
* @brief Returns the path of the URL. If the scheme and authority are
|
||||
* not set the path can be interpreted as file location
|
||||
* @return The path
|
||||
*/
|
||||
const std::string &path() const;
|
||||
|
||||
/**
|
||||
* @brief Returns the query string
|
||||
* @return The query string
|
||||
*/
|
||||
const std::string &query() const;
|
||||
|
||||
bool hasQuery() const;
|
||||
/**
|
||||
* @brief Checks if a specific query parameter is set
|
||||
* @return True if the parameter is set
|
||||
*/
|
||||
bool hasQueryItem (const std::string&) const;
|
||||
|
||||
/**
|
||||
* @brief Returns the value of a specific query parameter
|
||||
* @return The value
|
||||
*/
|
||||
std::string queryItemValue(const std::string&) const;
|
||||
|
||||
/**
|
||||
* @brief Returns a reference to a query item map
|
||||
* @return Reference to query item map
|
||||
*/
|
||||
const QueryItems &queryItems() const;
|
||||
|
||||
/**
|
||||
* @brief Returns the fragement part of the URL
|
||||
* @return The fragment
|
||||
*/
|
||||
const std::string &fragment() const;
|
||||
|
||||
/**
|
||||
* @brief Checks if the URL is valid
|
||||
* @return True is the URL is not empty and valid.
|
||||
*/
|
||||
bool isValid() const;
|
||||
|
||||
/**
|
||||
* @brief Returns the status of the URL
|
||||
* @return The status
|
||||
*/
|
||||
Status status() const;
|
||||
|
||||
/**
|
||||
* @brief Print parsed URL components
|
||||
*/
|
||||
void debug() const;
|
||||
|
||||
/**
|
||||
@ -92,6 +194,24 @@ class SC_SYSTEM_CORE_API Url {
|
||||
*/
|
||||
std::string withoutScheme() const;
|
||||
|
||||
/**
|
||||
* @brief Encodes STL string as defined in RFC 3986:
|
||||
* RFC 3986 section 2.2 Reserved Characters (January 2005) and
|
||||
* RFC 3986 section 2.3 Unreserved Characters (January 2005)
|
||||
* @param s STL string
|
||||
* @return Encoded STL string
|
||||
*/
|
||||
static std::string Encoded(const std::string &s);
|
||||
|
||||
/**
|
||||
* @brief Encodes C string based as defined in RFC 3986:
|
||||
* RFC 3986 section 2.2 Reserved Characters (January 2005) and
|
||||
* RFC 3986 section 2.3 Unreserved Characters (January 2005)
|
||||
* @param s C string
|
||||
* @return Encoded STL string
|
||||
*/
|
||||
static std::string Encoded(const char *s, int len);
|
||||
|
||||
/**
|
||||
* @brief Decodes STL string based as defined in RFC 3986:
|
||||
* RFC 3986 section 2.2 Reserved Characters (January 2005) and
|
||||
@ -101,6 +221,15 @@ class SC_SYSTEM_CORE_API Url {
|
||||
*/
|
||||
static std::string Decoded(const std::string &s);
|
||||
|
||||
/**
|
||||
* @brief Decodes C string based as defined in RFC 3986 defined:
|
||||
* RFC 3986 section 2.2 Reserved Characters (January 2005) and
|
||||
* RFC 3986 section 2.3 Unreserved Characters (January 2005)
|
||||
* @param s C string
|
||||
* @return Encoded STL string
|
||||
*/
|
||||
static std::string Decoded(const char *s, int len);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Operators
|
||||
@ -112,29 +241,77 @@ class SC_SYSTEM_CORE_API Url {
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Private methods
|
||||
// Protected methods
|
||||
// ----------------------------------------------------------------------
|
||||
private:
|
||||
bool parse(const std::string&);
|
||||
std::string subString(const std::string&, size_t&, const std::string& = "",
|
||||
bool required = false);
|
||||
protected:
|
||||
/**
|
||||
* @brief Resets all URL components
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* @brief Parses URL from string. Components and sub components are
|
||||
* parsed and separated before those are decoded.
|
||||
* @param url The URL
|
||||
* @param implyAuthority Whether to imply an authority if no scheme is
|
||||
* given.
|
||||
* @return Status code
|
||||
*/
|
||||
Status parse(const std::string &url, bool implyAuthority);
|
||||
|
||||
/**
|
||||
* @brief Parses scheme from URL
|
||||
* @param url The URL
|
||||
* @return Status code
|
||||
*/
|
||||
Status parseScheme(const std::string &url);
|
||||
|
||||
/**
|
||||
* @brief Parses authority from URL
|
||||
* @param The URL
|
||||
* @return Status code
|
||||
*/
|
||||
Status parseAuthority(const std::string &url);
|
||||
|
||||
/**
|
||||
* @brief Parses path from URL
|
||||
* @param The URL
|
||||
* @return Status code
|
||||
*/
|
||||
Status parsePath(const std::string &url);
|
||||
|
||||
/**
|
||||
* @brief Parses query from the URL and builds key/value param lookup
|
||||
* @param url The URL
|
||||
* @return Status code
|
||||
*/
|
||||
Status parseQuery(const std::string &url);
|
||||
|
||||
/**
|
||||
* @brief Loads scheme specific default values, e.g., for HTTP port 80
|
||||
*/
|
||||
void setSchemeDefaults();
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Private members
|
||||
// ----------------------------------------------------------------------
|
||||
private:
|
||||
protected:
|
||||
std::string _url;
|
||||
std::string _scheme;
|
||||
std::string _username;
|
||||
std::string _authority;
|
||||
std::string _user;
|
||||
std::string _password;
|
||||
std::string _host;
|
||||
size_t _port;
|
||||
OPT(uint16_t) _port;
|
||||
std::string _path;
|
||||
std::string _query;
|
||||
std::string _fragment;
|
||||
QueryItems _queryItems;
|
||||
bool _isValid;
|
||||
bool _isValid{false};
|
||||
std::string _errorString;
|
||||
size_t _currentPos{0};
|
||||
Status _status{STATUS_EMPTY};
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user