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


Java ResourceMethodInvoker.getMethod方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: filter

import org.jboss.resteasy.core.ResourceMethodInvoker; //导入方法依赖的package包/类
public void filter(ContainerRequestContext requestContext) throws IOException {
		if(requestContext.getMethod().equalsIgnoreCase("OPTIONS")) {
			//Preflight in here?
			return;
		}

		SecurityContext securityContext = requestContext.getSecurityContext();

		if(securityContext.getUserPrincipal() == null) {
			//Not logged in. Auth restriction should be done via web.xml, if no userPrincipal is set it uses anonymous login
			return;
		}

		ResourceMethodInvoker methodInvoker = (ResourceMethodInvoker) requestContext.getProperty("org.jboss.resteasy.core.ResourceMethodInvoker");
		if(methodInvoker == null) {
			log.error("Unable to fetch method from ResourceMethodInvoker");
			requestContext.abortWith(SERVER_ERROR);
		}
		Method method = methodInvoker.getMethod();

		if(method.isAnnotationPresent(DenyAll.class)) {
			//Functionality has been disallowed.
			requestContext.abortWith(ACCESS_FORBIDDEN);
			return;
		}
		if(method.isAnnotationPresent(PermitAll.class)) {
			//No authorization required.
			return;
		}

		if(method.isAnnotationPresent(RolesAllowed.class)) {
			RolesAllowed rolesAnnotation = method.getAnnotation(RolesAllowed.class);
			Set<String> rolesSet = new HashSet<String>(Arrays.asList(rolesAnnotation.value()));
//			System.out.println("Checking authentication for user ["+securityContext.getUserPrincipal().getName()+"] method ["+method.getAnnotation(javax.ws.rs.Path.class).value()+"] roles " + rolesSet.toString());

			//Verifying username and password
			if(!doAuth(securityContext, rolesSet)) {
				requestContext.abortWith(ACCESS_FORBIDDEN);
				return;
			}
		}
		//Don't do anything if RolesAllowed annotation is not set
	}
 
开发者ID:ibissource,项目名称:iaf,代码行数:44,代码来源:AuthorizationFilter.java


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