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


Java ParseException类代码示例

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


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

示例1: doPreExecute

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected boolean doPreExecute(@SuppressWarnings("rawtypes") @Nonnull final ProfileRequestContext profileRequestContext) {

    if (!super.doPreExecute(profileRequestContext)) {
        return false;
    }
    if (getOidcResponseContext().getIDToken() == null) {
        log.error("{} No id token available", getLogPrefix());
        ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MSG_CTX);
        return false;
    }
    try {
        idTokenClaims = getOidcResponseContext().getIDToken().toJWTClaimsSet();
    } catch (ParseException e) {
        log.error("{} id token parsing failed {}", getLogPrefix(), e.getMessage());
        ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MSG_CTX);
        return false;
    }
    return true;
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:22,代码来源:SignIDToken.java

示例2: parse

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected OIDCProviderMetadata parse(byte[] bytes) throws ParseException {
    final OIDCProviderMetadata result = OIDCProviderMetadata.parse(JSONObjectUtils.parse(new String(bytes)));
    final JSONObject jsonResult = result.toJSONObject();
    for (final String key : dynamicResolvers.keySet()) {
        log.debug("Starting to resolve value for {}", key);
        final RefreshableMetadataValueResolver resolver = dynamicResolvers.get(key);
        try {
            resolver.refresh();
            final Object value = resolver.resolveSingle(null);
            if (value != null) {
                jsonResult.put(key, value);
                log.debug("The field {} updated to the result", key);
            }
        } catch (ResolverException e) {
            log.warn("Could not resolve a value for {̛}, ignoring it.", key, e);
        }
    }
    return OIDCProviderMetadata.parse(jsonResult);
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:22,代码来源:DynamicFilesystemProviderMetadataResolver.java

示例3: init

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private void init(String request) throws ParseException, ComponentInitializationException {
    AuthenticationRequest req = AuthenticationRequest.parse(request);
    requestCtx = new RequestContextBuilder().setInboundMessage(req).buildRequestContext();
    ProfileRequestContext prc = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
    authnCtx = prc.getSubcontext(AuthenticationContext.class, true);
    List<AuthenticationResult> results = new ArrayList<AuthenticationResult>();
    Subject subject1 = new Subject();
    AuthenticationResult result1 = new AuthenticationResult("id1", subject1);
    // 10 seconds ago
    result1.setAuthenticationInstant(new Date().getTime() - 10000);
    Subject subject2 = new Subject();
    AuthenticationResult result2 = new AuthenticationResult("id2", subject2);
    // 5 seconds ago
    result2.setAuthenticationInstant(new Date().getTime() - 5000);
    results.add(result1);
    results.add(result2);
    authnCtx.setActiveResults(results);
    action = new FilterActiveAuthenticationResultsByMaxAge();
    action.initialize();
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:22,代码来源:FilterActiveAuthenticationResultsByMaxAgeTest.java

示例4: retrieveProviderMetadata

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
/**
	 * Retrieve provider metadata.
	 * Provider configuration information
	 * Obtaining the provider configuration information can be done either out-of-band or using the optional discovery process:
	 *
	 * @throws IOException Signals that an I/O exception has occurred.
	 * @throws ParseException the parse exception
	 * @throws KeyStoreException
	 * @throws CertificateException
	 * @throws NoSuchAlgorithmException
	 * @throws KeyManagementException
	 */
	public void retrieveProviderMetadata() throws IOException, ParseException, KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException {
		
		URL providerConfigurationURL = issuerURI.resolve(URLPATH_WELL_KNOWN_OPENID).toURL();
//		System.out.println(providerConfigurationURL);
		URLConnection conn = providerConfigurationURL.openConnection();

		if (trustStoreFile != null) {
			Trust.trustSpecific((HttpsURLConnection) conn, trustStoreFile);
		}
		InputStream stream = conn.getInputStream();
		// Read all data from URL
		String providerInfo = null;
		try (java.util.Scanner s = new java.util.Scanner(stream)) {
			providerInfo = s.useDelimiter("\\A").hasNext() ? s.next() : "";
		}
		setProviderMetadata(OIDCProviderMetadata.parse(providerInfo));
	}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:30,代码来源:SimpleOIDCClient.java

示例5: dumpTokenInfo

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
/**
 * Dump token info.
 *
 * @throws ParseException the parse exception
 * @throws java.text.ParseException
 */
public void dumpTokenInfo() throws ParseException, java.text.ParseException {
	System.out.println("Access Token:");
	System.out.println(accessToken);

	System.out.println("ID Token:");
	System.out.println(idToken);

	if (idToken != null) {
		idClaims = verifyIdToken();
		Map<String, Object> allClaims = idClaims.getClaims();
		for (Iterator<String> iterator = allClaims.keySet().iterator(); iterator.hasNext();) {
			String claimKey = (String) iterator.next();
			System.out.println(claimKey + ":" + allClaims.get(claimKey));
		}
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:23,代码来源:SimpleOIDCClient.java

示例6: init

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
/**
 * Initiates the authorization process by setting the necessary URIs and data to the OIDC client and preparing the URLProcessor.
 * 
 * @throws URISyntaxException
 * @throws IOException
 * @throws ParseException
 * @throws KeyStoreException 
 * @throws CertificateException 
 * @throws NoSuchAlgorithmException 
 * @throws KeyManagementException 
 */
public void init() throws URISyntaxException, IOException, KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException {
	
	this.getOIDCClient();
	//oidcClient.reset();
	urlProcessor = new URLProcessor();

	oidcClient.setIssuerURI(getIssuerURI());
	try {
		oidcClient.retrieveProviderMetadata();
		oidcClient.setClientMetadata(getResourceURI());
	} catch (ParseException e) {
		throw new IOException("OIDC ParseException");
	}
	oidcClient.setClientID(getClientID(), getClientSecret());
	oidcClient.setRedirectURI(getResourceURI());
	urlProcessor.prepare(oidcClient.getRedirectURI().toURL());
	inited = true;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:30,代码来源:OIDCAuthorization.java

示例7: mapRow

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
@Override
public OIDCClientInformation mapRow(ResultSet rs, int rowNum) throws SQLException {
	try {
		String id = rs.getString("id");
		Date issueDate = rs.getTimestamp("issue_date");
		String metadata = rs.getString("metadata");
		String secret = rs.getString("secret");
		String registrationUri = rs.getString("registration_uri");
		String accessToken = rs.getString("access_token");

		return new OIDCClientInformation(new ClientID(id), issueDate,
				OIDCClientMetadata.parse(JSONObjectUtils.parse(metadata)),
				(secret != null) ? new Secret(secret) : null,
				(registrationUri != null) ? URI.create(registrationUri) : null,
				(accessToken != null) ? new BearerAccessToken(accessToken) : null);
	}
	catch (ParseException e) {
		throw new TypeMismatchDataAccessException(e.getMessage(), e);
	}
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:21,代码来源:JdbcClientRepository.java

示例8: getLogoutPrompt

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
@GetMapping
public void getLogoutPrompt(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
	if (request.getQueryString() != null) {
		HTTPRequest httpRequest = ServletUtils.createHTTPRequest(request);

		try {
			LogoutRequest logoutRequest = LogoutRequest.parse(httpRequest.getQuery());
			request.setAttribute("redirectUri", logoutRequest.getPostLogoutRedirectionURI());
			request.setAttribute("state", logoutRequest.getState());
		}
		catch (ParseException ignored) {
		}
	}

	request.getRequestDispatcher("/logout").forward(request, response);
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:18,代码来源:EndSessionEndpoint.java

示例9: resolveAuthRequest

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
private AuthenticationRequest resolveAuthRequest(HttpServletRequest request)
		throws GeneralException, NonRedirectingException {
	AuthenticationRequest authRequest;

	try {
		authRequest = AuthenticationRequest.parse(request.getQueryString());
	}
	catch (ParseException e) {
		ClientID clientId = e.getClientID();
		URI redirectUri = e.getRedirectionURI();

		if (clientId == null || redirectUri == null) {
			throw new NonRedirectingException(e.getErrorObject());
		}

		OIDCClientInformation client = resolveClient(clientId);
		validateRedirectionURI(redirectUri, client.getOIDCMetadata());

		throw e;
	}

	return authRequest;
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:24,代码来源:AuthorizationEndpoint.java

示例10: getIdTokenClaims

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
protected JWTClaimsSet getIdTokenClaims(@Nonnull ClientID clientId, @Nullable Nonce nonce,
		@Nullable AccessTokenHash atHash, @Nullable CodeHash cHash) throws ParseException {
	UserInfo ui = getUserInfo();

	JWTClaimsSet.Builder cb = new JWTClaimsSet.Builder(ui.toJWTClaimsSet());

	cb.issuer(getTokenIssuer().getValue());
	cb.audience(getTokenAudience(clientId));
	cb.issueTime(getTokenIssuedAt());
	cb.expirationTime(getTokenExpiration());

	if (nonce != null) {
		cb.claim("nonce", nonce.getValue());
	}
	if (atHash != null) {
		cb.claim("at_hash", atHash.getValue());
	}
	if (cHash != null) {
		cb.claim("c_hash", cHash.getValue());
	}

	JWTClaimsSet claims = cb.build();
	return claims;
}
 
开发者ID:RUB-NDS,项目名称:PrOfESSOS,代码行数:25,代码来源:AbstractOPImplementation.java

示例11: getIdToken

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
protected JWT getIdToken(@Nonnull ClientID clientId, @Nullable Nonce nonce, @Nullable AccessTokenHash atHash,
		@Nullable CodeHash cHash) throws GeneralSecurityException, JOSEException, ParseException {
	JWTClaimsSet claims = getIdTokenClaims(clientId, nonce, atHash, cHash);

	RSAKey key = getSigningJwk();

	JWSHeader.Builder headerBuilder = new JWSHeader.Builder(JWSAlgorithm.RS256)
			.type(JOSEObjectType.JWT);
	if (params.getBool(INCLUDE_SIGNING_CERT)) {
		headerBuilder = headerBuilder.jwk(key.toPublicJWK());
	}
	JWSHeader header = headerBuilder.build();

	SignedJWT signedJwt = new SignedJWT(header, claims);

	JWSSigner signer = new RSASSASigner(key);
	signedJwt.sign(signer);

	return signedJwt;
}
 
开发者ID:RUB-NDS,项目名称:PrOfESSOS,代码行数:21,代码来源:AbstractOPImplementation.java

示例12: providerConfiguration

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
@Override
public void providerConfiguration(RequestPath path, HttpServletRequest req, HttpServletResponse resp) throws IOException {
	logger.log("Provider configuration requested.");
	logger.logHttpRequest(req, null);
	try {
		OIDCProviderMetadata md = getDefaultOPMetadata();
		String mdStr = md.toJSONObject().toString();

		resp.setContentType("application/json");
		resp.getWriter().write(mdStr);

		resp.flushBuffer();
		logger.log("Returning default provider config.");
		logger.logHttpResponse(resp, mdStr);
	} catch (IOException | ParseException ex) {
		logger.log("Failed to process default provider config.", ex);
		resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
		resp.flushBuffer();
		logger.logHttpResponse(resp, null);
	}
}
 
开发者ID:RUB-NDS,项目名称:PrOfESSOS,代码行数:22,代码来源:DefaultOP.java

示例13: userInfoRequest

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
@Override
public void userInfoRequest(RequestPath path, HttpServletRequest req, HttpServletResponse resp) throws IOException {
	try {
		logger.log("User Info requested.");

		HTTPRequest httpReq = ServletUtils.createHTTPRequest(req);
		UserInfoRequest userReq = UserInfoRequest.parse(httpReq);
		logger.logHttpRequest(req, httpReq.getQuery());
		
		UserInfoSuccessResponse uiResp = userInfoRequestInt(userReq, resp);
		if (uiResp != null) {
			sendResponse("User Info", uiResp, resp);
		}
	} catch (ParseException ex) {
		logger.log("Error parsing User Info Request.", ex);
		ErrorObject error = ex.getErrorObject();
		BearerTokenError be = new BearerTokenError(error.getCode(), error.getDescription(), error.getHTTPStatusCode());
		UserInfoErrorResponse errorResp = new UserInfoErrorResponse(be);
		sendErrorResponse("User Info", errorResp, resp);
	}
}
 
开发者ID:RUB-NDS,项目名称:PrOfESSOS,代码行数:22,代码来源:DefaultOP.java

示例14: updateUserInfo

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
public Principal updateUserInfo(URI userInfoEndpoint, IDTokenClaimsSet idToken, BearerAccessToken accessToken)
    throws IOException, ParseException, OIDCException, XWikiException, QueryException
{
    // Get OIDC user info
    UserInfoRequest userinfoRequest = new UserInfoRequest(userInfoEndpoint, accessToken);
    HTTPRequest userinfoHTTP = userinfoRequest.toHTTPRequest();
    userinfoHTTP.setHeader("User-Agent", this.getClass().getPackage().getImplementationTitle() + '/'
        + this.getClass().getPackage().getImplementationVersion());
    HTTPResponse httpResponse = userinfoHTTP.send();
    UserInfoResponse userinfoResponse = UserInfoResponse.parse(httpResponse);

    if (!userinfoResponse.indicatesSuccess()) {
        UserInfoErrorResponse error = (UserInfoErrorResponse) userinfoResponse;
        throw new OIDCException("Failed to get user info", error.getErrorObject());
    }

    UserInfoSuccessResponse userinfoSuccessResponse = (UserInfoSuccessResponse) userinfoResponse;
    UserInfo userInfo = userinfoSuccessResponse.getUserInfo();

    // Update/Create XWiki user
    return updateUser(idToken, userInfo);
}
 
开发者ID:xwiki-contrib,项目名称:oidc,代码行数:23,代码来源:OIDCUserManager.java

示例15: getProviderRSAKey

import com.nimbusds.oauth2.sdk.ParseException; //导入依赖的package包/类
private JSONObject getProviderRSAKey(InputStream is){
    StringBuilder sb = new StringBuilder();
    Scanner scanner = new Scanner(is);
    while(scanner.hasNext()){
       sb.append(scanner.next());
    }
    
    String jString = sb.toString();
    
    try {
        JSONObject json = JSONObjectUtils.parse(jString);
        JSONArray keyList = (JSONArray) json.get("keys");
        
        for(Object key: keyList){
            JSONObject obj = (JSONObject) key;
            if(obj.get("use").equals("sig") && obj.get("kty").equals("RSA")){
                return obj;
            }
        }
    } catch (ParseException ex) {
        _log.error(ex);
    }
    
    return null;
}
 
开发者ID:csgf,项目名称:OpenIdConnectLiferay,代码行数:26,代码来源:Authenticator.java


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