Sign the given claims

@param claims the claims to sign
@return the created and signed JSON Web Token
516237
public SignedJWT signToken(JWTClaimsSet claims) {
        try {
            SignedJWT signedJWT = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), claims);
            signedJWT.sign(new MACSigner(this.jwtSharedSecret));
            return signedJWT;
        } catch (JOSEException e) {
            throw new RuntimeException("Error signing JSON Web Token", e);
        }
    }
518090
public static final AuthToken createAuthToken(String principal, Set<String> roles, int expiresInMillis) {
        AuthToken token = new AuthToken();
        token.setIssuedOn(new Date());
        token.setExpiresOn(new Date(System.currentTimeMillis() + expiresInMillis));
        token.setPrincipal(principal);
        token.setRoles(roles);
        signAuthToken(token);
        return token;
    }
270145
def sign_jwt(data, secret_key, expires_in, salt=None, **kw):
    
    s = itsdangerous.TimedJSONWebSignatureSerializer(secret_key=secret_key,
                                                     expires_in=expires_in,
                                                     salt=salt,
                                                      **kw)
    return s.dumps(data)
264753
private void handleClaims(String jwt) {
        try {
            if (claimsUtils == null) {
                claimsUtils = new ClaimsUtils();
            }
            this.claimsSet = claimsUtils.getJwtClaims(jwt);
        } catch (JoseException e) {
            Tr.error(tc, "ERROR_GETTING_CLAIMS_FROM_JWT_STRING", new Object[] { e.getLocalizedMessage() });
        }
    }
749070
static Claim extractClaim(String claimName, Map<String, JsonNode> tree, ObjectReader objectReader) {
        JsonNode node = tree.get(claimName);
        return claimFromNode(node, objectReader);
    }
660594
private static List<Token> createTokens(final Map<String, String> properties) {
		List<Token> tokens = new ArrayList<Token>();
		for (Entry<String, String> entry : properties.entrySet()) {
			if (entry.getKey().toLowerCase(Locale.ROOT).startsWith(FIELD_PREFIX)) {
				tokens.add(FormatPatternParser.parse(entry.getValue()));
			}
		}
		return tokens;
	}
1129963
private void convertJoseTypes(JwtClaims claimsSet) {
        //        if (claimsSet.hasClaim(Claims.address.name())) {
        //            replaceMap(Claims.address.name());
        //        }
        //        if (claimsSet.hasClaim(Claims.jwk.name())) {
        //            replaceMap(Claims.jwk.name());
        //        }
        //        if (claimsSet.hasClaim(Claims.sub_jwk.name())) {
        //            replaceMap(Claims.sub_jwk.name());
        //        }
        if (claimsSet.hasClaim("address")) {
            replaceMapWithJsonObject("address", claimsSet);
        }
        if (claimsSet.hasClaim("jwk")) {
            replaceMapWithJsonObject("jwk", claimsSet);
        }
        if (claimsSet.hasClaim("sub_jwk")) {
            replaceMapWithJsonObject("sub_jwk", claimsSet);
        }
        if (claimsSet.hasClaim("aud")) {
            convertToList("aud", claimsSet);
        }
        if (claimsSet.hasClaim("groups")) {
            convertToList("groups", claimsSet);
        }
    }
112789
def requestClaimDef(self, seqNo, signature, sender):
        
        operation = { TXN_TYPE: GET_CLAIM_DEF,
                      ORIGIN: sender,
                      REF : seqNo,
                      SIGNATURE_TYPE : signature
                    }

        req = Request(sender, operation=operation)
        return self.prepReq(req)
987896
@Override
    public Builder claim(Map<String, Object> map) throws InvalidClaimException {
        if (map == null) {
            String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIMS_ERR");// "JWT_INVALID_CLAIMS_ERR";
            throw new InvalidClaimException(err);
        }
        return copyClaimsMap(map);
        // claims.putAll(map);
        // return this;
    }
