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


Java JwtClaims.setNotBeforeMinutesInThePast方法代码示例

本文整理汇总了Java中org.jose4j.jwt.JwtClaims.setNotBeforeMinutesInThePast方法的典型用法代码示例。如果您正苦于以下问题:Java JwtClaims.setNotBeforeMinutesInThePast方法的具体用法?Java JwtClaims.setNotBeforeMinutesInThePast怎么用?Java JwtClaims.setNotBeforeMinutesInThePast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jose4j.jwt.JwtClaims的用法示例。


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

示例1: createDefaultClaims

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
/**
 * Create a JwtClaims object with prefilled sane defaults.
 * @return JwtClaims
 */
private JwtClaims createDefaultClaims() {

  JwtClaims claims = new JwtClaims();

  claims.setIssuer(SSODataTest.DATA_ISSUER);  // who creates the token and signs it
  claims.setAudience(SSODataTest.DATA_AUDIENCE); // to whom the token is intended to be sent
  claims.setExpirationTimeMinutesInTheFuture(10); // time when the token will expire (10 minutes from now)
  claims.setGeneratedJwtId(); // a unique identifier for the token
  claims.setIssuedAtToNow();  // when the token was issued/created (now)
  claims.setNotBeforeMinutesInThePast(2); // time before which the token is not yet valid (2 minutes ago)
  claims.setSubject(SSODataTest.DATA_USER_ID); // the subject/principal is whom the token is about
  claims.setClaim(SSOData.KEY_INSTANCE_ID, SSODataTest.DATA_INSTANCE_ID); // additional claims/attributes about the subject can be added

  return claims;
}
 
开发者ID:Staffbase,项目名称:plugins-sdk-java,代码行数:20,代码来源:SSOFacadeTest.java

示例2: testMissingIATCLaim

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
/**
 * Test proper signed token missing mandatory iat claim.
 * @throws JoseException
 */
@Test(expected=SSOException.class)
public void testMissingIATCLaim() throws JoseException, SSOException {

  RsaJsonWebKey jwk = this.generateRsaJwk();
  JwtClaims claims = this.createMalformedClaims();

  claims.setExpirationTimeMinutesInTheFuture(10);
  //claims.setIssuedAtToNow();
  claims.setNotBeforeMinutesInThePast(2);

  String jwt = this.createSignedTokenFromClaims(claims, jwk);

  final SSOFacade ssoFac = SSOFacade.create(jwk.getRsaPublicKey());
  ssoFac.verify(jwt);
}
 
开发者ID:Staffbase,项目名称:plugins-sdk-java,代码行数:20,代码来源:SSOFacadeTest.java

示例3: testMissingEXPCLaim

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
/**
 * Test proper signed token missing mandatory exp claim.
 * @throws JoseException
 */
@Test(expected=SSOException.class)
public void testMissingEXPCLaim() throws JoseException, SSOException {

  RsaJsonWebKey jwk = this.generateRsaJwk();
  JwtClaims claims = this.createMalformedClaims();

  //claims.setExpirationTimeMinutesInTheFuture(10);
  claims.setIssuedAtToNow();
  claims.setNotBeforeMinutesInThePast(2);

  String jwt = this.createSignedTokenFromClaims(claims, jwk);

  final SSOFacade ssoFac = SSOFacade.create(jwk.getRsaPublicKey());
  ssoFac.verify(jwt);
}
 
开发者ID:Staffbase,项目名称:plugins-sdk-java,代码行数:20,代码来源:SSOFacadeTest.java

示例4: testPastEXPCLaim

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
/**
 * Test proper signed token already expired.
 * @throws JoseException
 */
@Test(expected=SSOException.class)
public void testPastEXPCLaim() throws JoseException, SSOException  {

  RsaJsonWebKey jwk = this.generateRsaJwk();
  JwtClaims claims = this.createMalformedClaims();

  NumericDate exp = NumericDate.now();
  exp.addSeconds(-3600);

  claims.setExpirationTime(exp);
  claims.setIssuedAtToNow();
  claims.setNotBeforeMinutesInThePast(2);

  String jwt = this.createSignedTokenFromClaims(claims, jwk);

  final SSOFacade ssoFac = SSOFacade.create(jwk.getRsaPublicKey());
  ssoFac.verify(jwt);
 }
 
开发者ID:Staffbase,项目名称:plugins-sdk-java,代码行数:23,代码来源:SSOFacadeTest.java

示例5: createJwtClaims

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
private static JwtClaims createJwtClaims(
    List<String> audiences,
    String email,
    int expiration,
    String subject,
    int notBefore,
    String issuer) {

  JwtClaims jwtClaims = new JwtClaims();
  jwtClaims.setAudience(audiences);
  jwtClaims.setExpirationTimeMinutesInTheFuture(expiration);
  jwtClaims.setClaim("email", email);
  jwtClaims.setSubject(subject);
  jwtClaims.setNotBeforeMinutesInThePast(notBefore);
  jwtClaims.setIssuer(issuer);
  return jwtClaims;
}
 
