本文整理汇总了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);
}
}
示例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());
}
示例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);
}
示例4: verificationException
import org.keycloak.common.VerificationException; //导入依赖的package包/类
public PolicyFailure verificationException(IPolicyContext context, VerificationException e) {
return createAuthenticationPolicyFailure(context, AUTH_VERIFICATION_ERROR, e.getMessage());
}
示例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;