public AnyCredential(ServiceContext serviceContext, bool legacyContext)
 {
     if (legacyContext)
     {
         core.v2_0.credential.CredentialData credential =
             UnmarshalLegacyCredential(serviceContext);
         Legacy      = true;
         Bus         = credential.bus;
         Login       = credential.login;
         Session     = credential.session;
         Ticket      = credential.ticket;
         Hash        = credential.hash;
         LegacyChain = credential.chain;
     }
     else
     {
         CredentialData credential = UnmarshalCredential(serviceContext);
         Legacy  = false;
         Bus     = credential.bus;
         Login   = credential.login;
         Session = credential.session;
         Ticket  = credential.ticket;
         Hash    = credential.hash;
         Chain   = credential.chain;
     }
 }
        public CallerChain MakeChainFor(string entity)
        {
            ConnectionImpl conn = (ConnectionImpl)GetCurrentConnection();

            if (conn == null)
            {
                Logger.Error("Não há conexão para executar a chamada MakeChainFor.");
                throw new NO_PERMISSION(NoLoginCode.ConstVal, CompletionStatus.Completed_No);
            }
            LoginInfo?myLogin = conn.Login;

            if (!myLogin.HasValue)
            {
                Logger.Error("Não há login para executar a chamada MakeChainFor.");
                throw new NO_PERMISSION(NoLoginCode.ConstVal, CompletionStatus.Completed_No);
            }

            try {
                AccessControl acs         = conn.Acs;
                SignedData    signedChain = acs.signChainFor(entity);
                CallChain     callChain   = CallerChainImpl.UnmarshalCallChain(signedChain);
                if (conn.Legacy)
                {
                    SignedCallChain legacySigned = conn.LegacyConverter.signChainFor(entity);
                    return(new CallerChainImpl(callChain.bus, callChain.caller, callChain.target,
                                               callChain.originators, signedChain, legacySigned));
                }
                return(new CallerChainImpl(callChain.bus, callChain.caller, callChain.target,
                                           callChain.originators, signedChain));
            }
            catch (GenericUserException e) {
                Logger.Error("Falha inesperada ao criar uma nova cadeia.", e);
                throw;
            }
        }
 internal CallerChainImpl(string busId, LoginInfo caller, string target,
                          LoginInfo[] originators, SignedData signed, SignedCallChain legacySigned)
     : this(busId, target)
 {
     Originators = originators;
     Caller      = caller;
     Signed      = new AnySignedChain(signed, legacySigned);
     Legacy      = false;
 }
 internal CallerChainImpl(string busId,
                          core.v2_0.services.access_control.LoginInfo caller, string target,
                          core.v2_0.services.access_control.LoginInfo[] originators,
                          SignedCallChain signed)
     : this(busId, target)
 {
     Originators = new LoginInfo[originators.Length];
     for (int i = 0; i < originators.Length; i++)
     {
         Originators[i] = new LoginInfo(originators[i].id, originators[i].entity);
     }
     Caller = new LoginInfo(caller.id, caller.entity);
     Signed = new AnySignedChain(signed);
     Legacy = true;
 }
 public AnySignedChain(SignedData signed, SignedCallChain legacy)
     : this(signed) {
     LegacyChain = legacy;
 }
 public AnySignedChain(SignedCallChain signed)
 {
     Signature   = signed.signature;
     Encoded     = signed.encoded;
     LegacyChain = signed;
 }
        internal static core.v2_0.services.access_control.CallChain UnmarshalLegacyCallChain(SignedCallChain signed)
        {
            TypeCode chainTypeCode =
                OrbServices.GetSingleton().create_tc_for_type(typeof(core.v2_0.services.access_control.CallChain));

            return((core.v2_0.services.access_control.CallChain)InterceptorsInitializer.Codec.decode_value(signed.encoded, chainTypeCode));
        }