38572
public static final void signAuthToken(AuthToken token) {
        String signature = generateSignature(token);
        token.setSignature(signature);
    }
1017069
private String build(Map<String, Object> claims, Date expireTime) {
        return Jwts.builder()
                .setClaims(claims)
                .setExpiration(expireTime)
                .signWith(SignatureAlgorithm.HS512, jwtProperties.getSecret())
                .compact();
    }
1243867
public static Map claimsFromJsonObject(String jsonFormattedString) throws JoseException {
		Map claimsMap = new ConcurrentHashMap<String, Object>();

		// JSONObject jobj = JSONObject.parse(jsonFormattedString);
		Map<String, Object> jobj = org.jose4j.json.JsonUtil.parseJson(jsonFormattedString);
		Set<Entry<String, Object>> entries = jobj.entrySet();
		Iterator<Entry<String, Object>> it = entries.iterator();

		while (it.hasNext()) {
			Entry<String, Object> entry = it.next();

			String key = entry.getKey();
			Object value = entry.getValue();
			if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
				Tr.debug(tc, "Key : " + key + ", Value: " + value);
			}
			if (!isNullEmpty(key) && value != null) {
				claimsMap.put(key, value);
			}

			// JsonElement jsonElem = entry.getValue();
		}

		// claims.putAll(jobj.entrySet());

		return claimsMap;
	}
895415
@Override
    public JwtToken buildJwt() throws JwtException, InvalidBuilderException {
        // Create JWT here
        // TODO check for default claims?
        JwtConfig config = getConfig(configId);
        JwtToken jwt = new TokenImpl(this, config);

        return jwt;
    }
1201401
public static String retrieveMasterToken(String tokenSigningKey) {
        Map<String, Object> claims = new HashMap<>();

        claims.put("*", String.valueOf(READ_UPDATE));

        return Jwts.builder()
                   .setSubject("segmentstoreresource")
                   .setAudience("segmentstore")
                   .setClaims(claims)
                   .signWith(SignatureAlgorithm.HS512, tokenSigningKey.getBytes())
                   .compact();
    }
186004
public static base_responses sign(nitro_service client, dnszone resources[]) throws Exception {
		base_responses result = null;
		if (resources != null && resources.length > 0) {
			dnszone signresources[] = new dnszone[resources.length];
			for (int i=0;i<resources.length;i++){
				signresources[i] = new dnszone();
				signresources[i].zonename = resources[i].zonename;
				signresources[i].keyname = resources[i].keyname;
			}
			result = perform_operation_bulk_request(client, signresources,"sign");
		}
		return result;
	}
93754
func sign(key string, claims *ClaimSet) (string, error) {
	b, err := json.Marshal(defaultHeader)
	if err != nil {
		return "", err
	}
	header := base64.RawURLEncoding.EncodeToString(b)

	jsonClaims, err := json.Marshal(claims)
	if err != nil {
		return "", err
	}
	encodedClaims := strings.TrimRight(base64.URLEncoding.EncodeToString(jsonClaims), "=")

	ss := fmt.Sprintf("%s.%s", header, encodedClaims)

	mac := hmac.New(sha256.New, []byte(key))
	mac.Write([]byte(ss))
	signature := mac.Sum(nil)

	return fmt.Sprintf("%s.%s", ss, base64.RawURLEncoding.EncodeToString(signature)), nil
}
742700
@Override
    public Builder claimFrom(JwtToken jwt, String claimName) throws InvalidClaimException, InvalidTokenException {
        isValidToken(jwt);
        if (JwtUtils.isNullEmpty(claimName)) {
            String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_ERR", new Object[] { claimName });
            throw new InvalidClaimException(err);
        }
        if (jwt.getClaims().get(claimName) != null) {
            claims.put(claimName, jwt.getClaims().get(claimName));
        }
        // else {
        // String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_VALUE_ERR", new
        // Object[] { claimName, "null" });
        // throw new InvalidClaimException(err);
        // }
        return this;
    }