/** * Returns the list of product tokens from the user agent name. * * @return The list of product tokens from the user agent name. * @see #getAgent() */ public List<Product> getAgentProducts() { if (this.agentProducts == null) { this.agentProducts = org.restlet.engine.header.ProductReader .read(getAgent()); } return this.agentProducts; }
clientInfo.setAgent(rci.getAgent());
/** * Returns the list of product tokens from the user agent name. * * @return The list of product tokens from the user agent name. */ public List<Product> getAgentProducts() { if (this.agentProducts == null) { this.agentProducts = Engine.getInstance() .parseUserAgent(getAgent()); } return this.agentProducts; }
/** * A beforeHandle will simply embed in request attributes a Nexus interface implemntor, depending on key used to * name it. */ protected int beforeHandle( Request request, Response response ) { String agentInfo = request.getClientInfo().getAgent() != null ? request .getClientInfo().getAgent().toLowerCase() : "unknown"; // This solution was the only that came on my mind :) // should work only if client specified more then one "alternatives" if ( StringUtils.indexOfAny( agentInfo, new String[] { "mozilla", "firefox", "msie", "opera", "safari" } ) > -1 && request.getClientInfo().getAcceptedMediaTypes().size() > 1 ) { // overriding client preferences, since it is a browser to TEXT/HTML // doing this by adding text/html as firxt to accepted media types with quality 1 request .getClientInfo().getAcceptedMediaTypes().add( 0, new Preference<MediaType>( MediaType.TEXT_HTML, 1 ) ); } return CONTINUE; }
facultativeData); if (template.parse(getAgent(), map) > -1) { for (final String key : map.keySet()) { this.agentAttributes.put(key, (String) map
@Override public ClientInfo getCurrentThreadClientInfo() { final Subject subject = SecurityUtils.getSubject(); if (subject != null && subject.getPrincipal() != null) { final String userId = subject.getPrincipal().toString(); final Request current = Request.getCurrent(); if (current != null) { final String currentIp = RemoteIPFinder.findIP(current); final String currentUa = current.getClientInfo().getAgent(); return new ClientInfo(userId, currentIp, currentUa); } else { // this is not HTTP processing thread at all return null; } } // we have no Shiro subject or "anonymous" user (from Shiro perspective, null principals return null; } }
@Override public ClientInfo getCurrentThreadClientInfo() { final Subject subject = SecurityUtils.getSubject(); if ( subject != null && subject.getPrincipal() != null ) { final String userId = subject.getPrincipal().toString(); final Request current = Request.getCurrent(); if ( current != null ) { final String currentIp = RemoteIPFinder.findIP( current ); final String currentUa = current.getClientInfo().getAgent(); return new ClientInfo( userId, currentIp, currentUa ); } else { // this is not HTTP processing thread at all return null; } } // we have no Shiro subject or "anonymous" user (from Shiro perspective, null principals return null; } }
if (template.parse(getAgent(), map) > -1) { for (String key : map.keySet()) { this.agentAttributes
String agentName = request.getClientInfo().getAgent(); sb.append((agentName == null) ? "-" : agentName);
result.getRequestContext().put(AccessManager.REQUEST_USER, subject.getPrincipal().toString()); result.getRequestContext().put(AccessManager.REQUEST_AGENT, request.getClientInfo().getAgent());
/** * Generates a CallLog for the request and adds it to the buffer. * * @param request * The Request object associated with the request. * @param response * The Response object associated with the request. * @param duration * The duration of the request in milliseconds. * @param startTime * The time at which the request arrived to the agent as an * epoch. */ public void addCallLogToBuffer(Request request, Response response, int duration, long startTime) { CallLog callLog = new CallLog(); callLog.setDate(new Date(startTime)); callLog.setDuration(duration); callLog.setMethod(request.getMethod().getName()); callLog.setPath(request.getResourceRef().getPath()); callLog.setRemoteIp(request.getClientInfo().getUpstreamAddress()); callLog.setStatusCode(response.getStatus().getCode()); callLog.setUserAgent(request.getClientInfo().getAgent()); callLog.setUserToken((request.getClientInfo().getUser() == null) ? "" : request.getClientInfo().getUser().getIdentifier()); callLogs.add(callLog); if (callLogs.size() >= bufferSize) { flushLogs(); } }
/** * Generates a CallLog for the request and adds it to the buffer. * * @param request * The Request object associated with the request. * @param response * The Response object associated with the request. * @param duration * The duration of the request in milliseconds. * @param startTime * The time at which the request arrived to the agent as an * epoch. */ public void addCallLogToBuffer(Request request, Response response, int duration, long startTime) { CallLog callLog = new CallLog(); callLog.setDate(new Date(startTime)); callLog.setDuration(duration); callLog.setMethod(request.getMethod().getName()); callLog.setPath(request.getResourceRef().getPath()); callLog.setRemoteIp(request.getClientInfo().getUpstreamAddress()); callLog.setStatusCode(response.getStatus().getCode()); callLog.setUserAgent(request.getClientInfo().getAgent()); callLog.setUserToken((request.getClientInfo().getUser() == null) ? "" : request.getClientInfo().getUser().getIdentifier()); callLogs.add(callLog); if (callLogs.size() >= bufferSize) { flushLogs(); } }
/** * Generates a CallLog for the request and adds it to the buffer. * * @param request * The Request object associated with the request. * @param response * The Response object associated with the request. * @param duration * The duration of the request in milliseconds. * @param startTime * The time at which the request arrived to the agent as an * epoch. */ public void addCallLogToBuffer(Request request, Response response, int duration, long startTime) { CallLog callLog = new CallLog(); callLog.setDate(new Date(startTime)); callLog.setDuration(duration); callLog.setMethod(request.getMethod().getName()); callLog.setPath(request.getResourceRef().getPath()); callLog.setRemoteIp(request.getClientInfo().getUpstreamAddress()); callLog.setStatusCode(response.getStatus().getCode()); callLog.setUserAgent(request.getClientInfo().getAgent()); callLog.setUserToken((request.getClientInfo().getUser() == null) ? "" : request.getClientInfo().getUser().getIdentifier()); callLogs.add(callLog); if (callLogs.size() >= bufferSize) { flushLogs(); } }
return this.request.getClientInfo().getUpstreamAddress(); case "cig": return this.request.getClientInfo().getAgent(); case "cri": return (cr != null) ? cr.getIdentifier() : null;
/** * Generates a CallLog for the request and adds it to the buffer. * * @param request * The Request object associated with the request. * @param response * The Response object associated with the request. * @param duration * The duration of the request in milliseconds. * @param startTime * The time at which the request arrived to the agent as an * epoch. */ public void addCallLogToBuffer(Request request, Response response, int duration, long startTime) { CallLog callLog = new CallLog(); callLog.setDate(new Date(startTime)); callLog.setDuration(duration); callLog.setMethod(request.getMethod().getName()); callLog.setPath(request.getResourceRef().getPath()); callLog.setRemoteIp(request.getClientInfo().getUpstreamAddress()); callLog.setStatusCode(response.getStatus().getCode()); callLog.setUserAgent(request.getClientInfo().getAgent()); callLog.setUserToken((request.getClientInfo().getUser() == null) ? "" : request.getClientInfo().getUser().getIdentifier()); callLogs.add(callLog); if (callLogs.size() >= bufferSize) { flushLogs(); } }
/** * Generates a CallLog for the request and adds it to the buffer. * * @param request * The Request object associated with the request. * @param response * The Response object associated with the request. * @param duration * The duration of the request in milliseconds. * @param startTime * The time at which the request arrived to the agent as an * epoch. */ public void addCallLogToBuffer(Request request, Response response, int duration, long startTime) { CallLog callLog = new CallLog(); callLog.setDate(new Date(startTime)); callLog.setDuration(duration); callLog.setMethod(request.getMethod().getName()); callLog.setPath(request.getResourceRef().getPath()); callLog.setRemoteIp(request.getClientInfo().getUpstreamAddress()); callLog.setStatusCode(response.getStatus().getCode()); callLog.setUserAgent(request.getClientInfo().getAgent()); callLog.setUserToken((request.getClientInfo().getUser() == null) ? "" : request.getClientInfo().getUser().getIdentifier()); callLogs.add(callLog); if (callLogs.size() >= bufferSize) { flushLogs(); } }
result.getRequestContext().put(AccessManager.REQUEST_USER, subject.getPrincipal().toString()); result.getRequestContext().put(AccessManager.REQUEST_AGENT, request.getClientInfo().getAgent());
result.getRequestContext().put( AccessManager.REQUEST_AGENT, request.getClientInfo().getAgent() );
result.getRequestContext().put( AccessManager.REQUEST_AGENT, request.getClientInfo().getAgent() );