本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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.");
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}