/** * Returns an authorization context for a given user. * * @return authorization context. */ protected AuthorizationContext getAuthorizationContextForSubject(String subject) { if (subject.equals(SystemUserService.SELF_LINK)) { return getSystemAuthorizationContext(); } else if (subject.equals(GuestUserService.SELF_LINK)) { return getGuestAuthorizationContext(); } return this.authorizationFilter.createAuthorizationContext(getTokenSigner(),subject); }
/** * Returns the system user's authorization context. */ @Override public final AuthorizationContext getSystemAuthorizationContext() { if (getHost().isPrivilegedService(this)) { return getHost().getSystemAuthorizationContext(); } else { throw new RuntimeException("Service not allowed to get system authorization context"); } }
/** * Returns the system user's authorization context. */ @Override public final AuthorizationContext getSystemAuthorizationContext() { if (getHost().isPrivilegedService(this)) { return getHost().getSystemAuthorizationContext(); } else { throw new RuntimeException("Service not allowed to get system authorization context"); } }
OperationContext.setAuthorizationContext(this.getSystemAuthorizationContext()); startPost.setCompletion(h); startPost.setAuthorizationContext(this.getSystemAuthorizationContext()); sb.append(startPost.getUri().toString()).append(Operation.CR_LF); log(Level.FINE, "starting %s", startPost.getUri());
}; setAuthorizationContext(getSystemAuthorizationContext());
@RouteDocumentation(description = "Read the service document") public void handleGet(Operation get) { if (!hasPendingTransactions()) { handleGetSimple(get); return; } handleGetWithinTransaction(this, get, this::handleGetSimple, this::failRequest, getHost().getSystemAuthorizationContext()); }
void scheduleServiceOptionToggleMaintenance(String path, EnumSet<ServiceOption> newOptions, EnumSet<ServiceOption> removedOptions) { Service s = findService(path); if (s == null || s.getProcessingStage() == ProcessingStage.STOPPED) { return; } ServiceMaintenanceRequest body = ServiceMaintenanceRequest.create(); body.reasons.add(MaintenanceReason.SERVICE_OPTION_TOGGLE); if (newOptions != null && newOptions.contains(ServiceOption.DOCUMENT_OWNER)) { body.reasons.add(MaintenanceReason.NODE_GROUP_CHANGE); s.adjustStat(Service.STAT_NAME_DOCUMENT_OWNER_TOGGLE_ON_MAINT_COUNT, 1); } if (removedOptions != null && removedOptions.contains(ServiceOption.DOCUMENT_OWNER)) { body.reasons.add(MaintenanceReason.NODE_GROUP_CHANGE); s.adjustStat(Service.STAT_NAME_DOCUMENT_OWNER_TOGGLE_OFF_MAINT_COUNT, 1); } if (body.reasons.contains(MaintenanceReason.NODE_GROUP_CHANGE)) { s.adjustStat(Service.STAT_NAME_NODE_GROUP_CHANGE_MAINTENANCE_COUNT, 1); } body.configUpdate = new ServiceConfigUpdateRequest(); body.configUpdate.addOptions = newOptions; body.configUpdate.removeOptions = removedOptions; run(() -> { OperationContext.setAuthorizationContext(getSystemAuthorizationContext()); s.handleMaintenance(Operation.createPost(s.getUri()).setBody(body)); }); }
.setBody(serviceState) .setReferer(getUri()); post.setAuthorizationContext(getSystemAuthorizationContext()); sendRequest(post);
private void sendJoinPeerRequest(JoinPeerRequest joinBody, URI localNodeGroupUri) { Operation peerRequestOp = Operation .createPost(localNodeGroupUri) .setReferer(UriUtils.buildUri(this, "")) .setBody(joinBody) .setCompletion((o, e) -> { if (e == null) { return; } if (e != null) { log(Level.WARNING, "Failure from local node group for join to: %s: %s", joinBody.memberGroupReference, e.toString()); } }); peerRequestOp.setAuthorizationContext(getSystemAuthorizationContext()); sendRequest(peerRequestOp); }
.setBody(state) .setReferer(getUri()) .setAuthorizationContext(getSystemAuthorizationContext()) .setCompletion(h); sendRequest(post);
private void scheduleNodeGroupChangeMaintenance(String nodeSelectorPath, Operation op) { OperationContext.setAuthorizationContext(this.host.getSystemAuthorizationContext()); if (nodeSelectorPath == null) { throw new IllegalArgumentException("nodeGroupPath is required");
/** * Initiates host periodic maintenance cycle */ private void scheduleMaintenance() { Runnable r = () -> { OperationContext.setAuthorizationContext(this.getSystemAuthorizationContext()); this.state.lastMaintenanceTimeUtcMicros = Utils.getSystemNowMicrosUtc(); long deadline = this.state.lastMaintenanceTimeUtcMicros + this.state.maintenanceIntervalMicros; performMaintenanceStage(Operation.createPost(getUri()), MaintenanceStage.UTILS, deadline); }; long intervalMicros = getMaintenanceCheckIntervalMicros(); this.maintenanceTask = scheduleCore(r, intervalMicros, TimeUnit.MICROSECONDS); }
Operation post = Operation .createPost(UriUtils.buildUri(this, selfLink)) .setAuthorizationContext(this.getSystemAuthorizationContext()); this.startService(post, new DirectoryContentService(rootDir));
.run(() -> { OperationContext.setAuthorizationContext(this.host .getSystemAuthorizationContext()); this.host.log(Level.FINE, " Synchronizing %s (last:%d, sl: %d now:%d)", link,
OperationContext.setAuthorizationContext(getSystemAuthorizationContext());
getUserOp.setAuthorizationContext(host.getSystemAuthorizationContext()); host.sendRequest(getUserOp); verifyOp.setAuthorizationContext(host.getSystemAuthorizationContext()); host.sendRequest(verifyOp);
Operation post = Operation .createPost(subscriptionUri) .setAuthorizationContext(this.getSystemAuthorizationContext()) .setCompletion((o, e) -> { if (e != null) {
try { OperationContext.setAuthorizationContext(this.host .getSystemAuthorizationContext()); if (s.hasOption(Service.ServiceOption.INSTRUMENTATION)) { s.adjustStat(Service.STAT_NAME_MAINTENANCE_COUNT, 1);
onDemandPost.setAuthorizationContext(host.getSystemAuthorizationContext());
request, getHost().getSystemAuthorizationContext())) { return;