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


Java ClassResourceInfo类代码示例

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


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

示例1: canHandle

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
public boolean canHandle(Message message, ClassResourceInfo classResourceInfo) {
    // check the "Authorization" header and if "Basic" is there, can be handled.

    // get the map of protocol headers
    Map protocolHeaders = (TreeMap) message.get(Message.PROTOCOL_HEADERS);
    // get the value for Authorization Header
    List authzHeaders = (ArrayList) protocolHeaders
            .get(EntitlementEndpointConstants.AUTHORIZATION_HEADER);
    if (authzHeaders != null) {
        // get the authorization header value, if provided
        String authzHeader = (String) authzHeaders.get(0);
        if (authzHeader != null && authzHeader.contains(BASIC_AUTH_HEADER)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:18,代码来源:BasicAuthHandler.java

示例2: compare

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
@Override
public int compare(
    ClassResourceInfo cri1, ClassResourceInfo cri2, Message message) {

    ResourceProvider rp1 = cri1.getResourceProvider();
    ResourceProvider rp2 = cri2.getResourceProvider();

    if (rp1 instanceof ServiceReferenceResourceProvider &&
        rp2 instanceof ServiceReferenceResourceProvider) {

        return comparator.compare(
            (ServiceReferenceResourceProvider)rp2,
            (ServiceReferenceResourceProvider)rp1);
    }

    if (rp1 instanceof ServiceReferenceResourceProvider) {
        return -1;
    }

    if (rp2 instanceof ServiceReferenceResourceProvider) {
        return 1;
    }

    return 0;
}
 
开发者ID:apache,项目名称:aries-jax-rs-whiteboard,代码行数:26,代码来源:CXFJaxRsServiceRegistrator.java

示例3: setupJAXRSServerFactoryBean

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
protected void setupJAXRSServerFactoryBean(JAXRSServerFactoryBean sfb) {
    // address
    if (getAddress() != null) {
        sfb.setAddress(getAddress());
    }
    processResourceModel(sfb);
    if (getResourceClasses() != null) {
        sfb.setResourceClasses(getResourceClasses());
    }

    // setup the resource providers for interfaces
    List<ClassResourceInfo> cris = sfb.getServiceFactory().getClassResourceInfo();
    for (ClassResourceInfo cri : cris) {
        final Class<?> serviceClass = cri.getServiceClass();
        if (serviceClass.isInterface()) {
            cri.setResourceProvider(new CamelResourceProvider(serviceClass));
        }
    }
    setupCommonFactoryProperties(sfb);
    sfb.setStart(false);
    getNullSafeCxfRsEndpointConfigurer().configure(sfb);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:CxfRsEndpoint.java

示例4: init

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
@Override
public void init(List<ClassResourceInfo> classResourceInfos) {
    this.setProduceMediaTypes((this.formatCodecs =
        (this.codecs.stream().collect(SdcctStreamUtils.toMap(ContentCodec::getType, Function.identity(), () -> new LinkedHashMap<>(this.codecs.size()))))
            .entrySet().stream()
            .collect(SdcctStreamUtils.toMap(
                (Entry<SdcctContentType, ContentCodec<?, ?>> contentTypeEntry) -> SdcctEnumUtils.findByPredicate(FhirFormatType.class,
                    formatTypeItem -> (formatTypeItem.getContentType() == contentTypeEntry.getKey())),
                Entry::getValue, () -> new LinkedHashMap<FhirFormatType, ContentCodec<?, ?>>(this.codecs.size())))).keySet().stream()
                    .map(formatType -> formatType.getEncodedMediaType().toString()).collect(Collectors.toList()));

    FhirFormatType[] formats = FhirFormatType.values();

    this.formatQueryParamValues = new LinkedHashMap<>();

    Stream.of(formats)
        .forEach(format -> format.getQueryParamValues().forEach(formatQueryParamValue -> this.formatQueryParamValues.put(formatQueryParamValue, format)));
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:19,代码来源:FhirContentProvider.java

示例5: canHandle

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
public boolean canHandle(Message message, ClassResourceInfo classResourceInfo) {
    // check the "Authorization" header and if "Basic" is there, can be handled.

    // get the map of protocol headers
    Map protocolHeaders = (TreeMap) message.get(Message.PROTOCOL_HEADERS);
    // get the value for Authorization Header
    List authzHeaders = (ArrayList) protocolHeaders
            .get(SCIMConstants.AUTHORIZATION_HEADER);
    if (authzHeaders != null) {
        // get the authorization header value, if provided
        String authzHeader = (String) authzHeaders.get(0);
        if (authzHeader != null && authzHeader.contains(BASIC_AUTH_HEADER)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:18,代码来源:BasicAuthHandler.java

示例6: canHandle

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
public boolean canHandle(Message message, ClassResourceInfo classResourceInfo) {
    // check the "Authorization" header and if "Bearer" is there, can be handled.

    // get the map of protocol headers
    Map protocolHeaders = (TreeMap) message.get(Message.PROTOCOL_HEADERS);
    // get the value for Authorization Header
    List authzHeaders = (ArrayList) protocolHeaders
            .get(SCIMConstants.AUTHORIZATION_HEADER);
    if (authzHeaders != null) {
        // get the authorization header value, if provided
        String authzHeader = (String) authzHeaders.get(0);
        if (authzHeader != null && authzHeader.contains(BEARER_AUTH_HEADER)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:18,代码来源:OAuthHandler.java

示例7: handleRequest

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
/**
  * This method handles the request received at the registry endpoint. The method decodes the extracted 
  * JWT token and extract the enduser's username and tenantID which is appended to the original rest request 
  * as query param and forwarded to the respective resource class. This method returns 
  * a null value which indicates that the request to be processed. 
  */
@Override
public Response handleRequest(Message message, ClassResourceInfo resourceInfo) {
	if(log.isDebugEnabled()){
		log.debug("request has been received at REST API handle request method");
	}
	String requestUrl = message.get(Message.REQUEST_URL).toString();
	String queryParam = (message.get(Message.QUERY_STRING) != null)?message.get(Message.QUERY_STRING).toString():"";
	//extracting all the headers received along with the request.
	String header = message.get(Message.PROTOCOL_HEADERS).toString();
	String userName = getUsernameFromJwtToken(header);
	String tenantID = null;
	try {
		tenantID = String.valueOf(getTenantIdOFUser(userName));
	} 
	catch (UserStoreException e) {
		log.error(e.getMessage(),e);
		return Response.status(Response.Status.UNAUTHORIZED).build();
	}
	String queryParamAppender = (queryParam.length() == 0 ? "" : "&");
	queryParam += queryParamAppender + "username="+userName+"&tenantid="+tenantID;
	message.put(Message.REQUEST_URL, requestUrl);
	message.put(Message.QUERY_STRING, queryParam);			
	return null;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:31,代码来源:RestApiRequestAuthorizationHandler.java

示例8: handleRequest

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
/**
 * Implementation of RequestHandler.handleRequest method.
 * This method retrieves userName and password from Basic auth header,
 * and tries to authenticate against carbon user store
 *
 * Upon successful authentication allows process to proceed to retrieve requested REST resource
 * Upon invalid credentials returns a HTTP 401 UNAUTHORIZED response to client
 * Upon receiving a userStoreExceptions or IdentityException returns HTTP 500 internal server error to client
 *
 * @param message
 * @param classResourceInfo
 * @return Response
 */
public Response handleRequest(Message message, ClassResourceInfo classResourceInfo) {
    if (log.isDebugEnabled()) {
        log.debug("Registry REST API Basic authentication handler execution started");
    }

    AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);
    if (policy != null && HttpAuthHeader.AUTH_TYPE_BASIC.equals(policy.getAuthorizationType())) {
        try {
            if (authenticate(policy.getUserName(), policy.getPassword())) {
                return null;
            }
        } catch (RestApiBasicAuthenticationException e) {
            /* Upon an occurrence of exception log the caught exception
             * and return a HTTP response with 500 server error response */
            log.error("Could not authenticate user : " + policy.getUserName() + "against carbon userStore", e);
            return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
        }

        return Response.status(Response.Status.UNAUTHORIZED).header("WWW-Authenticate", HttpAuthHeader.AUTH_TYPE_BASIC).build();
    }

    return Response.status(Response.Status.UNAUTHORIZED).header("WWW-Authenticate", HttpAuthHeader.AUTH_TYPE_BASIC).build();
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:37,代码来源:RestApiBasicAuthenticationHandler.java

示例9: handleRequest

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
public Response handleRequest(Message m, ClassResourceInfo resourceClass) {
    AuthorizationPolicy policy = m.get(AuthorizationPolicy.class);
    if (policy != null) {
        String username = policy.getUserName();
        String password = policy.getPassword();
        try {
            session = JcrSessionUtil.createSession(username, password);
            if (isAuthenticated(session)) {
                HttpServletRequest request = (HttpServletRequest) m.get(AbstractHTTPDestination.HTTP_REQUEST);
                request.setAttribute(AuthenticationConstants.HIPPO_SESSION, session);
                return null;
            } else {
                throw new UnauthorizedException();
            }
        } catch (LoginException e) {
            log.debug("Login failed: {}", e);
            throw new UnauthorizedException(e.getMessage());
        }
    }
    throw new UnauthorizedException();
}
 
开发者ID:jreijn,项目名称:hippo-addon-restful-webservices,代码行数:22,代码来源:HippoAuthenticationRequestHandler.java

示例10: handle

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
public Response handle(Message message, ClassResourceInfo classResourceInfo) {
    try {
        OAuth2TokenValidationResponseDTO respDTO;
        ValidationServiceClient validationServiceClient = new
                ValidationServiceClient(oauthValidationEndpoint, username, password);
        HttpHeaders httpHeaders = new HttpHeadersImpl(message);
        String header = httpHeaders.getRequestHeaders().getFirst("Authorization");
        // if the authorization token has Bearer..
        if (header.startsWith("Bearer ")) {
            String accessToken = header.substring(7).trim();
            respDTO = validationServiceClient.validateAuthenticationRequest(accessToken); //TODO : send scope params
            boolean valid = respDTO.getValid();
            if (!valid) {
                // authorization failure..
                return Response.status(Response.Status.FORBIDDEN).build();
            }
        }
    } catch (Exception e) {
        log.error("Error while validating access token", e);
        return Response.status(Response.Status.FORBIDDEN).build();
    }
    AuthenticationContext.setAuthenticated(true);
    return null;
}
 
开发者ID:apache,项目名称:stratos,代码行数:25,代码来源:OAuthHandler.java

示例11: bind

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
public static void bind(final Exchange exchange) {
    if (exchange == null) {
        return;
    }

    final ClassResourceInfo cri = exchange.get(OperationResourceInfo.class).getClassResourceInfo();

    // binding context fields
    final Set<Class<?>> types = new HashSet<>();
    for (final Field field : cri.getContextFields()) {
        types.add(field.getType());
    }

    bind(exchange, types);
}
 
开发者ID:apache,项目名称:tomee,代码行数:17,代码来源:Contexts.java

示例12: getAuthenticator

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
/**
 * Given the RESTful message and other info, returns the authenticator which can handle the request.
 *
 * @param message
 * @param classResourceInfo
 * @return
 */
public EntitlementAuthenticationHandler getAuthenticator(Message message,
                                                         ClassResourceInfo classResourceInfo) {
    //since we use a tree map to store authenticators, they are ordered based on the priority.
    //therefore, we iterate over the authenticators and check the can handle method
    for (EntitlementAuthenticationHandler entitlementAuthenticationHandler : EntitlementAuthHandlers.values()) {
        if (entitlementAuthenticationHandler.canHandle(message, classResourceInfo)) {
            return entitlementAuthenticationHandler;
        }
    }
    return null;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:19,代码来源:EntitlementAuthenticatorRegistry.java

示例13: handleRequest

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
@Override
public Response handleRequest(Message message, ClassResourceInfo classResourceInfo) {

    // reset anything set on provisioning thread local.
    IdentityApplicationManagementUtil.resetThreadLocalProvisioningServiceProvider();

    if (log.isDebugEnabled()) {
        log.debug("Authenticating Entitlement Endpoint request..");
    }
    EntitlementAuthenticatorRegistry entitlementAuthRegistry = EntitlementAuthenticatorRegistry.getInstance();

    if (entitlementAuthRegistry != null) {
        EntitlementAuthenticationHandler entitlementAuthHandler = entitlementAuthRegistry.getAuthenticator(
                message, classResourceInfo);

        boolean isAuthenticated = false;
        if (entitlementAuthHandler != null) {
            isAuthenticated = entitlementAuthHandler.isAuthenticated(message, classResourceInfo);

            if (isAuthenticated) {
                return null;
            }
        }
    }
    //if null response is not returned(i.e:message continues its way to the resource), return error & terminate.
    UnauthorizedException unauthorizedException = new UnauthorizedException(
            EntitlementEndpointConstants.ERROR_UNAUTHORIZED_MESSAGE);
    Response.ResponseBuilder responseBuilder = Response.status(unauthorizedException.getCode());
    responseBuilder.entity(unauthorizedException.getDescription());

    return responseBuilder.build();
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:33,代码来源:AuthenticationFilter.java

示例14: newJAXRSServerFactoryBean

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
protected JAXRSServerFactoryBean newJAXRSServerFactoryBean() {
    return new JAXRSServerFactoryBean() {
        protected boolean isValidClassResourceInfo(ClassResourceInfo cri) {
            // CXF will consider interfaces created for managing model resources
            // invalid - however it is fine with Camel processors if no service invocation
            // is requested.
            return !performInvocation || !cri.getServiceClass().isInterface();
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:CxfRsEndpoint.java

示例15: handleMessage

import org.apache.cxf.jaxrs.model.ClassResourceInfo; //导入依赖的package包/类
@Override
public void handleMessage(Message message) throws Fault {
    final OperationResourceInfo operationResource = message.getExchange().get(OperationResourceInfo.class);
    if (operationResource == null) {
        log.info("OperationResourceInfo is not available, skipping validation");
        return;
    }

    final ClassResourceInfo classResource = operationResource.getClassResourceInfo();
    if (classResource == null) {
        log.info("ClassResourceInfo is not available, skipping validation");
        return;
    }

    final ResourceProvider resourceProvider = classResource.getResourceProvider();
    if (resourceProvider == null) {
        log.info("ResourceProvider is not available, skipping validation");
        return;
    }

    final List<Object> arguments = MessageContentsList.getContentsList(message);
    final Method method = operationResource.getAnnotatedMethod();
    final Object instance = resourceProvider.getInstance(message);
    if (method != null && arguments != null) {
        //validate the parameters(arguments) over the invoked method
        validate(method, arguments.toArray(), instance);

        //validate the fields of each argument
        for (Object arg : arguments) {
            if (arg != null)
                validate(arg);
        }
    }

}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:36,代码来源:ValidationInterceptor.java


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