public override GenericXmlSecurityToken GetToken ( CardSpacePolicyElement [] policyChain, SecurityTokenSerializer serializer) { NativeGenericXmlToken token; NativeInfocardCryptoHandle proof; NativePolicyElement [] natives = new NativePolicyElement [policyChain.Length]; for (int i = 0; i < policyChain.Length; i++) natives [i] = new NativePolicyElement ( policyChain [i].Target, policyChain [i].Issuer, policyChain [i].Parameters, policyChain [i].PolicyNoticeLink, policyChain [i].PolicyNoticeVersion, policyChain [i].IsManagedIssuer); int hresult = GetToken (policyChain.Length, natives, out token, out proof); NativeGetTokenResults ret = (NativeGetTokenResults) (hresult & 0xCFFFFFFF); switch (ret) { case NativeGetTokenResults.OK: return token.ToObject (proof, serializer); case NativeGetTokenResults.UserCancelled: throw new UserCancellationException (); case NativeGetTokenResults.InvalidPolicy: throw new PolicyValidationException (); case NativeGetTokenResults.ServiceBusy: throw new ServiceBusyException (); case NativeGetTokenResults.ServiceUnavailable: throw new ServiceNotStartedException (); case NativeGetTokenResults.IdentityVerificationFailed: case NativeGetTokenResults.InvalidDecryptionKey: throw new IdentityValidationException (); case NativeGetTokenResults.ErrorOnCommunication: throw new StsCommunicationException (); case NativeGetTokenResults.UntrustedRecipient: throw new UntrustedRecipientException (); case NativeGetTokenResults.UnsupportedPolicy: throw new UnsupportedPolicyOptionsException (); case NativeGetTokenResults.ErrorOnDataAccess: case NativeGetTokenResults.ErrorOnExport: case NativeGetTokenResults.ErrorOnImport: case NativeGetTokenResults.InvalidArgument: case NativeGetTokenResults.ErrorInRequest: case NativeGetTokenResults.ErrorInCardData: case NativeGetTokenResults.InvalidCertificateLogo: case NativeGetTokenResults.InvalidPassword: case NativeGetTokenResults.ProcessDied: case NativeGetTokenResults.Shuttingdown: case NativeGetTokenResults.ErrorOnTokenCreation: case NativeGetTokenResults.TrustExchangeFailure: case NativeGetTokenResults.ErrorOnStoreImport: case NativeGetTokenResults.UIStartFailure: case NativeGetTokenResults.MaxSession: case NativeGetTokenResults.ImportFileAccessFailure: case NativeGetTokenResults.MalformedRequest: case NativeGetTokenResults.RefreshRequired: case NativeGetTokenResults.MissingAppliesTo: case NativeGetTokenResults.UnknownReference: case NativeGetTokenResults.InvalidProofKey: case NativeGetTokenResults.ClaimsNotProvided: default: throw CardspaceError (ret); } }
static extern int GetToken (int cPolicyChain, NativePolicyElement [] pPolicyChain, out NativeGenericXmlToken securityToken, out NativeInfocardCryptoHandle phProofTokenCrypto);