public ProfileLocator getDefaultProfile(RequestContext context, String locatorName) throws ProfilerException { // find a profiling rule for the default principal ProfilingRule rule = getRuleForPrincipal(DEFAULT_RULE_PRINCIPAL, locatorName); if (null == rule) { log.warn("Could not find profiling rule for principal: " + DEFAULT_RULE_PRINCIPAL); rule = this.getDefaultRule(); } if (null == rule) { String msg = "Couldn't find any profiling rules including default rule for principal " + DEFAULT_RULE_PRINCIPAL; log.error(msg); throw new ProfilerException(msg); } // create a profile locator for given rule return rule.apply(context, this); }
String msg = "Invalid (null) Subject in request pipeline"; log.error(msg); throw new ProfilerException(msg); String msg = "Could not find a principle for subject in request pipeline"; log.error(msg); throw new ProfilerException(msg); + principal; log.error(msg); throw new ProfilerException(msg);
/** * Setup and maintain profiler context to be used to reap rule caches * for principals on session end. * * @param context request context * @throws ProfilerException when subject or principal not available */ private void setupProfilerContext(RequestContext context) throws ProfilerException { // validate profiler context ProfilerContext profilerContext = (ProfilerContext) context.getSessionAttribute(PROFILER_CONTEXT_ATTRIBUTE_NAME); try { // access session principal and test for change Principal principal = SubjectHelper.getBestPrincipal(context.getSubject(), UserSubjectPrincipal.class); if (principal == null) { throw new NullPointerException("Principal not found"); } if ((profilerContext == null) || (profilerContext.getPrincipal() != principal)) { // setup/reset profiler context context.setSessionAttribute(PROFILER_CONTEXT_ATTRIBUTE_NAME, new ProfilerContext(this, principal)); } } catch (Exception e) { String message = "Unable to access principal in pipeline: " + e; log.error(message, e); throw new ProfilerException(message, e); } }
if (requestSubject == null) throw new ProfilerException("Missing subject for request: " + requestPath); throw new ProfilerException("Missing principal for request: " + requestPath);
throw new ProfilerException("Missing user principal for request: " + request.getPath()); throw new ProfilerException("Cannot retrieve user for " + userPrincipal.getName());