当前位置: 首页>>代码示例>>Java>>正文


Java ResourceMethodInvoker类代码示例

本文整理汇总了Java中org.jboss.resteasy.core.ResourceMethodInvoker的典型用法代码示例。如果您正苦于以下问题:Java ResourceMethodInvoker类的具体用法?Java ResourceMethodInvoker怎么用?Java ResourceMethodInvoker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ResourceMethodInvoker类属于org.jboss.resteasy.core包,在下文中一共展示了ResourceMethodInvoker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: discover

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
public static List<Path> discover(ResourceMethodRegistry registry) {
    return registry.getBounded().entrySet().stream()
            .sorted(Comparator.comparing(Map.Entry::getKey))
            .map(entry -> {
                String path = entry.getKey();
                List<PathMethod> methods = entry.getValue().stream()
                        .filter(resourceInvoker -> resourceInvoker instanceof ResourceMethodInvoker)
                        .map(resourceInvoker -> {
                            ResourceMethodInvoker rmi = (ResourceMethodInvoker) resourceInvoker;
                            String producing = null;
                            if (rmi.getProduces() != null && rmi.getProduces().length > 0) {
                                producing = rmi.getProduces()[0].toString();
                            }
                            String consuming = null;
                            if (rmi.getConsumes() != null && rmi.getConsumes().length > 0) {
                                consuming = rmi.getConsumes()[0].toString();
                            }
                            return new PathMethod(rmi.getHttpMethods().iterator().next(), producing, consuming);
                        }).collect(Collectors.toList());
                return new Path(path, methods);
            }).collect(Collectors.toList());
}
 
开发者ID:hawkular,项目名称:hawkular-commons,代码行数:23,代码来源:RESTPathDiscovery.java