开发者ID:cloudendpoints,项目名称:endpoints-management-java,代码行数:18,代码来源:AuthenticatorTest.java

示例6: getDefaultJwtClaims

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
/**
 * Construct a default JwtClaims
 *
 * @return JwtClaims
 */
public static JwtClaims getDefaultJwtClaims() {
    JwtConfig config = (JwtConfig) Config.getInstance().getJsonObjectConfig(JWT_CONFIG, JwtConfig.class);

    JwtClaims claims = new JwtClaims();

    claims.setIssuer(config.getIssuer());
    claims.setAudience(config.getAudience());
    claims.setExpirationTimeMinutesInTheFuture(config.getExpiredInMinutes());
    claims.setGeneratedJwtId(); // a unique identifier for the token
    claims.setIssuedAtToNow();  // when the token was issued/created (now)
    claims.setNotBeforeMinutesInThePast(2); // time before which the token is not yet valid (2 minutes ago)
    claims.setClaim("version", config.getVersion());
    return claims;

}
 
开发者ID:networknt,项目名称:light-4j,代码行数:21,代码来源:JwtHelper.java

示例7: getTestClaims

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
private static JwtClaims getTestClaims() {
    JwtClaims claims = new JwtClaims();
    claims.setIssuer("urn:com:networknt:oauth2:v1");
    claims.setAudience("urn:com.networknt");
    claims.setExpirationTimeMinutesInTheFuture(10);
    claims.setGeneratedJwtId(); // a unique identifier for the token
    claims.setIssuedAtToNow();  // when the token was issued/created (now)
    claims.setNotBeforeMinutesInThePast(2); // time before which the token is not yet valid (2 minutes ago)
    claims.setClaim("version", "1.0");

    claims.setClaim("user_id", "steve");
    claims.setClaim("user_type", "EMPLOYEE");
    claims.setClaim("client_id", "aaaaaaaa-1234-1234-1234-bbbbbbbb");
    List<String> scope = Arrays.asList("api.r", "api.w");
    claims.setStringListClaim("scope", scope); // multi-valued claims work too and will end up as a JSON array
    return claims;
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:18,代码来源:Http2ClientIT.java

示例8: generateToken

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
public String generateToken(boolean forcenew) {
	JwtClaims claims = new JwtClaims();
	claims.setClaim("appID", appId);
	claims.setClaim("userID", userId);
	if (keyId != null) {
		claims.setClaim("keyID", keyId);
	}
	claims.setExpirationTimeMinutesInTheFuture(10);
	claims.setNotBeforeMinutesInThePast(10);
	
	JsonWebSignature jws = new JsonWebSignature();
	jws.setPayload(claims.toJson());
	jws.setKey(key);
	jws.setAlgorithmHeaderValue(AlgorithmIdentifiers.HMAC_SHA256);
	// For backwards compatibility with old app secrets
	jws.setDoKeyValidation(false);
	try {
		String jwt = jws.getCompactSerialization();
		return jwt;
	} catch (JoseException e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:callstats-io,项目名称:callstats.java,代码行数:25,代码来源:TokenGeneratorHs256.java

示例9: generateToken

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
public String generateToken(boolean forcenew) {
	JwtClaims claims = new JwtClaims();
	claims.setClaim("appID", appId);
	claims.setClaim("userID", userId);
	claims.setClaim("keyID", keyId);
	claims.setExpirationTimeMinutesInTheFuture(10);
	claims.setNotBeforeMinutesInThePast(10);
	
	JsonWebSignature jws = new JsonWebSignature();
	
	jws.setKey(eCDSAPrivateKey);
	jws.setPayload(claims.toJson());
	jws.setAlgorithmHeaderValue(AlgorithmIdentifiers.ECDSA_USING_P256_CURVE_AND_SHA256);
	try {
		return jws.getCompactSerialization();
	} catch (JoseException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:callstats-io,项目名称:callstats.java,代码行数:22,代码来源:LocalTokenGenerator.java

示例10: createToken

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
@NotNull
public static String createToken(@NotNull JsonWebEncryption jwe, @NotNull User user, @NotNull NumericDate expireAt) {
  try {
    JwtClaims claims = new JwtClaims();
    claims.setExpirationTime(expireAt);
    claims.setGeneratedJwtId(); // a unique identifier for the token
    claims.setIssuedAtToNow();  // when the token was issued/created (now)
    claims.setNotBeforeMinutesInThePast(0.5f); // time before which the token is not yet valid (30 seconds ago)
    if (!user.isAnonymous()) {
      claims.setSubject(user.getUserName()); // the subject/principal is whom the token is about
      setClaim(claims, "email", user.getEmail());
      setClaim(claims, "name", user.getRealName());
      setClaim(claims, "external", user.getExternalId());
    }
    jwe.setPayload(claims.toJson());
    return jwe.getCompactSerialization();
  } catch (JoseException e) {
    throw new IllegalStateException(e);
  }
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:21,代码来源:TokenHelper.java

示例11: getJwtClaims

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
private JwtClaims getJwtClaims() {
    JwtClaims claims = new JwtClaims();
    claims.setIssuer("Issuer");  // who creates the token and signs it
    claims.setAudience("Audience"); // to whom the token is intended to be sent
    claims.setExpirationTimeMinutesInTheFuture(10); // time when the token will expire (10 minutes from now)
    claims.setGeneratedJwtId(); // a unique identifier for the token
    claims.setIssuedAtToNow();  // when the token was issued/created (now)
    claims.setNotBeforeMinutesInThePast(2); // time before which the token is not yet valid (2 minutes ago)
    claims.setSubject("subject"); // the subject/principal is whom the token is about
    claims.setClaim("email", "[email protected]"); // additional claims/attributes about the subject can be added
    return claims;
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:13,代码来源:Jose4JTest.java

示例12: getSamplePayload

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
private static String getSamplePayload() {
    JwtClaims claims = new JwtClaims();
    claims.setIssuer("issue-idp-1");
    claims.setAudience("aud-1", "aud-2");
    claims.setExpirationTimeMinutesInTheFuture(299);
    claims.setGeneratedJwtId();
    claims.setIssuedAtToNow();
    claims.setNotBeforeMinutesInThePast(2);
    claims.setSubject("johndoe");
    claims.setClaim("email","[email protected]");
    return claims.toJson();
}
 
开发者ID:gahana,项目名称:edge-jwt-sample,代码行数:13,代码来源:JWTUtil.java

示例13: getToken

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
public String getToken(TokenDTO data) {

	try {

	    ZonedDateTime expiration = ZonedDateTime.now(ZoneOffset.UTC).plus(daysOfValidity, ChronoUnit.DAYS);

	    Key key = new HmacKey(secret.getBytes("UTF-8"));

	    JwtClaims claims = new JwtClaims();
	    claims.setExpirationTime(NumericDate.fromMilliseconds(expiration.toInstant().toEpochMilli()));
	    claims.setGeneratedJwtId();
	    claims.setIssuedAtToNow();
	    claims.setNotBeforeMinutesInThePast(2);
	    claims.setSubject(data.getSubject());
	    claims.setIssuer(data.getIssuer());
	    claims.setClaim(EMAIL_KEY, data.getEmail());

	    JsonWebSignature jws = new JsonWebSignature();
	    jws.setPayload(claims.toJson());
	    jws.setKey(key);
	    jws.setAlgorithmHeaderValue(AlgorithmIdentifiers.HMAC_SHA256);

	    return jws.getCompactSerialization();

	} catch (JoseException | UnsupportedEncodingException e) {
	    throw new RuntimeException("An error occured while building a token", e);
	}

    }
 
开发者ID:tomacla,项目名称:auth-token,代码行数:30,代码来源:TokenManager.java

示例14: payload2token

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
public String payload2token(String subject, Object payload, long minutes) throws JoseException {
    JwtClaims claims = new JwtClaims();
    claims.setIssuer(TOKEN_ISSUER);
    claims.setAudience(TOKEN_AUDIENCE);
    claims.setExpirationTimeMinutesInTheFuture(minutes);
    claims.setGeneratedJwtId();
    claims.setIssuedAtToNow();
    claims.setNotBeforeMinutesInThePast(2);
    claims.setSubject(subject);
    claims.setStringClaim(CLAIM_KEY, jsonHelper.object2json(payload));

    JsonWebSignature jws = new JsonWebSignature();
    jws.setPayload(claims.toJson());

    jws.setKey(getKey());
    jws.setKeyIdHeaderValue(KEY_ID);
    jws.setAlgorithmHeaderValue(getAlgorithm());


    String token = jws.getCompactSerialization();
    if (!tokenService.contains(token)) {
        tokenService.store(token, null); //todo
    }

    return token;

}
 
开发者ID:chonglou,项目名称:itpkg,代码行数:28,代码来源:JwtHelper.java

示例15: getBaseClaims

import org.jose4j.jwt.JwtClaims; //导入方法依赖的package包/类
private JwtClaims getBaseClaims() {
    JwtClaims jwtClaims = new JwtClaims();
    jwtClaims.setGeneratedJwtId();
    jwtClaims.setExpirationTimeMinutesInTheFuture(60000);
    jwtClaims.setAudience(ENTITY_IDENTIFIER);
    jwtClaims.setIssuer(PLATFORM_IDENTIFIER);
    jwtClaims.setIssuedAtToNow();
    jwtClaims.setNotBeforeMinutesInThePast(0);
    return jwtClaims;
}
 
开发者ID:iovation,项目名称:launchkey-java,代码行数:11,代码来源:Jose4jJWTServiceTest.java


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