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


Java Secret类代码示例

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


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

示例1: create

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

示例2: mapRow

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

示例3: authCode_postAuth_isOk

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

	ClientSecretPost clientAuth = new ClientSecretPost(clientId, new Secret("test-secret"));
	TokenRequest tokenRequest = new TokenRequest(URI.create("http://op.example.com"), clientAuth,
			new AuthorizationCodeGrant(authorizationCode, redirectUri));

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

	given(this.clientRepository.findById(any(ClientID.class)))
			.willReturn(client(ClientAuthenticationMethod.CLIENT_SECRET_POST));
	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

示例4: resourceOwnerPasswordCredentials_basicAuth_isOk

import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Test
public void resourceOwnerPasswordCredentials_basicAuth_isOk() throws Exception {
	ClientSecretBasic clientAuth = new ClientSecretBasic(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_BASIC));
	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)
			.header("Authorization", clientAuth.toHTTPAuthorizationHeader());
	this.mvc.perform(request).andExpect(status().isOk());
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:23,代码来源:TokenEndpointTests.java

示例5: resourceOwnerPasswordCredentials_postAuth_isOk

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

示例6: clientCredentials_basicAuth_isOk

import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Test
public void clientCredentials_basicAuth_isOk() throws Exception {
	ClientSecretBasic clientAuth = new ClientSecretBasic(new ClientID("test-client"), new Secret("test-secret"));
	TokenRequest tokenRequest = new TokenRequest(URI.create("http://op.example.com"), clientAuth,
			new ClientCredentialsGrant(), new Scope("test"));

	BearerAccessToken accessToken = new BearerAccessToken();

	given(this.clientRepository.findById(any(ClientID.class)))
			.willReturn(client(ClientAuthenticationMethod.CLIENT_SECRET_BASIC));
	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)
			.header("Authorization", clientAuth.toHTTPAuthorizationHeader());
	this.mvc.perform(request).andExpect(status().isOk());
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:20,代码来源:TokenEndpointTests.java

示例7: clientCredentials_postAuth_isOk

import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Test
public void clientCredentials_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 ClientCredentialsGrant(), new Scope("test"));

	BearerAccessToken accessToken = new BearerAccessToken();

	given(this.clientRepository.findById(any(ClientID.class)))
			.willReturn(client(ClientAuthenticationMethod.CLIENT_SECRET_POST));
	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,代码行数:19,代码来源:TokenEndpointTests.java

示例8: refreshToken_basicAuth_isOk

