検索

質問
· 2026年1月15日

VsCode error to create a new class definition.

Anyone else is passing through this issue?

Since last week when I create a new class definition, It is created without the full name into the signature class and I have to put it by myself.

I thougth that should be any configuration about the language patterns, but I didn`t found it.



Thank you all

2件の新着コメント
ディスカッション (2)2
続けるにはログインするか新規登録を行ってください
記事
· 2026年1月15日 3m read

Generando JWT sin acceso a los certificados/keys x509 del sistema

Si queréis generar JWT a partir de un certificado/clave x509, cualquier operación (incluida la lectura) sobre %SYS.X509Credentials requiere el permiso U en el recurso %Admin_Secure. Esto se debe a que %SYS.X509Credentials es persistente y está implementado así para evitar que todos los usuarios tengan acceso a las claves privadas.

Si el recurso %Admin_Secure no está disponible en tiempo de ejecución, podéis usar la siguiente solución alternativa.

Revisándo el código de generación de JWT, descubrí que sólo utiliza %SYS.X509Credentials como fuente de datos en tiempo de ejecución para PrivateKey, PrivateKeyPasswordy Certificate. Como alternativa, podéis usar una implementación no persistente en tiempo de ejecución de la interfaz X.509, exponiendo únicamente estas propiedades.

Si estáis usando interoperabilidad, el certificado/clave privada se puede almacenar en credenciales para un acceso seguro.

Class User.X509 Extends %RegisteredObject
{

Property PrivateKey As %VarString;
Property PrivateKeyPassword As %String;
Property Certificate As %VarString;
Property HasPrivateKey As %Boolean [ InitialExpression = {$$$YES} ];
ClassMethod GetX509() As User.X509
{
    set x509 = ..%New()
    set x509.PrivateKey = ..Key()
    set x509.Certificate = ..Cert()
    quit x509
}

/// Get X509 object from credential.
/// Username is a Cert, Password is a Private Key
ClassMethod GetX509FromCredential(credential) As User.X509
{
    set credentialObj = ##class(Ens.Config.Credentials).%OpenId(credential,,.sc)
    throw:$$$ISERR(sc) ##class(%Exception.StatusException).ThrowIfInterrupt(sc)
    
    set x509 = ..%New()
    set x509.PrivateKey = credentialObj.Password
    set x509.Certificate = credentialObj.Username
    quit x509
}

ClassMethod Key()
{
    q "-----BEGIN RSA PRIVATE KEY-----"_$C(13,10)
    _"YOUR_TEST_KEY"_$C(13,10)
    _"-----END RSA PRIVATE KEY-----"
}

ClassMethod Cert() As %VarString
{
    q "-----BEGIN CERTIFICATE-----"_$C(13,10)
    _"YOUR_TEST_CERT"_$C(13,10)
    _"-----END CERTIFICATE-----"
}

}

Y podéis generar JWT de la siguiente manera:

ClassMethod JWT() As %Status
{
    Set sc = $$$OK
    //Set x509 = ##class(%SYS.X509Credentials).GetByAlias("TempKeyPair")
    Set x509 = ##class(User.X509).GetX509()
    
    Set algorithm ="RS256"
    Set header = {"alg": (algorithm), "typ": "JWT"}
    Set claims= {"Key": "Value" }
    
    #; create JWK
    Set sc = ##class(%Net.JSON.JWK).CreateX509(algorithm,x509,.privateJWK)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    #; Create JWKS
    Set sc = ##class(%Net.JSON.JWKS).PutJWK(privateJWK,.privateJWKS)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    Set sc = ##Class(%Net.JSON.JWT).Create(header,,claims,privateJWKS,,.pJWT)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }
    
    Write pJWT
	Return sc
}

Alternativamente, podéis usar un objeto dinámico para evitar crear la clase; en ese caso, se vería así:

ClassMethod JWT(credential) As %Status
{
    Set sc = $$$OK
    //Set x509 = ##class(%SYS.X509Credentials).GetByAlias("TempKeyPair")
    Set credentialObj = ##class(Ens.Config.Credentials).%OpenId(credential,,.sc)
    throw:$$$ISERR(sc) ##class(%Exception.StatusException).ThrowIfInterrupt(sc)
    
    Set x509 = {
        "HasPrivateKey": true,
        "PrivateKey": (credentialObj.Password),
        "PrivateKeyPassword":"",
        "Certificate":(credentialObj.Username)
    }

    Set algorithm ="RS256"
    Set header = {"alg": (algorithm), "typ": "JWT"}
    Set claims= {"Key": "Value" }
    
    #; create JWK
    Set sc = ##class(%Net.JSON.JWK).CreateX509(algorithm,x509,.privateJWK)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    #; Create JWKS
    Set sc = ##class(%Net.JSON.JWKS).PutJWK(privateJWK,.privateJWKS)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    Set sc = ##Class(%Net.JSON.JWT).Create(header,,claims,privateJWKS,,.pJWT)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }
    
    Write pJWT
    Return sc
}
ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
お知らせ
· 2026年1月15日

[Video] ¿Qué es el InterSystems Secure Wallet?

Hola Comunidad!

¿Necesitas un modo de almacenar de forma segura tus passwords, API keys y otras credenciales? Mira como el Secure Wallet en InterSystems IRIS® data platform te puede ayudar:

¿Qué es el InterSystems Secure Wallet?

En este video, verás como utilizar Secure Wallet para almacenar y gestionar, de forma segura, credenciales utilizadas por aplicaciones que se conectan a sistemas o fuentes de datos externas.

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
お知らせ
· 2026年1月15日

[Video] What Is the InterSystems Secure Wallet?

Hi, Community!

Do you need a way to securely manage your passwords, API keys, and other credentials? See how the Secure Wallet in InterSystems IRIS® data platform can help:

What Is the InterSystems Secure Wallet?

In this video, you will see how to use the Secure Wallet to securely store and manage sensitive credentials used by applications that connect to external systems or data sources.

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
お知らせ
· 2026年1月15日

InterSystems Community Q&A Annual Recap 2025

Hello and welcome to the 2025 Q&A Recap.
General Stats
755 questions published in 2025
9,819 questions published all time
Most Popular
Most Discussed
2025 Q&A fromInterSystems Developers
ディスカッション (0)1
続けるにはログインするか新規登録を行ってください