• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java OAuth2TokenValidationRequestDTO类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createValidationRequest

import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; //导入依赖的package包/类
private OAuth2TokenValidationRequestDTO createValidationRequest(String accessToken, String resource) {
    OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO();
    OAuth2TokenValidationRequestDTO_OAuth2AccessToken oauthToken =
            new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();

    oauthToken.setTokenType("bearer");
    oauthToken.setIdentifier(accessToken);
    validationRequest.setAccessToken(oauthToken);

    OAuth2TokenValidationRequestDTO_TokenValidationContextParam resourceContextParam =
            new OAuth2TokenValidationRequestDTO_TokenValidationContextParam();

    resourceContextParam.setKey("resource");
    resourceContextParam.setValue(resource);

    OAuth2TokenValidationRequestDTO_TokenValidationContextParam[] tokenValidationContextParams =
            new OAuth2TokenValidationRequestDTO_TokenValidationContextParam[1];

    tokenValidationContextParams[0] = resourceContextParam;
    validationRequest.setContext(tokenValidationContextParams);

    return validationRequest;
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:24,代码来源:RemoteOAuthValidator.java


示例2: validateAccessToken

import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; //导入依赖的package包/类
/**
 * Validates the OAuth 2.0 request
 *
 * @param accessTokenIdentifier
 * @return
 * @throws Exception
 */
public OAuth2TokenValidationResponseDTO validateAccessToken(String accessTokenIdentifier)
        throws Exception {
    OAuth2TokenValidationRequestDTO oauthReq = new OAuth2TokenValidationRequestDTO();
    OAuth2TokenValidationRequestDTO_OAuth2AccessToken accessToken =
            new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();
    accessToken.setTokenType(BEARER_TOKEN_TYPE);
    accessToken.setIdentifier(accessTokenIdentifier);
    oauthReq.setAccessToken(accessToken);
    try {
        return stub.validate(oauthReq);
    } catch (RemoteException e) {
        log.error("Error while validating OAuth2 request");
        throw new Exception("Error while validating OAuth2 request", e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:23,代码来源:OAuthServiceClient.java


示例3: findOAuthConsumerIfTokenIsValid

import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; //导入依赖的package包/类
/**
 * @param accessTokenIdentifier
 * @return
 * @throws Exception
 */
public OAuth2ClientApplicationDTO findOAuthConsumerIfTokenIsValid(String accessTokenIdentifier)
        throws Exception {
    OAuth2TokenValidationRequestDTO oauthReq = new OAuth2TokenValidationRequestDTO();
    OAuth2TokenValidationRequestDTO_OAuth2AccessToken accessToken =
            new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();
    accessToken.setTokenType(BEARER_TOKEN_TYPE);
    accessToken.setIdentifier(accessTokenIdentifier);
    oauthReq.setAccessToken(accessToken);
    try {
        return stub.findOAuthConsumerIfTokenIsValid(oauthReq);
    } catch (RemoteException e) {
        log.error("Error while validating OAuth2 request");
        throw new Exception("Error while validating OAuth2 request", e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:21,代码来源:OAuthServiceClient.java


示例4: validateAccessToken

import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; //导入依赖的package包/类
/**
 * Validates the OAuth 2.0 access token
 *
 * @param accessToken
 * @return
 * @throws Exception
 */
public OAuth2TokenValidationResponseDTO validateAccessToken(String accessToken)
        throws AiravataSecurityException {

    try {
        OAuth2TokenValidationRequestDTO oauthReq = new OAuth2TokenValidationRequestDTO();
        OAuth2TokenValidationRequestDTO_OAuth2AccessToken token =
                new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();
        token.setIdentifier(accessToken);
        token.setTokenType(BEARER_TOKEN_TYPE);
        oauthReq.setAccessToken(token);
        return stub.validate(oauthReq);
    } catch (RemoteException e) {
        logger.error(e.getMessage(), e);
        throw new AiravataSecurityException("Error in validating the OAuth access token.");
    }
}
 
开发者ID:apache,项目名称:airavata,代码行数:24,代码来源:DefaultOAuthClient.java


示例5: validateToken

import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; //导入依赖的package包/类
/**
 * This method gets a string accessToken and validates it and generate the OAuth2ClientApplicationDTO
 * containing the validity and user details if valid.
 *
 * @param token which need to be validated.
 * @return OAuthValidationResponse with the validated results.
 */
public OAuthValidationResponse validateToken(String token) throws RemoteException {
    OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO();
    OAuth2TokenValidationRequestDTO_OAuth2AccessToken accessToken =
            new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();
    accessToken.setTokenType(OauthAuthenticatorConstants.BEARER_TOKEN_TYPE);
    accessToken.setIdentifier(token);
    validationRequest.setAccessToken(accessToken);
    OAuth2TokenValidationServiceStub tokenValidationService =
            new OAuth2TokenValidationServiceStub(hostURL);
    ServiceClient client = tokenValidationService._getServiceClient();
    Options options = client.getOptions();
    List<Header> headerList = new ArrayList<>();
    Header header = new Header();
    header.setName(HTTPConstants.HEADER_AUTHORIZATION);
    header.setValue(OauthAuthenticatorConstants.AUTHORIZATION_HEADER_PREFIX_BASIC + " " + getBasicAuthCredentials());
    headerList.add(header);
    options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_HEADERS, headerList);
    client.setOptions(options);
    OAuth2TokenValidationResponseDTO tokenValidationResponse = tokenValidationService.
            findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse();
    boolean isValid = tokenValidationResponse.getValid();
    String userName = null;
    String tenantDomain = null;
    if (isValid) {
        userName = MultitenantUtils.getTenantAwareUsername(
                tokenValidationResponse.getAuthorizedUser());
        tenantDomain = MultitenantUtils.
                getTenantDomain(tokenValidationResponse.getAuthorizedUser());
    }
    return new OAuthValidationResponse(userName,tenantDomain,isValid);
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:39,代码来源:ExternalOAuthValidator.java


示例6: validateAuthenticationRequest

import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; //导入依赖的package包/类
public OAuth2TokenValidationResponseDTO validateAuthenticationRequest(String accessToken) throws Exception {
    OAuth2TokenValidationRequestDTO oauthReq = new OAuth2TokenValidationRequestDTO();
    OAuth2TokenValidationRequestDTO_OAuth2AccessToken oAuth2AccessToken
            = new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();
    oAuth2AccessToken.setIdentifier(accessToken);
    oAuth2AccessToken.setTokenType(OAuthConstants.BEARER_TOKEN_TYPE);
    oauthReq.setAccessToken(oAuth2AccessToken);
    try {
        return stub.validate(oauthReq);
    } catch (RemoteException e) {
        log.error("Error while validating OAuth2 request");
        throw new Exception("Error while validating OAuth2 request", e);
    }
}
 
开发者ID:apache,项目名称:stratos,代码行数:15,代码来源:ValidationServiceClient.java


示例7: getAuthenticationInfo

import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; //导入依赖的package包/类
/**
 * This creates an AuthenticationInfo object that is used for authorization. This method will validate the token and
 * sets the required parameters to the object.
 *
 * @param token                      that needs to be validated.
 * @param tokenValidationServiceStub stub that is used to call the external service.
 * @return AuthenticationInfo This contains the information related to authenticated client.
 * @throws RemoteException that triggers when failing to call the external service..
 */
private AuthenticationInfo getAuthenticationInfo(String token,
	OAuth2TokenValidationServiceStub tokenValidationServiceStub) throws RemoteException {
	AuthenticationInfo authenticationInfo = new AuthenticationInfo();
	OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO();
	OAuth2TokenValidationRequestDTO_OAuth2AccessToken accessToken =
			new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();
	accessToken.setTokenType(TOKEN_TYPE);
	accessToken.setIdentifier(token);
	validationRequest.setAccessToken(accessToken);
	boolean authenticated;
	OAuth2TokenValidationResponseDTO tokenValidationResponse;
	tokenValidationResponse = tokenValidationServiceStub.validate(validationRequest);
	if (tokenValidationResponse == null) {
		authenticationInfo.setAuthenticated(false);
		return authenticationInfo;
	}
	authenticated = tokenValidationResponse.getValid();
	if (authenticated) {
		String authorizedUser = tokenValidationResponse.getAuthorizedUser();
		String username = MultitenantUtils.getTenantAwareUsername(authorizedUser);
		String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser);
		authenticationInfo.setUsername(username);
		authenticationInfo.setTenantDomain(tenantDomain);
		authenticationInfo.setProperty(TOKEN_EXPIRY_TIME_IDENTIFIER, tokenValidationResponse.getExpiryTime());
		String validateResponseScope[] = tokenValidationResponse.getScope();
		if (validateResponseScope != null && validateResponseScope.length > 0) {
			List<String> responseScopes = Arrays.asList(validateResponseScope);
			authenticationInfo.setProperty(SCOPE_IDENTIFIER, responseScopes);
		}
	} else {
		if (log.isDebugEnabled()) {
			log.debug("Token validation failed for token: " + token);
		}
	}
	ServiceContext serviceContext = tokenValidationServiceStub._getServiceClient()
			.getLastOperationContext().getServiceContext();
	cookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING);
	authenticationInfo.setAuthenticated(authenticated);
	return authenticationInfo;
}
 
开发者ID:wso2,项目名称:carbon-business-messaging,代码行数:50,代码来源:OAuth2BasedMQTTAuthenticator.java


示例8: getTokenValidation

import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; //导入依赖的package包/类
/**
 * 
 * @param accessToken
 * @return
 * @throws AxisFault
 * @throws RemoteException
 */
public OAuth2TokenValidationResponseDTO getTokenValidation(String accessToken) throws AxisFault, RemoteException {
    OAuth2TokenValidationRequestDTO oauthReq = new OAuth2TokenValidationRequestDTO();
    oauthReq.setAccessToken(getOAuthToken(accessToken));

    return getValidationService().validate(oauthReq);        
}
 
开发者ID:romulets,项目名称:wso2is-example,代码行数:14,代码来源:TokenValidationService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ExecutionFilter类代码示例发布时间:2022-05-22
下一篇:
Java ClassUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap