All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ew.levr.db.skyrepo.5.15.1.source-code.skyrepo.crypto.rs2 Maven / Gradle / Ivy

There is a newer version: 5.16.4
Show newest version
// Copyright 2015-2016 Eduworks Corporation and other contributing parties.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

owner=#add(_string="true",a="@",b="owner");
#owner=owner;

context=#add(_string="true",a="@",b="context");
#context=context;

type=#add(_string="true",a="@",b="type");
#type=type;

reader=#add(_string="true",a="@",b="reader");
#reader=reader;

id=#add(_string="true",a="@",b="id");
#id=id;

signatureParam=#add(_string="true",a="@",b="signature");
#signature=signatureParam;

signatureArr=#toObject(obj="@signatureArr");
context=signatureArr.getByParam(param=context);
type=signatureArr.getByParam(param=type);
type=#if(
	operator=type.has(has="http"),
	operand="true",
	eq=type,
	ne=#if(
		operator=context.endsWith(with="/"),
		operand="true",
		eq=context.add(z=type),
		ne=context.add(y="/",z=type)
	)
);
owner=signatureArr.getByParam(param=owner);
expiry=signatureArr.cget(expiry="");
signature=signatureArr.getByParam(param=signatureParam);

owner = owner.replace(
	regex="true",
	replace="\r?\n",
	with=""
);

signatureSheet=#object(
	a=#fileFromDatastream(name="signatureSheet").fileToString().toArray(),
	b=#headers().get(signatureSheet="").toArray(),
	c=#headers().get(signaturesheet="").toArray()
).valueSet().union();

verifySignature=#object(
	a=#if(
		operator=type,
		operand="http://schema.cassproject.org/kbac/0.2/TimeLimitedSignature",
		ne=#error(code="422",msg="Invalid Signature Version.")
	),
	aa=#if(
		operator=type,
		operand="",
		eq=#error(code="422",msg="Missing Signature Version.")
	),
	b=#if(
		operator=expiry,
		operand=#date(_raw="true"),
		lt=#error(
			code="419",
			msg=#add(
				_string="true",
				a="A Signature is Expired. My time is ",
				b=#date(_raw="true").toString(),
				c=" and the signature expires at ",
				d=expiry
			).toString()
		)
	),
	bb=#if(
		operator=expiry,
		operand="",
		eq=#error(code="422",msg="Missing expiry date.")
	),
	c=#if(
		operator=signature.rsaVerify(
			pk=owner,
			against=signatureArr.removeByParam(param=signatureParam)
		),
		operand="true",
		ne=#error(code="451",msg=#add(a="Invalid Signature Detected: ",b=signature))
	),
	cc=#if(
		operator=signature,
		operand="",
		eq=#error(code="496",msg="Missing Signature.")	
	),
	z=owner
).cget(z="");

signatureSheet=signatureSheet.cforEach(paramName="signatureArr",threaded="false",array="true",rethrow="true",op=verifySignature).cache(name=#add(a="signatureSheet",b=signatureSheet.toString()));
#signatureSheet=signatureSheet;




© 2015 - 2024 Weber Informatics LLC | Privacy Policy