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


Java OAuth2TokenValidationRequestDTO.setAccessToken方法代码示例

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


在下文中一共展示了OAuth2TokenValidationRequestDTO.setAccessToken方法的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.setAccessToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。