TheOpenCloudEngine / uEngine-iam-monolithic

One of member of OCE's microservices-architecture components. Identity & Access Management conforming to OAuth2 and JWT spec and provides Web GUI for managing organizations, users, and permission scopes. REST APIs allows your application easily converted to MSA-style services accessing underlying back-end services through token-based security.
1 stars 3 forks source link

RSA JWT static method perfoermance #6

Open SeungpilPark opened 7 years ago

SeungpilPark commented 7 years ago

nimbus-jose-jwt 내부의 synchronized 메소드로 인해 멀티 쓰레드 요청시 성능 저하가 의심되는 상황.

jinyoung commented 7 years ago

해당 code 가 오디에 있나요? 한번 봐줄게요.

SeungpilPark commented 7 years ago

포시에스에서 해결해달라고 주장하는 부분:

상황:

        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
            <version>4.16.1</version>
        </dependency>

느려진다고 주장하는 부분 - nimbus-jose-jwt 내부코드의 synchronized 구간.

package com.nimbusds.jose;

import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JOSEObject;
import com.nimbusds.jose.JWSHeader;
import com.nimbusds.jose.JWSSigner;
import com.nimbusds.jose.JWSVerifier;
import com.nimbusds.jose.Payload;
import com.nimbusds.jose.util.Base64URL;
import java.nio.charset.Charset;
import java.text.ParseException;
import net.jcip.annotations.ThreadSafe;

@ThreadSafe
public class JWSObject extends JOSEObject {
.
.
    public synchronized boolean verify(JWSVerifier verifier) throws JOSEException {
        this.ensureSignedOrVerifiedState();

        boolean verified;
        try {
            verified = verifier.verify(this.getHeader(), this.getSigningInput(), this.getSignature());
        } catch (JOSEException var4) {
            throw var4;
        } catch (Exception var5) {
            throw new JOSEException(var5.getMessage(), var5);
        }

        if(verified) {
            this.state = JWSObject.State.VERIFIED;
        }

        return verified;
    }