Java Code Examples for org.apache.cxf.rs.security.oidc.common.IdToken#getName()
The following examples show how to use
org.apache.cxf.rs.security.oidc.common.IdToken#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserInfoService.java From cxf with Apache License 2.0 | 5 votes |
protected UserInfo createFromIdToken(IdToken idToken) { UserInfo userInfo = new UserInfo(); userInfo.setSubject(idToken.getSubject()); if (super.isJwsRequired()) { userInfo.setIssuer(idToken.getIssuer()); userInfo.setAudience(idToken.getAudience()); } if (idToken.getPreferredUserName() != null) { userInfo.setPreferredUserName(idToken.getPreferredUserName()); } if (idToken.getName() != null) { userInfo.setName(idToken.getName()); } if (idToken.getGivenName() != null) { userInfo.setGivenName(idToken.getGivenName()); } if (idToken.getFamilyName() != null) { userInfo.setFamilyName(idToken.getFamilyName()); } if (idToken.getEmail() != null) { userInfo.setEmail(idToken.getEmail()); } if (idToken.getNickName() != null) { userInfo.setNickName(idToken.getNickName()); } if (additionalClaims != null && !additionalClaims.isEmpty()) { for (String additionalClaim : additionalClaims) { if (idToken.containsProperty(additionalClaim)) { userInfo.setClaim(additionalClaim, idToken.getClaim(additionalClaim)); } } } //etc return userInfo; }
Example 2
Source File: BackChannelLogoutHandler.java From cxf-fediz with Apache License 2.0 | 5 votes |
private void submitBackChannelLogoutRequest(final Client client, final OidcUserSubject subject, final IdToken idTokenHint, final String uri) { // Application context is expected to contain HttpConduit HTTPS configuration final WebClient wc = WebClient.create(uri); IdToken idToken = idTokenHint != null ? idTokenHint : subject.getIdToken(); JwtClaims claims = new JwtClaims(); claims.setIssuer(idToken.getIssuer()); claims.setSubject(idToken.getSubject()); claims.setAudience(client.getClientId()); claims.setIssuedAt(System.currentTimeMillis() / 1000); claims.setTokenId(Base64UrlUtility.encode(CryptoUtils.generateSecureRandomBytes(16))); claims.setClaim(EVENTS_PROPERTY, Collections.singletonMap(BACK_CHANNEL_LOGOUT_EVENT, Collections.emptyMap())); if (idToken.getName() != null) { claims.setClaim(IdToken.NAME_CLAIM, idToken.getName()); } final String logoutToken = super.processJwt(new JwtToken(claims)); executorService.submit(new Runnable() { @Override public void run() { try { wc.form(new Form().param(LOGOUT_TOKEN, logoutToken)); } catch (Exception ex) { LOG.info(String.format("Back channel request to %s to log out %s from client %s has failed", uri, subject.getLogin(), client.getClientId())); LOG.fine(String.format("%s request failure: %s", uri, ExceptionUtils.getStackTrace(ex))); } } }); }