示例2: filter

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
@SuppressWarnings("nls")
@Override
public void filter(ContainerRequestContext context) throws IOException
{
	ResourceMethodInvoker invoker = (ResourceMethodInvoker) context.getProperty(ResourceMethodInvoker.class
		.getName());
	Class<?> clazz = invoker.getResourceClass();
	Institutional.Type instType = Institutional.Type.INSTITUTIONAL;
	Institutional instanno = clazz.getAnnotation(Institutional.class);
	if( instanno != null )
	{
		instType = instanno.value();
	}
	boolean hasInst = CurrentInstitution.get() != null;
	if( instType != Institutional.Type.BOTH && (hasInst != (instType == Institutional.Type.INSTITUTIONAL)) )
	{
		throw new NotFoundException();
	}
	// Class or calling method system restricted?
	SecureOnCallSystem system = clazz.getAnnotation(SecureOnCallSystem.class);
	if( system == null )
	{
		system = invoker.getMethod().getAnnotation(SecureOnCallSystem.class);
	}
	if( system != null && !CurrentUser.getUserState().isSystem() )
	{
		throw new AccessDeniedException("You do not have the privileges to access this endpoint");
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:30,代码来源:InstitutionSecurityFilter.java

示例3: preProcess

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
@Override
public ServerResponse preProcess(HttpRequest hr, ResourceMethodInvoker rmi) throws Failure, WebApplicationException {
    String methodName = rmi.getMethod().getName();
    String remoteAddress = servletRequest.getRemoteAddr();
    String requestUri = servletRequest.getRequestURI();
    String queryString = servletRequest.getQueryString();
    String httpMethod = servletRequest.getMethod();

    String requestData = "Remote Adress: " + remoteAddress + "\n\t\t\t"
            + "Method: " + methodName + "\n\t\t\t"
            + "Request URI: " + requestUri + "\n\t\t\t"
            + "Query String: " + queryString + "\n\t\t\t"
            + "HTTP Method: " + httpMethod;

    LOGGER.info(requestData);

    Enumeration<String> headerNames = servletRequest.getHeaderNames();
    servletRequest.getHeader("");

    if (LOGGER.isTraceEnabled()) {
        while (headerNames.hasMoreElements()) {
            String headerName = headerNames.nextElement();

            Enumeration<String> headers = servletRequest.getHeaders(headerName);
            while (headers.hasMoreElements()) {
                String headerValue = headers.nextElement();
                LOGGER.trace(headerName + ": " + headerValue);
            }
        }
    } else {
        String contentType = servletRequest.getHeader("content-type");
        LOGGER.info("content-type: " + contentType);

        String acceptEnconding = servletRequest.getHeader("accept-encoding");
        LOGGER.info("accept-encoding: " + acceptEnconding);
    }

    return null;
}
 
开发者ID:jokoframework,项目名称:notification-server,代码行数:40,代码来源:LoggingInterceptor.java

示例4: addMethod

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
public void addMethod(String path, ResourceMethodInvoker method) {
	String produces = mostPreferredOrNull(method.getProduces());
	String consumes = mostPreferredOrNull(method.getConsumes());

	for (String verb : method.getHttpMethods()) {
		calls.add(new MethodDescription(verb, path, produces, consumes));
	}
}
 
开发者ID:LADOSSIFPB,项目名称:-gdgjp-HackGDGIO2015-IFOpenDoors,代码行数:9,代码来源:IFOpenDoorsRestServices.java

示例5: fromBoundResourceInvokers

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
public static List<ResourceDescription> fromBoundResourceInvokers(
		Set<Map.Entry<String, List<ResourceInvoker>>> bound) {
	
	Map<String, ResourceDescription> descriptions = 
			new HashMap<String, IFOpenDoorsRestServices.ResourceDescription>();

	for (Map.Entry<String, List<ResourceInvoker>> entry : bound) {
		Method aMethod = ((ResourceMethodInvoker) entry.getValue().get(
				0)).getMethod();
		String basePath = aMethod.getDeclaringClass()
				.getAnnotation(Path.class).value();

		if (!descriptions.containsKey(basePath)) {
			descriptions.put(basePath,
					new ResourceDescription(basePath));
		}

		for (ResourceInvoker invoker : entry.getValue()) {
			ResourceMethodInvoker method = (ResourceMethodInvoker) invoker;

			String subPath = null;
			for (Annotation annotation : method.getMethodAnnotations()) {
				if (annotation.annotationType().equals(Path.class)) {
					subPath = ((Path) annotation).value();
					break;
				}
			}

			descriptions.get(basePath).addMethod(basePath + subPath,
					method);
		}
	}

	List<ResourceDescription> linkList = 
			new LinkedList<ResourceDescription>();
	linkList.addAll(descriptions.values());
	
	return linkList;
}
 
开发者ID:LADOSSIFPB,项目名称:-gdgjp-HackGDGIO2015-IFOpenDoors,代码行数:40,代码来源:IFOpenDoorsRestServices.java

示例6: preProcess

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
public ServerResponse preProcess(HttpRequest request, ResourceMethodInvoker method)
        throws Failure, WebApplicationException {
    if (logger.isDebugEnabled()) {

        String httpMethod = request.getHttpMethod();

        URI uri = ui.getRequestUri();

        String uriPath = uri.getPath();
        if (uri.getQuery() != null) {
            uriPath += "?" + uri.getQuery();
        }
        if (uri.getFragment() != null) {
            uriPath += "#" + uri.getFragment();
        }

        String sessionid = null;
        List<String> headerSessionId = request.getHttpHeaders().getRequestHeader("sessionid");
        if (headerSessionId != null) {
            sessionid = headerSessionId.get(0);
        }
        if (logger.isDebugEnabled()) {
            // log only in debug mode
            logger.debug(sessionid + "|" + httpMethod + "|" + uriPath);
        }
    }
    return null;
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:29,代码来源:LoggingInterceptor.java

示例7: filter

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
    final ResourceMethodInvoker methodInvoker = (ResourceMethodInvoker) requestContext.getProperty("org.jboss.resteasy.core.ResourceMethodInvoker");
    final Method method = methodInvoker.getMethod();

    // Verifies if it isn't annotated with @PermitAll
    if (!method.isAnnotationPresent(PermitAll.class)) {

        if (method.isAnnotationPresent(DenyAll.class)) {
            LOGGER.info("Access denied!");
            requestContext.abortWith(Response.status(Status.FORBIDDEN).entity(new User()).build());
        }
    }
}
 
开发者ID:bionimbuz,项目名称:Bionimbuz,代码行数:15,代码来源:SecurityInterceptor.java

示例8: filter

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
@Override
public void filter(ContainerRequestContext ctx) throws IOException {
	if (!(ctx instanceof PostMatchContainerRequestContext)) {
		return;
	}

	PostMatchContainerRequestContext context = (PostMatchContainerRequestContext) ctx;
	ResourceMethodInvoker resourceMethod = context.getResourceMethod();
	Method method = resourceMethod.getMethod();
	Class<?> resource = method.getDeclaringClass();
	checkRequireAuthentication(ctx, method, resource);
}
 
开发者ID:devhub-tud,项目名称:git-server,代码行数:13,代码来源:SecurityFilter.java

示例9: filter

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
@Override
public void filter(ContainerRequestContext arg0,
		ContainerResponseContext responseContext) throws IOException {

	MultivaluedMap<String, Object> headers = responseContext.getHeaders();
	headers.putSingle("Access-Control-Allow-Origin", "*");
/*	headers.putSingle("Access-Control-Allow-Methods", "HEAD, DELETE,GET,OPTIONS,POST,PUT");
	headers.putSingle("Access-Control-Allow-Headers", "Accept, Content-Type, Authorization, Content-Length, X-Requested-With");*/
	headers.putSingle("Access-Control-Allow-Credentials", true); 

	final ResourceMethodInvoker methodInvoker = (ResourceMethodInvoker)arg0.getProperty("org.jboss.resteasy.core.ResourceMethodInvoker");
    if ( methodInvoker != null) {
    	final Method method = methodInvoker.getMethod();
      
    	if (!method.isAnnotationPresent(AuthenticationNotRequired.class) && 
    		  !method.isAnnotationPresent(NdexOpenFunction.class) && 
    		  !BasicAuthenticationFilter.setAuthHeaderIsFalse(arg0)) {
           	   headers.putSingle("WWW-Authenticate", "Basic");
    	}
    	
    	int responseCode = responseContext.getStatus();
    	
    	String error = MDC.get("error");
    	
    	logger.info("[end]\t["+ method.getName() + "]\t[status: " + responseCode + "]" + 
    			(error !=null? "\t[error: "+ error + "]" : "" ));
    	
    	if ( error !=null)
    		MDC.remove("error");
    }
    
    
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:34,代码来源:NdexDefaultResponseFilter.java

示例10: getMethod

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
@Override
public ResourceMethodInvoker getMethod() {

    return invoker;
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:6,代码来源:VertxAsynchronousResponse.java

示例11: filter

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
public void filter(ContainerRequestContext requestContext) throws IOException   {

        ResourceMethodInvoker methodInvoker = (ResourceMethodInvoker)
                requestContext.getProperty("org.jboss.resteasy.core.ResourceMethodInvoker");
        Method method = methodInvoker.getMethod();

        //Access allowed for all
        if( ! method.isAnnotationPresent(PermitAll.class))
        {
            //Access denied for all
            if(method.isAnnotationPresent(DenyAll.class))
            {
                requestContext.abortWith(ACCESS_FORBIDDEN);
                return;
            }

            //Get request headers
            final MultivaluedMap<String, String> headers = requestContext.getHeaders();

            //Fetch authorization header
            final List<String> authorization = headers.get(AUTHORIZATION_PROPERTY);

            //If no authorization information present; block access
            if(authorization == null || authorization.isEmpty())
            {
                requestContext.abortWith(ACCESS_DENIED);
                return;
            }


            Subject subject = securityService.getSubject();
            if (!subject.isAuthenticated()) {
                requestContext.abortWith(SERVER_ERROR);
                return;
             }


            //Verify user access
            if(method.isAnnotationPresent(RolesAllowed.class))
            {
                boolean isAllowed = false;

                RolesAllowed rolesAnnotation = method.getAnnotation(RolesAllowed.class);
                Set<String> rolesSet = new HashSet<String>(Arrays.asList(rolesAnnotation.value()));

                //Is user allowed?
                for(String s : rolesSet)
                    if(subject.hasRole(s))
                    {
                        isAllowed = true;
                    }

                if(!isAllowed)
                {
                    requestContext.abortWith(ACCESS_DENIED);
                }
            }

        }
    }
 
开发者ID:ffacon,项目名称:tapestry5-angular2-demo,代码行数:61,代码来源:SecurityInterceptor.java

示例12: isNodeOperational

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
/**
 * Filter to check if node is operational and the requests can be executed.
 *
 * @param reqCtx
 */
private void isNodeOperational( PostMatchContainerRequestContext reqCtx )
{

    UriInfo info = reqCtx.getUriInfo();
    String methodName = null;
    String className = null;

    ResourceMethodInvoker method = reqCtx.getResourceMethod();

    if ( method != null )
    {

        methodName = method.getMethod().getName();
        className = method.getMethod().getDeclaringClass().getCanonicalName();
    }

    if ( methodName.equalsIgnoreCase( "updateNodes" )
        && className.equalsIgnoreCase( "com.vmware.vrack.hms.rest.services.ServerRestService" ) )
    {

        MultivaluedMap<String, String> queryParameters = info.getQueryParameters();
        if ( queryParameters != null && queryParameters.containsKey( "action" ) )
        {

            try
            {

                NodeAdminStatus.valueOf( queryParameters.get( "action" ).get( 0 ) );
                return;

            }
            catch ( IllegalArgumentException e )
            {

                logger.info( "Action not of type NodeOperationalStatus" );
            }
        }
    }

    MultivaluedMap<String, String> parameters = info.getPathParameters();
    if ( parameters != null && parameters.containsKey( "host_id" ) )
    {

        HmsNode node = ServerNodeConnector.getInstance().getNodeMap().get( parameters.get( "host_id" ).get( 0 ) );
        if ( node != null && !node.isNodeOperational() )
        {

            reqCtx.abortWith( Response.status( Status.SERVICE_UNAVAILABLE.getStatusCode() ).entity( new BaseResponse( Status.SERVICE_UNAVAILABLE.getStatusCode(),
                                                                                                                      "Service Unavialble",
                                                                                                                      node.getAdminStatus().getMessage( node.getNodeID() ) ) ).type( MediaType.APPLICATION_JSON ).build() );
            logger.debug( "Abort request: {} {} ", reqCtx.getMethod(), reqCtx.getUriInfo().getAbsolutePath() );
        }
    }
}
 
开发者ID:vmware,项目名称:OHMS,代码行数:60,代码来源:HmsServiceFilters.java

示例13: filter

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
	ResourceMethodInvoker methodInvoker = (ResourceMethodInvoker) requestContext.getProperty("org.jboss.resteasy.core.ResourceMethodInvoker");
       Method method = methodInvoker.getMethod();
       //Access allowed for all
       if( ! method.isAnnotationPresent(PermitAll.class))
       {
           //Access denied for all
           if(method.isAnnotationPresent(DenyAll.class))
           {
               requestContext.abortWith(ACCESS_FORBIDDEN);
               return;
           }
            
           //Get request headers
           final MultivaluedMap<String, String> headers = requestContext.getHeaders();
            
           //Fetch authorization header
           final List<String> authorization = headers.get(AUTHORIZATION_PROPERTY);
            
           //If no authorization information present; block access
           if(authorization == null || authorization.isEmpty())
           {
               requestContext.abortWith(ACCESS_DENIED);
               return;
           }
            
           //Get user token
           final String userToken = authorization.get(0);
           
           DefaultUserService userService = DefaultUserService.getInstance();
           
           User user = userService.getUser(userToken); 
           
           if(user == null) {
           	requestContext.abortWith(ACCESS_DENIED);
           	return;
           }
          
           //Verifying Username and password
           System.out.println(user.getUserName());
           System.out.println(user.getPassword());
           
            
           //Verify user access
           if(method.isAnnotationPresent(RolesAllowed.class))
           {
               RolesAllowed rolesAnnotation = method.getAnnotation(RolesAllowed.class);
               Set<String> rolesSet = new HashSet<String>(Arrays.asList(rolesAnnotation.value()));
                
               //Is user valid?
               if(!rolesSet.contains(user.getRole().name()))
               {
                   requestContext.abortWith(ACCESS_DENIED);
                   return;
               }
           }
       }
}
 
开发者ID:tangaiyun,项目名称:Netty-Resteasy-Spring,代码行数:60,代码来源:AuthenticationFilter.java

示例14: filter

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) {
	ResourceMethodInvoker methodInvoker = (ResourceMethodInvoker) requestContext
			.getProperty("org.jboss.resteasy.core.ResourceMethodInvoker");
	Method method = methodInvoker.getMethod();
	// Access allowed for all
	if (!method.isAnnotationPresent(PermitAll.class)) {
		// Access denied for all
		if (method.isAnnotationPresent(DenyAll.class)) {
			requestContext.abortWith(ACCESS_FORBIDDEN);
			return;
		}

		// Get request headers
		final MultivaluedMap<String, String> headersMap = requestContext.getHeaders();

		// Fetch authorization header
		final List<String> authorization = headersMap.get(AUTHORIZATION_PROPERTY);

		// If no authorization information present; block access
		if (authorization == null || authorization.isEmpty()) {
			requestContext.abortWith(ACCESS_DENIED);
			return;
		}

		// Get encoded username and password
		final String encodedUserPassword = authorization.get(0).replaceFirst(AUTHENTICATION_SCHEME + " ", "");

		// Decode username and password
		String usernameAndPassword = new String(Base64.decodeBase64(encodedUserPassword));

		// Split username and password tokens
		final StringTokenizer tokenizer = new StringTokenizer(usernameAndPassword, ":");
		final String username = tokenizer.nextToken();
		final String password = tokenizer.nextToken();

		// Verify user access
		if (method.isAnnotationPresent(RolesAllowed.class)) {
			RolesAllowed rolesAnnotation = method.getAnnotation(RolesAllowed.class);
			Set<String> rolesSet = new HashSet<String>(Arrays.asList(rolesAnnotation.value()));

			// Is user valid?
			if (!isUserAllowed(username, password, rolesSet)) {
				requestContext.abortWith(ACCESS_DENIED);
				return;
			}
		}
	}
}
 
开发者ID:v5developer,项目名称:maven-framework-project,代码行数:50,代码来源:SecurityInterceptor.java

示例15: filter

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) {
	ResourceMethodInvoker methodInvoker = (ResourceMethodInvoker) requestContext
			.getProperty(RESOURCE_METHOD_INVOKER);
	Method method = methodInvoker.getMethod();
	// Access allowed for all
	if (!method.isAnnotationPresent(PermitAll.class)) {
		// Access denied for all
		if (method.isAnnotationPresent(DenyAll.class)) {
			requestContext.abortWith(ACCESS_FORBIDDEN);
			return;
		}

		// Get request headers
		final MultivaluedMap<String, String> headersMap = requestContext.getHeaders();

		// Fetch authorization header
		final List<String> authorizationList = headersMap.get(AUTHORIZATION_PROPERTY);

		// If no authorization information present; block access
		if (authorizationList == null || authorizationList.isEmpty()) {
			requestContext.abortWith(ACCESS_DENIED);
			return;
		}

		// Get encoded username and password
		final String encodedUserPassword = authorizationList.get(0).replaceFirst(AUTHENTICATION_SCHEME + " ", "");

		// Decode username and password
		String usernameAndPassword = new String(Base64.decodeBase64(encodedUserPassword));

		// Split username and password tokens
		final StringTokenizer tokenizer = new StringTokenizer(usernameAndPassword, ":");
		final String userName = tokenizer.nextToken();
		final String password = tokenizer.nextToken();

		// Verify user access
		if (method.isAnnotationPresent(RolesAllowed.class)) {
			RolesAllowed rolesAnnotation = method.getAnnotation(RolesAllowed.class);
			Set<String> rolesSet = new HashSet<String>(Arrays.asList(rolesAnnotation.value()));

			// Is user valid?
			if (!isUserAllowed(userName, password, rolesSet)) {
				requestContext.abortWith(ACCESS_DENIED);
				return;
			}
		}
	}
}
 
开发者ID:v5developer,项目名称:maven-framework-project,代码行数:50,代码来源:SecurityFilter.java


注:本文中的org.jboss.resteasy.core.ResourceMethodInvoker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。