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


Java VerificationException类代码示例

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


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

示例1: doTokenAuth

import org.keycloak.common.VerificationException; //导入依赖的package包/类
private Holder<Boolean> doTokenAuth(Holder<Boolean> successStatus, ApiRequest request,
        IPolicyContext context, KeycloakOauthConfigBean config, IPolicyChain<ApiRequest> chain,
        String rawToken) {
    try {
        AccessToken parsedToken = RSATokenVerifier.verifyToken(rawToken, config.getRealmCertificate()
                .getPublicKey(), config.getRealm());

        delegateKerberosTicket(request, config, parsedToken);
        forwardHeaders(request, config, rawToken, parsedToken);
        stripAuthTokens(request, config);
        forwardAuthRoles(context, config, parsedToken);

        RequestMetric metric = context.getAttribute(PolicyContextKeys.REQUEST_METRIC, (RequestMetric) null);
        if (metric != null) {
            metric.setUser(parsedToken.getPreferredUsername());
        }

        return successStatus.setValue(true);
    } catch (VerificationException e) {
        System.out.println(e);
        chain.doFailure(failureFactory.verificationException(context, e));
        return successStatus.setValue(false);
    }
}
 
开发者ID:apiman,项目名称:apiman-plugins,代码行数:25,代码来源:KeycloakOauthPolicy.java

示例2: createKeycloakSecurityContext

import org.keycloak.common.VerificationException; //导入依赖的package包/类
/**
 * Creates a new {@link RefreshableKeycloakSecurityContext} from the given {@link KeycloakDeployment} and {@link AccessTokenResponse}.
 *
 * @param deployment the <code>KeycloakDeployment</code> for which to create a <code>RefreshableKeycloakSecurityContext</code> (required)
 * @param accessTokenResponse the <code>AccessTokenResponse</code> from which to create a RefreshableKeycloakSecurityContext (required)
 *
 * @return a <code>RefreshableKeycloakSecurityContext</code> created from the given <code>accessTokenResponse</code>
 * @throws VerificationException if the given <code>AccessTokenResponse</code> contains an invalid {@link IDToken}
 */
public static RefreshableKeycloakSecurityContext createKeycloakSecurityContext(KeycloakDeployment deployment, AccessTokenResponse accessTokenResponse) throws VerificationException {
    String tokenString = accessTokenResponse.getToken();
    String idTokenString = accessTokenResponse.getIdToken();
    AccessToken accessToken = RSATokenVerifier
            .verifyToken(tokenString, deployment.getRealmKey(), deployment.getRealmInfoUrl());
    IDToken idToken;

    try {
        JWSInput input = new JWSInput(idTokenString);
        idToken = input.readJsonContent(IDToken.class);
    } catch (JWSInputException e) {
        throw new VerificationException("Unable to verify ID token", e);
    }

    // FIXME: does it make sense to pass null for the token store?
    return new RefreshableKeycloakSecurityContext(deployment, null, tokenString, accessToken, idTokenString, idToken, accessTokenResponse.getRefreshToken());
}
 
开发者ID:Smartling,项目名称:smartling-keycloak-extras,代码行数:27,代码来源:KeycloakSpringAdapterUtils.java

示例3: login

import org.keycloak.common.VerificationException; //导入依赖的package包/类
@Override
public RefreshableKeycloakSecurityContext login(String username, String password) throws VerificationException {

    final MultiValueMap<String,String> body = new LinkedMultiValueMap<>();
    final HttpHeaders headers = new HttpHeaders();

    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    body.set("username", username);
    body.set("password", password);
    body.set(OAuth2Constants.GRANT_TYPE, OAuth2Constants.PASSWORD);

    AccessTokenResponse response = template.postForObject(keycloakDeployment.getTokenUrl(), new HttpEntity<>(body, headers), AccessTokenResponse.class);

    return KeycloakSpringAdapterUtils.createKeycloakSecurityContext(keycloakDeployment, response);
}
 
开发者ID:Smartling,项目名称:smartling-keycloak-extras,代码行数:17,代码来源:KeycloakDirectAccessGrantService.java

示例4: verificationException

import org.keycloak.common.VerificationException; //导入依赖的package包/类
public PolicyFailure verificationException(IPolicyContext context, VerificationException e) {
    return createAuthenticationPolicyFailure(context, AUTH_VERIFICATION_ERROR, e.getMessage());
}
 
开发者ID:apiman,项目名称:apiman-plugins,代码行数:4,代码来源:PolicyFailureFactory.java

示例5: login

import org.keycloak.common.VerificationException; //导入依赖的package包/类
/**
 * Creates a login session for the Keycloak authenticated username and password.
 *
 * @param username to username to authenticate
 * @param password the password for the given <code>username</code>
 * @return an authenticated <code>RefreshableKeycloakSecurityContext</code> if login succeeds
 * are incorrect
 */
RefreshableKeycloakSecurityContext login(String username, String password) throws VerificationException;
 
开发者ID:Smartling,项目名称:smartling-keycloak-extras,代码行数:10,代码来源:DirectAccessGrantService.java


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