Exemplo n.º 1
0
        internal AutenticationToken GetAutenticationToken(string token)
        {
            AutenticationToken authtoken = null;

            tokenDictionary.TryGetValue(token, out authtoken);
            return(authtoken);
        }
Exemplo n.º 2
0
 internal string AutenticateUser(Credential credential)
 {
     /* Token de teste */
     RandomNumberGenerator rng = new RNGCryptoServiceProvider();
     var tokenData = new byte[64];
     rng.GetBytes(tokenData);
     string s = Convert.ToBase64String(tokenData);
     var token = new AutenticationToken(credential);
     tokenDictionary.TryAdd(s, token);
     return s;
 }
Exemplo n.º 3
0
        internal string AutenticateUser(Credential credential)
        {
            /* Token de teste */
            RandomNumberGenerator rng = new RNGCryptoServiceProvider();
            var tokenData             = new byte[64];

            rng.GetBytes(tokenData);
            string s     = Convert.ToBase64String(tokenData);
            var    token = new AutenticationToken(credential);

            tokenDictionary.TryAdd(s, token);
            return(s);
        }
Exemplo n.º 4
0
        private bool IsAuthorized(string method, string resource)
        {
            string            token   = null;
            MessageProperties msgProp = OperationContext.Current.IncomingMessageProperties;
            var ctxProperty           = msgProp[ContextMessageProperty.Name] as ContextMessageProperty;

            if (ctxProperty.Context.ContainsKey("AccessToken"))
            {
                token = ctxProperty.Context["AccessToken"];
                AutenticationToken authToken = authProvider.GetAutenticationToken(token);

                if (authToken == null || authToken.expire < DateTime.Now)
                {
                    return(false);
                }

                return(PdpUserProvider.IsAutorized(authToken.credential.user, method, resource));
            }
            return(false);
        }