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


Java ClientID类代码示例

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


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

示例1: doInvoke

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doInvoke(@Nonnull final MessageContext messageContext) throws MessageHandlerException {
    ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
    // Resolve client id from inbound message
    final ClientID clientId = RequestFieldResolver.getClientID((AbstractRequest) messageContext.getMessage());
    // Resolve metadata for client id
    final ClientIDCriterion clientCriterion = new ClientIDCriterion(clientId);
    final CriteriaSet criteria = new CriteriaSet(clientCriterion);
    try {
        final OIDCClientInformation clientInformation = clientResolver.resolveSingle(criteria);
        if (clientInformation == null) {
            log.warn("{} No client information returned for {}", getLogPrefix(), clientId);
            return;
        }
        final OIDCMetadataContext oidcCtx = new OIDCMetadataContext();
        oidcCtx.setClientInformation(clientInformation);
        messageContext.addSubcontext(oidcCtx);
        // Based on that info we know 1) client is valid 2) we know valid
        // redirect uris
        log.debug("{} {} added to MessageContext as child of {}", getLogPrefix(),
                OIDCMetadataContext.class.getName(), messageContext.getClass().getName());
    } catch (ResolverException e) {
        log.error("{} ResolverException thrown during client information lookup", getLogPrefix(), e);
    }
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:27,代码来源:OIDCMetadataLookupHandler.java

示例2: getClientID

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的package包/类
/**
 * Returns client id from the request.
 * 
 * @param request
 *            oidc request
 * @return client id or null if not existing or not found
 */
public static ClientID getClientID(AbstractRequest request) {
    ClientID id = null;
    if (request instanceof TokenRequest) {
        // TODO: Why getting client id is this tedious? Find out what is going wrong
        id = ((TokenRequest) request).getClientID();
        if (id == null && ((TokenRequest) request).getClientAuthentication() != null) {
            id = ((TokenRequest) request).getClientAuthentication().getClientID();
        }
    }
    if (request instanceof AuthenticationRequest) {
        id = ((AuthenticationRequest) request).getClientID();
    }
    return id;

}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:23,代码来源:RequestFieldResolver.java

示例3: testSuccess

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的package包/类
@Test
public void testSuccess() throws Exception {
    final ClientIDCriterion criterion = new ClientIDCriterion(new ClientID(clientId));
    final OIDCClientInformation clientInfo = resolver.resolveSingle(new CriteriaSet(criterion));
    Assert.assertNotNull(clientInfo);
    Assert.assertEquals(clientInfo.getID().getValue(), clientId);
    final Set<URI> redirectUris = clientInfo.getOIDCMetadata().getRedirectionURIs();
    Assert.assertEquals(redirectUris.size(), 1);
    Assert.assertTrue(redirectUris.contains(redirectUri));
    final Scope scope = clientInfo.getOIDCMetadata().getScope();
    Assert.assertEquals(scope.size(), 6);
    Assert.assertTrue(scope.contains(OIDCScopeValue.OPENID));
    Assert.assertTrue(scope.contains(OIDCScopeValue.ADDRESS));
    Assert.assertTrue(scope.contains(OIDCScopeValue.EMAIL));
    Assert.assertTrue(scope.contains(OIDCScopeValue.PHONE));
    Assert.assertTrue(scope.contains(OIDCScopeValue.PROFILE));
    Assert.assertTrue(scope.contains("info"));
    final Set<ResponseType> responseTypes = clientInfo.getOIDCMetadata().getResponseTypes();
    Assert.assertEquals(responseTypes.size(), 2);
    Assert.assertTrue(responseTypes.contains(new ResponseType(OIDCResponseTypeValue.ID_TOKEN)));
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:22,代码来源:FilesystemClientInformationResolverTest.java

示例4: createRefreshToken

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的package包/类
@Override
public RefreshToken createRefreshToken(RefreshTokenRequest refreshTokenRequest) {
	Instant now = Instant.now();
	ClientID clientId = refreshTokenRequest.getClientId();
	Subject subject = refreshTokenRequest.getSubject();
	Scope scope = refreshTokenRequest.getScope();

	RefreshTokenContext context = this.refreshTokenStore.findByClientIdAndSubject(clientId, subject);

	if (context == null || !SetUtils.isEqualSet(context.getScope(), scope)) {
		if (context != null) {
			this.refreshTokenStore.revoke(context.getRefreshToken());
		}
		Instant expiry = (!this.refreshTokenLifetime.isZero() && !this.refreshTokenLifetime.isNegative())
				? now.plus(this.refreshTokenLifetime)
				: null;
		context = new RefreshTokenContext(new RefreshToken(), clientId, subject, scope, expiry);
		this.refreshTokenStore.save(context);
	}

	return context.getRefreshToken();
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:23,代码来源:DefaultTokenService.java

示例5: create

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的package包/类
@Override
public OIDCClientInformation create(OIDCClientMetadata metadata, boolean dynamicRegistration) {
	metadata.applyDefaults();
	ClientID id = new ClientID(UUID.randomUUID().toString());
	Instant issueDate = Instant.now();
	Secret secret = isTokenEndpointAuthEnabled(metadata) ? new Secret() : null;
	URI registrationUri = dynamicRegistration
			? URI.create(this.registrationUriTemplate.replace("{id}", id.getValue()))
			: null;
	BearerAccessToken accessToken = dynamicRegistration ? new BearerAccessToken() : null;

	OIDCClientInformation client = new OIDCClientInformation(id, Date.from(issueDate), metadata, secret,
			registrationUri, accessToken);
	this.clientRepository.save(client);

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

示例6: mapRow

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的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

示例7: AuthorizationCodeContext

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的package包/类
public AuthorizationCodeContext(Subject subject, ClientID clientId, URI redirectUri, Scope scope,
		Instant authenticationTime, ACR acr, AMR amr, SessionID sessionId, CodeChallenge codeChallenge,
		CodeChallengeMethod codeChallengeMethod, Nonce nonce) {
	Objects.requireNonNull(subject, "subject must not be null");
	Objects.requireNonNull(clientId, "clientId must not be null");
	Objects.requireNonNull(redirectUri, "redirectUri must not be null");
	Objects.requireNonNull(scope, "scope must not be null");
	Objects.requireNonNull(authenticationTime, "authenticationTime must not be null");
	Objects.requireNonNull(acr, "acr must not be null");
	Objects.requireNonNull(amr, "amr must not be null");
	Objects.requireNonNull(sessionId, "sessionId must not be null");
	this.subject = subject;
	this.clientId = clientId;
	this.redirectUri = redirectUri;
	this.scope = scope;
	this.authenticationTime = authenticationTime;
	this.acr = acr;
	this.amr = amr;
	this.sessionId = sessionId;
	this.codeChallenge = codeChallenge;
	this.codeChallengeMethod = codeChallengeMethod;
	this.nonce = nonce;
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:24,代码来源:AuthorizationCodeContext.java

示例8: grant

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的package包/类
@Override
public Tokens grant(TokenRequest tokenRequest) throws GeneralException {
	if (!(tokenRequest.getAuthorizationGrant() instanceof RefreshTokenGrant)) {
		throw new GeneralException(OAuth2Error.UNSUPPORTED_GRANT_TYPE);
	}

	RefreshToken refreshToken = ((RefreshTokenGrant) tokenRequest.getAuthorizationGrant()).getRefreshToken();
	RefreshTokenContext context = this.refreshTokenStore.load(refreshToken);

	Subject subject = context.getSubject();
	ClientID clientId = context.getClientId();
	Scope originalScope = context.getScope();

	OIDCClientInformation client = this.clientRepository.findById(clientId);
	AccessTokenRequest accessTokenRequest = new AccessTokenRequest(subject, client, originalScope);
	AccessToken accessToken = this.tokenService.createAccessToken(accessTokenRequest);
	RefreshToken updatedRefreshToken = null;

	if (this.updateRefreshToken) {
		this.refreshTokenStore.revoke(refreshToken);
		RefreshTokenRequest refreshTokenRequest = new RefreshTokenRequest(subject, clientId, originalScope);
		updatedRefreshToken = this.tokenService.createRefreshToken(refreshTokenRequest);
	}

	return new Tokens(accessToken, updatedRefreshToken);
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:27,代码来源:RefreshTokenGrantHandler.java

示例9: findByClientIdAndSubject

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的package包/类
@Override
public RefreshTokenContext findByClientIdAndSubject(ClientID clientId, Subject subject) {
	Objects.requireNonNull(clientId, "clientId must not be null");
	Objects.requireNonNull(subject, "subject must not be null");
	RefreshTokenContext result = null;
	for (Map.Entry<RefreshToken, RefreshTokenContext> entry : this.refreshTokens.entrySet()) {
		RefreshTokenContext context = entry.getValue();
		if (clientId.equals(context.getClientId()) && subject.equals(context.getSubject())) {
			if (context.isExpired()) {
				this.refreshTokens.remove(context.getRefreshToken());
			}
			else {
				result = context;
			}
		}
	}
	return result;
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:19,代码来源:InMemoryRefreshTokenStore.java

示例10: findByClientIdAndSubject

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的package包/类
@Override
@Transactional
public RefreshTokenContext findByClientIdAndSubject(ClientID clientId, Subject subject) {
	Objects.requireNonNull(clientId, "clientId must not be null");
	Objects.requireNonNull(subject, "subject must not be null");
	try {
		RefreshTokenContext context = this.jdbcOperations.queryForObject(this.statementSelectByClientIdAndSubject,
				refreshTokenContextMapper, clientId.getValue(), subject.getValue());
		if (context.isExpired()) {
			this.jdbcOperations.update(this.statementDeleteByToken,
					ps -> ps.setString(1, context.getRefreshToken().getValue()));
			return null;
		}
		return context;
	}
	catch (EmptyResultDataAccessException e) {
		return null;
	}
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:20,代码来源:JdbcRefreshTokenStore.java

示例11: resourceOwnerPasswordCredentials_postAuth_isOk

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的package包/类
@Test
public void resourceOwnerPasswordCredentials_postAuth_isOk() throws Exception {
	ClientSecretPost clientAuth = new ClientSecretPost(new ClientID("test-client"), new Secret("test-secret"));
	TokenRequest tokenRequest = new TokenRequest(URI.create("http://op.example.com"), clientAuth,
			new ResourceOwnerPasswordCredentialsGrant("user", new Secret("password")),
			new Scope(OIDCScopeValue.OPENID));

	BearerAccessToken accessToken = new BearerAccessToken();

	given(this.clientRepository.findById(any(ClientID.class)))
			.willReturn(client(ClientAuthenticationMethod.CLIENT_SECRET_POST));
	given(this.authenticationHandler.authenticate(any(ResourceOwnerPasswordCredentialsGrant.class)))
			.willReturn(new Subject("user"));
	given(this.scopeResolver.resolve(any(Subject.class), any(Scope.class), any(OIDCClientMetadata.class)))
			.willAnswer(returnsSecondArg());
	given(this.tokenService.createAccessToken(any(AccessTokenRequest.class))).willReturn(accessToken);

	MockHttpServletRequestBuilder request = post("/oauth2/token").content(tokenRequest.toHTTPRequest().getQuery())
			.contentType(MediaType.APPLICATION_FORM_URLENCODED);
	this.mvc.perform(request).andExpect(status().isOk());
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:22,代码来源:TokenEndpointTests.java

示例12: authCode_pkceS256_isOk

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的package包/类
@Test
public void authCode_pkceS256_isOk() throws Exception {
	ClientID clientId = new ClientID("test-client");
	URI redirectUri = URI.create("http://rp.example.com");
	CodeVerifier codeVerifier = new CodeVerifier();
	CodeChallengeMethod codeChallengeMethod = CodeChallengeMethod.S256;
	AuthorizationCode authorizationCode = new AuthorizationCode();

	TokenRequest tokenRequest = new TokenRequest(URI.create("http://op.example.com"), clientId,
			new AuthorizationCodeGrant(authorizationCode, URI.create("http://rp.example.com"), codeVerifier));

	AuthorizationCodeContext context = new AuthorizationCodeContext(new Subject("user"), clientId, redirectUri,
			new Scope(OIDCScopeValue.OPENID), Instant.now(), new ACR("1"), AMR.PWD, new SessionID("test"),
			CodeChallenge.compute(codeChallengeMethod, codeVerifier), codeChallengeMethod, null);
	BearerAccessToken accessToken = new BearerAccessToken();
	JWT idToken = new PlainJWT(new JWTClaimsSet.Builder().build());

	given(this.clientRepository.findById(any(ClientID.class))).willReturn(client(ClientAuthenticationMethod.NONE));
	given(this.authorizationCodeService.consume(eq(authorizationCode))).willReturn(context);
	given(this.tokenService.createAccessToken(any(AccessTokenRequest.class))).willReturn(accessToken);
	given(this.tokenService.createIdToken(any(IdTokenRequest.class))).willReturn(idToken);

	MockHttpServletRequestBuilder request = post("/oauth2/token").content(tokenRequest.toHTTPRequest().getQuery())
			.contentType(MediaType.APPLICATION_FORM_URLENCODED);
	this.mvc.perform(request).andExpect(status().isOk());
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:27,代码来源:TokenEndpointTests.java

示例13: deleteClientConfiguration

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的package包/类
@DeleteMapping(path = "/{id:.*}")
public void deleteClientConfiguration(HttpServletRequest request, HttpServletResponse response,
		@PathVariable ClientID id) throws IOException {
	HTTPRequest httpRequest = ServletUtils.createHTTPRequest(request);

	try {
		ClientDeleteRequest clientDeleteRequest = ClientDeleteRequest.parse(httpRequest);
		resolveAndValidateClient(id, clientDeleteRequest);

		this.clientRepository.deleteById(id);

		response.setStatus(HttpServletResponse.SC_NO_CONTENT);
	}
	catch (GeneralException e) {
		ClientRegistrationResponse registrationResponse = new ClientRegistrationErrorResponse(e.getErrorObject());
		ServletUtils.applyHTTPResponse(registrationResponse.toHTTPResponse(), response);
	}
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:19,代码来源:ClientRegistrationEndpoint.java

示例14: resolveAndValidateClient

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的package包/类
private OIDCClientInformation resolveAndValidateClient(ClientID clientId, ProtectedResourceRequest request)
		throws GeneralException {
	OIDCClientInformation client = this.clientRepository.findById(clientId);

	if (client != null) {
		AccessToken requestAccessToken = request.getAccessToken();
		BearerAccessToken registrationAccessToken = client.getRegistrationAccessToken();
		BearerAccessToken apiAccessToken = this.apiAccessToken;

		if (requestAccessToken.equals(registrationAccessToken) || requestAccessToken.equals(apiAccessToken)) {
			return client;
		}
	}

	throw new GeneralException(BearerTokenError.INVALID_TOKEN);
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:17,代码来源:ClientRegistrationEndpoint.java

示例15: resolveAuthRequest

import com.nimbusds.oauth2.sdk.id.ClientID; //导入依赖的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


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