public void maySetSAuthVersion(HttpRequest request) { if (request.hasNotHeader(Header.SAuth.Value.Authorization)) request.setHeader(Header.SAuth.Value.Authorization); if (request.hasNotHeader(Header.SAuth.Value.Version)) request.setHeader(Header.SAuth.Value.Version); }
public java.lang.String getSAuthNonce(HttpRequest request) { return request.getHeaderString(Header.SAuth.Nonce); }
public alto.lang.Header getSAuthVersionHeader(HttpRequest request) { return request.getHeader(Header.SAuth.Version); }
public void setSAuthSignature(HttpRequest request, long folded) { java.lang.String value = alto.io.u.Hex.encode(folded); request.setHeader(Header.SAuth.Signature, value); }
public long getSAuthSignatureLong(HttpRequest request) { java.math.BigInteger bint = request.getHeaderHex(Header.SAuth.Signature); if (null != bint) return bint.longValue(); else return 0L; }
public alto.lang.Header getSAuthSignatureHeader(HttpRequest request) { return request.getHeader(Header.SAuth.Signature); }
public void setSAuthNonce(HttpRequest request, java.lang.String value) { request.setHeader(Header.SAuth.Nonce, value); }
public void setSAuthNonce(HttpRequest request) { request.setHeader(Header.SAuth.Nonce, alto.io.u.Prng.RandLongStringHex()); }
public java.lang.String validateSAuthUIDHeaderString(HttpRequest request) { return request.validateHeaderString(Header.SAuth.UID); }
public alto.lang.Header getSAuthUIDHeader(HttpRequest request) { return request.getHeader(Header.SAuth.UID); }
public boolean hasNotSAuthUID(HttpRequest request) { return (request.hasNotHeader(Header.SAuth.UID)); }
public java.lang.String validateSAuthVersionHeaderString(HttpRequest request) { java.lang.String re = request.validateHeaderString(Header.SAuth.Version); if (null != re && re.equals(Header.SAuth.Value.Version.toString())) { return re; } else throw new alto.sys.BadRequestException(re); }
public java.lang.String getSAuthVersion(HttpRequest request) { return request.getHeaderString(Header.SAuth.Version); }
public java.lang.String getSAuthNonceHeaderString(HttpRequest request) { alto.lang.Header header = request.getHeader(Header.SAuth.Nonce); if (null != header) return header.toString(); else return null; }
public java.lang.String getSAuthUID(HttpRequest request) { return request.getHeaderString(Header.SAuth.UID); }
public java.lang.String validateSAuthNonceHeaderString(HttpRequest request) { java.lang.String re = request.validateHeaderString(Header.SAuth.Nonce); java.math.BigInteger value = request.getHeaderHex(Header.SAuth.Nonce); if (null != value && 14 < value.bitLength()) return re; else throw new alto.sys.BadRequestException(re); }
public void setSAuthUID(HttpRequest request, java.lang.String value) { request.setHeader(Header.SAuth.UID, value); }
public void maySetSAuthNonce(HttpRequest request) { if (request.hasNotHeader(Header.SAuth.Nonce)) request.setHeader(Header.SAuth.Nonce, alto.io.u.Prng.RandLongStringHex()); }
public void maySetSAuthUID(HttpRequest request, java.lang.String uid) { java.lang.String value = this.getSAuthUID(request); if (null == value || (!value.equals(uid))) request.setHeader(Header.SAuth.UID, uid); }
public boolean hasNotSAuthSignature(HttpRequest request) { return (request.hasNotHeader(Header.SAuth.Signature)); }
public void setSAuthUID(HttpRequest request, Principal principal) { request.setHeader(Header.SAuth.UID, principal.getName()); }
public java.lang.String getSAuthSignature(HttpRequest request) { return request.getHeaderString(Header.SAuth.Signature); }
public boolean hasNotSAuthNonce(HttpRequest request) { return (request.hasNotHeader(Header.SAuth.Nonce)); }
public void setSAuthSignature(HttpRequest request, java.lang.String value) { request.setHeader(Header.SAuth.Signature, value); }
public alto.lang.Header getSAuthNonceHeader(HttpRequest request) { return request.getHeader(Header.SAuth.Nonce); }
public boolean sign(Principal.Authentic keys, HttpRequest request) { if (null != keys) { RSA rsa = new RSA(keys); request.maySetDate(); request.maySetHost(); request.setContentMD5(); this.setSAuthVersion(request); this.setSAuthUID(request, keys.getUID()); this.setSAuthNonce(request); java.lang.String requestline = request.validateMethod() + ' ' + request.validatePathComplete(); java.lang.String headerHost = request.validateHostHeaderString(); java.lang.String headerDate = request.validateDateHeaderString(); java.lang.String headerSAuthVersion = this.validateSAuthVersionHeaderString(request); java.lang.String headerSAuthUID = this.validateSAuthUIDHeaderString(request); java.lang.String headerSAuthNonce = this.validateSAuthNonceHeaderString(request); java.lang.String headerContentType = null; java.lang.String headerContentLength = null; java.lang.String headerContentEncoding = null; java.lang.String headerContentRange = null; java.lang.String headerContentLocation = null; java.lang.String headerETag = null; java.lang.String headerLastModified = null; java.lang.String headerExpires = null; java.lang.String headerContentMD5 = null; SHA1 sha = new SHA1(); sha.update(requestline); sha.update(headerHost); sha.update(headerDate); if (request.isContentLengthPositive()) { headerContentType = request.getContentTypeHeaderString(); sha.update(headerContentType); headerContentLength = request.validateContentLengthHeaderString(); sha.update(headerContentLength); headerContentEncoding = request.getContentEncodingHeaderString(); sha.update(headerContentEncoding); headerContentRange = request.getContentRangeHeaderString(); sha.update(headerContentRange); headerContentLocation = request.getContentLocationHeaderString(); sha.update(headerContentLocation); headerETag = request.getETagHeaderString(); sha.update(headerETag); headerLastModified = request.getLastModifiedHeaderString(); sha.update(headerLastModified); headerExpires = request.getExpiresHeaderString(); sha.update(headerExpires); headerContentMD5 = request.validateContentMD5HeaderString(); // (verifyContentMD5) sha.update(headerContentMD5); } sha.update(headerSAuthVersion); sha.update(headerSAuthUID); sha.update(headerSAuthNonce); long signature = Function.Xor.Hash64(rsa.sign(sha)); this.setSAuthSignature(request, signature); return true; } else throw new alto.sys.Error.Argument(); }
public boolean hasNotSAuthVersion(HttpRequest request) { return (request.hasNotHeader(Header.SAuth.Version)); }