use of org.hl7.fhir.r4b.model.Signature in project dpc-app by CMSgov.
the class KeyUpload method run.
@Override
public void run(Bootstrap<?> bootstrap, Namespace namespace) throws Exception {
final IdType orgID = new IdType(namespace.getString("org-reference"));
final String apiService = namespace.getString(API_HOSTNAME);
System.out.println(String.format("Connecting to API service at: %s", apiService));
// Read the file and parse it
final Path keyFilePath = FileSystems.getDefault().getPath(namespace.getString(KEY_FILE));
final String publicKey = Files.readString(keyFilePath);
final Path signaturePath = FileSystems.getDefault().getPath(namespace.getString(SIGNATURE_FILE));
final String signature = Files.readString(signaturePath);
KeyResource.KeySignature keySignature = new KeyResource.KeySignature(publicKey, signature);
final Optional<String> label = Optional.ofNullable(namespace.getString("key-label"));
uploadKey(apiService, orgID.getIdPart(), label, keySignature);
}
use of org.hl7.fhir.r4b.model.Signature in project clinical_quality_language by cqframework.
the class ElmRequirementsContext method reportFunctionRef.
public void reportFunctionRef(FunctionRef functionRef) {
CompiledLibrary targetLibrary = prepareLibraryVisit(getCurrentLibraryIdentifier(), functionRef.getLibraryName());
try {
List<DataType> signature;
signature = new ArrayList<DataType>();
for (TypeSpecifier ts : functionRef.getSignature()) {
signature.add(typeResolver.resolveTypeSpecifier(ts));
}
// Signature sizes will only be different in the case that the signature is not present in the ELM, so needs to be constructed
if (signature.size() != functionRef.getOperand().size()) {
for (Expression e : functionRef.getOperand()) {
if (e.getResultType() != null) {
signature.add(e.getResultType());
} else if (e.getResultTypeName() != null) {
signature.add(typeResolver.resolveTypeName(e.getResultTypeName()));
} else if (e.getResultTypeSpecifier() != null) {
signature.add(typeResolver.resolveTypeSpecifier(e.getResultTypeSpecifier()));
} else {
// Signature could not be constructed, fall back to reporting all function defs
signature = null;
break;
}
}
}
Iterable<FunctionDef> fds = targetLibrary.resolveFunctionRef(functionRef.getName(), signature);
for (FunctionDef fd : fds) {
if (!visited.contains(fd)) {
visitor.visitElement(fd, this);
}
}
} finally {
unprepareLibraryVisit(functionRef.getLibraryName());
}
}
use of org.hl7.fhir.r4b.model.Signature in project clinical_quality_language by cqframework.
the class GenericOperator method instantiate.
public InstantiationResult instantiate(Signature callSignature, Map<TypeParameter, DataType> parameters, OperatorMap operatorMap, ConversionMap conversionMap, boolean allowPromotionAndDemotion) {
Map<TypeParameter, DataType> typeMap = new HashMap<>();
for (TypeParameter p : typeParameters) {
typeMap.put(p, null);
}
if (parameters != null) {
for (Map.Entry<TypeParameter, DataType> entry : parameters.entrySet()) {
typeMap.put(entry.getKey(), entry.getValue());
}
}
InstantiationContextImpl context = new InstantiationContextImpl(typeMap, operatorMap, conversionMap, allowPromotionAndDemotion);
Boolean instantiable = getSignature().isInstantiable(callSignature, context);
if (instantiable) {
Operator result = new Operator(getName(), getSignature().instantiate(context), getResultType().instantiate(context));
result.setAccessLevel(getAccessLevel());
result.setLibraryName(getLibraryName());
return new InstantiationResult(this, result, context.getConversionScore());
}
return new InstantiationResult(this, null, context.getConversionScore());
}
use of org.hl7.fhir.r4b.model.Signature in project clinical_quality_language by cqframework.
the class OperatorEntry method expandChoices.
public List<Signature> expandChoices(Signature callSignature) {
ArrayList<Signature> signatures = new ArrayList<Signature>();
if (callSignature.containsChoices()) {
ArrayList<ArrayList<DataType>> operandList = new ArrayList<ArrayList<DataType>>();
for (DataType operand : callSignature.getOperandTypes()) {
ArrayList<DataType> list = new ArrayList<DataType>();
if (operand instanceof ChoiceType) {
for (DataType type : ((ChoiceType) operand).getTypes()) {
list.add(type);
}
} else {
list.add(operand);
}
operandList.add(list);
}
DataType[] result = new DataType[callSignature.getSize()];
collectSignatures(operandList, result, 0, signatures);
} else {
signatures.add(callSignature);
}
return signatures;
}
use of org.hl7.fhir.r4b.model.Signature in project drug-formulary-ri by HL7-DaVinci.
the class PatientAuthorizationInterceptor method buildRuleList.
@Override
public List<IAuthRule> buildRuleList(RequestDetails theRequestDetails) {
String authHeader = theRequestDetails.getHeader("Authorization");
if (authHeader != null) {
// Retrieve the JWT token from the Authorization header
Pattern pattern = Pattern.compile("Bearer (.*)");
Matcher matcher = pattern.matcher(authHeader);
if (matcher.find() && matcher.groupCount() == 1) {
String token = matcher.group(1);
logger.fine("AuthorizationInterceptor::Token retrieved is " + token);
String adminToken = HapiProperties.getAdminToken();
if (adminToken != null && token.equals(adminToken)) {
logger.info("AuthorizationInterceptor::JWT token is admin token");
return adminAuthorizedRule();
}
try {
IIdType patientId = verify(token, theRequestDetails.getFhirServerBase());
if (patientId != null)
return authorizedRule(patientId);
} catch (SignatureVerificationException e) {
String msg = "Authorization failed: invalid signature";
throw new AuthenticationException(msg, e.getCause());
} catch (TokenExpiredException e) {
String msg = "Authorization failed: access token expired";
throw new AuthenticationException(msg, e.getCause());
} catch (Exception e) {
throw new AuthenticationException(e.getMessage(), e.getCause());
}
} else {
throw new AuthenticationException("Authorization header is not in the form 'Bearer <token>'");
}
}
return unauthorizedRule();
}
Aggregations