import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Test
public void refreshToken_basicAuth_isOk() throws Exception {
	ClientID clientId = new ClientID("test-client");

	ClientSecretBasic clientAuth = new ClientSecretBasic(clientId, new Secret("test-secret"));
	TokenRequest tokenRequest = new TokenRequest(URI.create("http://op.example.com"), clientAuth,
			new RefreshTokenGrant(new RefreshToken()));

	BearerAccessToken accessToken = new BearerAccessToken();

	given(this.clientRepository.findById(any(ClientID.class)))
			.willReturn(client(ClientAuthenticationMethod.CLIENT_SECRET_BASIC));
	given(this.tokenService.createAccessToken(any(AccessTokenRequest.class))).willReturn(accessToken);
	given(this.refreshTokenStore.load(any(RefreshToken.class))).willReturn(new RefreshTokenContext(
			new RefreshToken(), clientId, new Subject("user"), new Scope(OIDCScopeValue.OPENID), null));

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

示例9: refreshToken_postAuth_isOk

import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Test
public void refreshToken_postAuth_isOk() throws Exception {
	ClientID clientId = new ClientID("test-client");

	ClientSecretPost clientAuth = new ClientSecretPost(clientId, new Secret("test-secret"));
	TokenRequest tokenRequest = new TokenRequest(URI.create("http://op.example.com"), clientAuth,
			new RefreshTokenGrant(new RefreshToken()));

	BearerAccessToken accessToken = new BearerAccessToken();

	given(this.clientRepository.findById(any(ClientID.class)))
			.willReturn(client(ClientAuthenticationMethod.CLIENT_SECRET_POST));
	given(this.tokenService.createAccessToken(any(AccessTokenRequest.class))).willReturn(accessToken);
	given(this.refreshTokenStore.load(any(RefreshToken.class))).willReturn(new RefreshTokenContext(
			new RefreshToken(), clientId, new Subject("user"), new Scope(OIDCScopeValue.OPENID), null));

	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,代码行数:21,代码来源:TokenEndpointTests.java

示例10: Authenticator

import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
public Authenticator(State state) {
        authC = new ClientSecretBasic(new ClientID("xxxxxxxxxxxxxx"), new Secret("xxxxxxxxxxxxxx"));
        this.state = state;
        try {
            callback = new URI("https://csgf.egi.eu/c/portal/login");
//            callback = new URI("http://burns.ct.infn.it/c/portal/login");
            oauthS = new URI("https://unity.egi.eu/oauth2-as/oauth2-authz");
            tokenS = new URI("https://unity.egi.eu/oauth2/token");
            userS = new URI("https://unity.egi.eu/oauth2/userinfo");
            tokenCertSign = new URI("https://unity.egi.eu/oauth2/jwk");
            issuer = "https://unity.egi.eu/oauth2";
            aud = "unity-oauth-sg"; 
        } catch (URISyntaxException ex) {
            _log.error(ex);
        }
    }
 
开发者ID:csgf,项目名称:OpenIdConnectLiferay,代码行数:17,代码来源:Authenticator.java

示例11: setUp

import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void setUp(boolean idtoken, boolean userinfo) throws Exception {
    matcher = new AttributeInOIDCRequestedClaimsMatcher();
    final RequestContext requestCtx = new RequestContextBuilder().buildRequestContext();
    prc = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
    msgCtx = new MessageContext<AuthenticationRequest>();
    prc.setInboundMessageContext(msgCtx);
    //We use the same ctx for outbonud, outbound is olnly used here for fetching response context.
    prc.setOutboundMessageContext(msgCtx);
    OIDCAuthenticationResponseContext respCtx = new OIDCAuthenticationResponseContext();
    msgCtx.addSubcontext(respCtx);
    if (!idtoken && !userinfo) {
        msgCtx.setMessage(new AuthenticationRequest(new URI("htts://example.org"), ResponseType.getDefault(),
                new Scope("openid"), new ClientID(), new URI("htts://example.org"), new State(), new Nonce()));
        
    } else {

        msgCtx.setMessage(new AuthenticationRequest(new URI("htts://example.org"), ResponseType.getDefault(), null,
                new Scope("openid"), new ClientID(), new URI("htts://example.org"), new State(), new Nonce(), null,
                null, 0, null, null, null, null, null, getClaimsRequest(idtoken, userinfo), null, null, null, null));
        respCtx.setRequestedClaims(getClaimsRequest(idtoken, userinfo));
    }
    
    // shortcut, may break the test
    filtercontext = prc.getSubcontext(AttributeFilterContext.class, true);
    ctx = new OIDCMetadataContext();
    OIDCClientMetadata metadata = new OIDCClientMetadata();
    OIDCClientInformation information = new OIDCClientInformation(new ClientID(), new Date(), metadata,
            new Secret());
    ctx.setClientInformation(information);
    msgCtx.addSubcontext(ctx);
    attribute = new IdPAttribute("test");
    OIDCStringAttributeEncoder encoder = new OIDCStringAttributeEncoder();
    encoder.setName("test");
    encoders = new ArrayList<AttributeEncoder<?>>();
    encoders.add(encoder);
    attribute.setEncoders(encoders);
    matcher.setId("componentId");
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:40,代码来源:AttributeInOIDCRequestedClaimsMatcherTest.java

示例12: setUp

import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@BeforeMethod
protected void setUp() throws Exception {
    sector = new URI("https://example.org/uri");
    lookup = new SectorIdentifierLookupFunction();
    final RequestContext requestCtx = new RequestContextBuilder().buildRequestContext();
    prc = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
    msgCtx = new MessageContext<AuthenticationRequest>();
    prc.setInboundMessageContext(msgCtx);
    ctx = new OIDCMetadataContext();
    OIDCClientMetadata metadata= new OIDCClientMetadata();
    OIDCClientInformation information = new OIDCClientInformation(new ClientID(), new Date(), metadata, new Secret() );
    ctx.setClientInformation(information);
    msgCtx.addSubcontext(ctx);
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:16,代码来源:SectorIdentifierLookupFunctionTest.java

示例13: setClientID

import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
/**
 * Sets the client ID.
 * If the provider does not support dynamic client registration, set client ID and client secret with the client credentials received out-of-band.
 *
 * @param clientIDString the client ID string
 * @param clientSecret the client secret
 */
public void setClientID(String clientIDString, String clientSecret) {
	clientID = new ClientID(clientIDString);
	if (this.clientSecret != null && (clientSecret == null || clientSecret.isEmpty())) {
		this.clientSecret = new Secret();
	} else {
		this.clientSecret = new Secret(clientSecret);
	}
	clientInformation = new OIDCClientInformation(clientID, null, clientMetadata, this.clientSecret);
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:17,代码来源:SimpleOIDCClient.java

示例14: exchange

import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Override
public TokenResponseAttributes exchange(
    AuthorizationCodeAuthenticationToken authorizationCodeAuthenticationToken)
    throws OAuth2AuthenticationException {

    ClientRegistration clientRegistration = authorizationCodeAuthenticationToken.getClientRegistration();

    AuthorizationCode authorizationCode = new AuthorizationCode(
        authorizationCodeAuthenticationToken.getAuthorizationCode());
    AuthorizationGrant authorizationCodeGrant = new AuthorizationCodeGrant(
        authorizationCode, URI.create(clientRegistration.getRedirectUri()));
    URI tokenUri = URI.create(clientRegistration.getProviderDetails().getTokenUri());

    ClientID clientId = new ClientID(clientRegistration.getClientId());
    Secret clientSecret = new Secret(clientRegistration.getClientSecret());
    ClientAuthentication clientAuthentication = new ClientSecretGet(clientId, clientSecret);

    try {
        HTTPRequest httpRequest = createTokenRequest(
                clientRegistration, authorizationCodeGrant,
                tokenUri, clientAuthentication);

        TokenResponse tokenResponse = TokenResponse.parse(httpRequest.send());

        if (!tokenResponse.indicatesSuccess()) {
            OAuth2Error errorObject = new OAuth2Error("invalid_token_response");
            throw new OAuth2AuthenticationException(errorObject, "error");
        }

        return createTokenResponse((AccessTokenResponse) tokenResponse);

    } catch (MalformedURLException e) {
        throw new SerializeException(e.getMessage(), e);
    } catch (ParseException pe) {
        throw new OAuth2AuthenticationException(new OAuth2Error("invalid_token_response"), pe);
    } catch (IOException ioe) {
        throw new AuthenticationServiceException(
            "An error occurred while sending the Access Token Request: " +
            ioe.getMessage(), ioe);
    }

}
 
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:43,代码来源:FacebookAuthorizationGrantTokenExchanger.java

示例15: selectClientSecrets

import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Override
public List<Secret> selectClientSecrets(ClientID claimedClientID, ClientAuthenticationMethod authMethod,
		Context<OIDCClientInformation> context) throws InvalidClientException {
	OIDCClientInformation client = context.get();
	ClientAuthenticationMethod configuredAuthMethod = client.getOIDCMetadata().getTokenEndpointAuthMethod();

	if (configuredAuthMethod != null && !configuredAuthMethod.equals(authMethod)) {
		throw InvalidClientException.NOT_REGISTERED_FOR_AUTH_METHOD;
	}

	return Collections.singletonList(client.getSecret());
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:13,代码来源:ClientRequestValidator.java


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