Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial ServiceStack-based webservice

  • Loading branch information...
commit 031a7885f334f4c3f775317a2de3db524d1e947c 1 parent 078a0ab
Jérémie Laval garuma authored
Showing with 21,957 additions and 8 deletions.
  1. +45 −0 MonkeyWrench.Web.ServiceStack/BuildBots.cs
  2. +83 −0 MonkeyWrench.Web.ServiceStack/BuildSteps.cs
  3. +110 −0 MonkeyWrench.Web.ServiceStack/Builds.cs
  4. +1 −0  MonkeyWrench.Web.ServiceStack/Global.asax
  5. +75 −0 MonkeyWrench.Web.ServiceStack/Global.asax.cs
  6. +112 −0 MonkeyWrench.Web.ServiceStack/HostBuilds.cs
  7. +91 −0 MonkeyWrench.Web.ServiceStack/LatestBuilds.cs
  8. +96 −0 MonkeyWrench.Web.ServiceStack/MonkeyWrench.Web.ServiceStack.csproj
  9. +47 −0 MonkeyWrench.Web.ServiceStack/Pocos.cs
  10. +43 −0 MonkeyWrench.Web.ServiceStack/Projects.cs
  11. +90 −0 MonkeyWrench.Web.ServiceStack/Utils.cs
  12. +29 −0 MonkeyWrench.Web.ServiceStack/WrenchAuthUserSession.cs
  13. +31 −0 MonkeyWrench.Web.ServiceStack/web.config
  14. +91 −8 MonkeyWrench.sln
  15. +15 −0 ServiceStack/src/ServiceStack.Authentication.OpenId/GoogleOpenIdOAuthProvider.cs
  16. +13 −0 ServiceStack/src/ServiceStack.Authentication.OpenId/MyOpenIdOAuthProvider.cs
  17. +311 −0 ServiceStack/src/ServiceStack.Authentication.OpenId/OpenIdOAuthProvider.cs
  18. +36 −0 ServiceStack/src/ServiceStack.Authentication.OpenId/Properties/AssemblyInfo.cs
  19. +87 −0 ServiceStack/src/ServiceStack.Authentication.OpenId/ServiceStack.Authentication.OpenId.csproj
  20. +13 −0 ServiceStack/src/ServiceStack.Authentication.OpenId/YahooOpenIdOAuthProvider.cs
  21. +4 −0 ServiceStack/src/ServiceStack.Authentication.OpenId/packages.config
  22. +96 −0 ServiceStack/src/ServiceStack.Common/ActionExecExtensions.cs
  23. +73 −0 ServiceStack/src/ServiceStack.Common/AssertExtensions.cs
  24. +20 −0 ServiceStack/src/ServiceStack.Common/ByteArrayExtensions.cs
  25. +152 −0 ServiceStack/src/ServiceStack.Common/CryptUtils.cs
  26. +63 −0 ServiceStack/src/ServiceStack.Common/DictionaryExtensions.cs
  27. +44 −0 ServiceStack/src/ServiceStack.Common/DirectoryInfoExtensions.cs
  28. +46 −0 ServiceStack/src/ServiceStack.Common/DisposableExtensions.cs
  29. +110 −0 ServiceStack/src/ServiceStack.Common/EnumExtensions.cs
  30. +121 −0 ServiceStack/src/ServiceStack.Common/EnumerableExtensions.cs
  31. +144 −0 ServiceStack/src/ServiceStack.Common/ExecExtensions.cs
  32. +72 −0 ServiceStack/src/ServiceStack.Common/Expressions/DelegateFactory.cs
  33. +54 −0 ServiceStack/src/ServiceStack.Common/Extensions/ActionExecExtensions.cs
  34. +58 −0 ServiceStack/src/ServiceStack.Common/Extensions/AssertExtensions.cs
  35. +14 −0 ServiceStack/src/ServiceStack.Common/Extensions/ByteArrayExtensions.cs
  36. +26 −0 ServiceStack/src/ServiceStack.Common/Extensions/CollectionExtensions.cs
  37. +31 −0 ServiceStack/src/ServiceStack.Common/Extensions/DictionaryExtensions.cs
  38. +127 −0 ServiceStack/src/ServiceStack.Common/Extensions/EnumerableExtensions.cs
  39. +26 −0 ServiceStack/src/ServiceStack.Common/Extensions/ITranslatorExtensions.cs
  40. +46 −0 ServiceStack/src/ServiceStack.Common/Extensions/IntExtensions.cs
  41. +75 −0 ServiceStack/src/ServiceStack.Common/Extensions/StringExtensions.cs
  42. +86 −0 ServiceStack/src/ServiceStack.Common/HostContext.cs
  43. +168 −0 ServiceStack/src/ServiceStack.Common/IPAddressExtensions.cs
  44. +72 −0 ServiceStack/src/ServiceStack.Common/IntExtensions.cs
  45. +35 −0 ServiceStack/src/ServiceStack.Common/Messaging/ClientFactory.cs
  46. +37 −0 ServiceStack/src/ServiceStack.Common/Messaging/IMessageHandler.cs
  47. +7 −0 ServiceStack/src/ServiceStack.Common/Messaging/IMessageHandlerDisposer.cs
  48. +10 −0 ServiceStack/src/ServiceStack.Common/Messaging/IMessageHandlerFactory.cs
  49. +54 −0 ServiceStack/src/ServiceStack.Common/Messaging/InMemoryMessageQueueClient.cs
  50. +74 −0 ServiceStack/src/ServiceStack.Common/Messaging/InMemoryTransientMessageFactory.cs
  51. +40 −0 ServiceStack/src/ServiceStack.Common/Messaging/InMemoryTransientMessageService.cs
  52. +98 −0 ServiceStack/src/ServiceStack.Common/Messaging/MessageExtensions.cs
  53. +212 −0 ServiceStack/src/ServiceStack.Common/Messaging/MessageHandler.cs
  54. +62 −0 ServiceStack/src/ServiceStack.Common/Messaging/MessageHandlerFactory.cs
  55. +78 −0 ServiceStack/src/ServiceStack.Common/Messaging/MessageQueueClientFactory.cs
  56. +315 −0 ServiceStack/src/ServiceStack.Common/Messaging/Rcon/Client.cs
  57. +30 −0 ServiceStack/src/ServiceStack.Common/Messaging/Rcon/Packet.cs
  58. +152 −0 ServiceStack/src/ServiceStack.Common/Messaging/Rcon/PacketCodec.cs
  59. +108 −0 ServiceStack/src/ServiceStack.Common/Messaging/Rcon/PacketProcessingClient.cs
  60. +321 −0 ServiceStack/src/ServiceStack.Common/Messaging/Rcon/Server.cs
  61. +142 −0 ServiceStack/src/ServiceStack.Common/Messaging/TransientMessageServiceBase.cs
  62. +27 −0 ServiceStack/src/ServiceStack.Common/Model.cs
  63. +13 −0 ServiceStack/src/ServiceStack.Common/ModelConfig.cs
  64. +440 −0 ServiceStack/src/ServiceStack.Common/Net30/ConcurrentDictionary.cs
  65. +237 −0 ServiceStack/src/ServiceStack.Common/Net30/ConcurrentQueue.cs
  66. +97 −0 ServiceStack/src/ServiceStack.Common/Net30/ObjectPool.cs
  67. +519 −0 ServiceStack/src/ServiceStack.Common/Net30/SplitOrderedList.cs
  68. +361 −0 ServiceStack/src/ServiceStack.Common/Net30/Tuple.cs
  69. +43 −0 ServiceStack/src/ServiceStack.Common/Properties/AssemblyInfo.cs
  70. +11 −0 ServiceStack/src/ServiceStack.Common/README.md
  71. +113 −0 ServiceStack/src/ServiceStack.Common/Reflection/PropertyAccessor.cs
  72. +173 −0 ServiceStack/src/ServiceStack.Common/Reflection/StaticAccessors.cs
  73. +154 −0 ServiceStack/src/ServiceStack.Common/ReflectionExtensions.cs
  74. +33 −0 ServiceStack/src/ServiceStack.Common/RequestContextExtensions.cs
  75. +663 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/AsyncServiceClient.cs
  76. +70 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/AuthDtos.cs
  77. +33 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/DictionaryExtensions.cs
  78. +48 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/GenericProxy.cs
  79. +16 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/HttpMethod.cs
  80. +14 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/IDuplex.cs
  81. +14 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/IDuplexCallback.cs
  82. +15 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/IOneWay.cs
  83. +15 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/ISyncReply.cs
  84. +22 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/IWcfServiceClient.cs
  85. +114 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/JsonRestClientAsync.cs
  86. +51 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/JsonServiceClient.cs
  87. +111 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/JsvRestClientAsync.cs
  88. +56 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/JsvServiceClient.cs
  89. +39 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/RouteMember.cs
  90. +1,103 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/ServiceClientBase.cs
  91. +150 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/Soap11ServiceClient.cs
  92. +68 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/Soap12ServiceClient.cs
  93. +419 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/UrlExtensions.cs
  94. +424 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/WcfServiceClient.cs
  95. +262 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/WebRequestExtensions.cs
  96. +101 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/WebRequestUtils.cs
  97. +123 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/WebServiceException.cs
  98. +273 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/XLinqExtensions.cs
  99. +113 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/XmlRestClientAsync.cs
  100. +61 −0 ServiceStack/src/ServiceStack.Common/ServiceClient.Web/XmlServiceClient.cs
  101. +47 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/DictionaryExtensions.cs
  102. +142 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/MetadataTypes.cs
  103. +80 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/Serialization/DataContractDeserializer.cs
  104. +102 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/Serialization/DataContractSerializer.cs
  105. +89 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/Serialization/JsonDataContractDeserializer.cs
  106. +75 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/Serialization/JsonDataContractSerializer.cs
  107. +41 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/Serialization/KeyValueDataContractDeserializer.cs
  108. +135 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/Serialization/StringMapTypeDeserializer.cs
  109. +73 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/Serialization/XmlSerializableDeserializer.cs
  110. +42 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/Serialization/XmlSerializableSerializer.cs
  111. +114 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/Support/XmlSerializableWrapper.cs
  112. +158 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/Validation/ValidationError.cs
  113. +34 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/Validation/ValidationErrorField.cs
  114. +128 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/Validation/ValidationErrorResult.cs
  115. +298 −0 ServiceStack/src/ServiceStack.Common/ServiceModel/XLinqExtensions.cs
  116. +499 −0 ServiceStack/src/ServiceStack.Common/ServiceStack.Common.csproj
  117. +106 −0 ServiceStack/src/ServiceStack.Common/StreamExtensions.cs
  118. +239 −0 ServiceStack/src/ServiceStack.Common/StringExtensions.cs
  119. +25 −0 ServiceStack/src/ServiceStack.Common/Support/ActionExecHandler.cs
  120. +70 −0 ServiceStack/src/ServiceStack.Common/Support/AdapterBase.cs
  121. +192 −0 ServiceStack/src/ServiceStack.Common/Support/AssignmentDefinition.cs
  122. +24 −0 ServiceStack/src/ServiceStack.Common/Support/CommandExecsHandler.cs
  123. +27 −0 ServiceStack/src/ServiceStack.Common/Support/CommandResultsHandler.cs
  124. +191 −0 ServiceStack/src/ServiceStack.Common/Support/InMemoryLogFactory.cs
  125. +143 −0 ServiceStack/src/ServiceStack.Common/Support/LogicFacadeBase.cs
  126. +38 −0 ServiceStack/src/ServiceStack.Common/Support/NetDeflateProvider.cs
  127. +37 −0 ServiceStack/src/ServiceStack.Common/Support/NetGZipProvider.cs
  128. +74 −0 ServiceStack/src/ServiceStack.Common/Support/PropertyInvoker.cs
  129. +18 −0 ServiceStack/src/ServiceStack.Common/Support/Thread.WinRT.cs
  130. +40 −0 ServiceStack/src/ServiceStack.Common/TypeExtensions.cs
  131. +123 −0 ServiceStack/src/ServiceStack.Common/UrnId.cs
  132. +37 −0 ServiceStack/src/ServiceStack.Common/Utils/AssertUtils.cs
  133. +118 −0 ServiceStack/src/ServiceStack.Common/Utils/CommandsUtils.cs
  134. +49 −0 ServiceStack/src/ServiceStack.Common/Utils/FuncUtils.cs
  135. +171 −0 ServiceStack/src/ServiceStack.Common/Utils/IdUtils.cs
  136. +84 −0 ServiceStack/src/ServiceStack.Common/Utils/PathUtils.cs
  137. +32 −0 ServiceStack/src/ServiceStack.Common/Utils/PerfUtils.cs
  138. +479 −0 ServiceStack/src/ServiceStack.Common/Utils/ReflectionUtils.cs
  139. +58 −0 ServiceStack/src/ServiceStack.Common/Utils/ResponseStatusUtils.cs
  140. +77 −0 ServiceStack/src/ServiceStack.Common/Web/CompressedFileResult.cs
  141. +77 −0 ServiceStack/src/ServiceStack.Common/Web/CompressedResult.cs
  142. +40 −0 ServiceStack/src/ServiceStack.Common/Web/CompressionTypes.cs
  143. +237 −0 ServiceStack/src/ServiceStack.Common/Web/ContentType.cs
  144. +14 −0 ServiceStack/src/ServiceStack.Common/Web/EndPoint.cs
  145. +120 −0 ServiceStack/src/ServiceStack.Common/Web/HttpError.cs
  146. +55 −0 ServiceStack/src/ServiceStack.Common/Web/HttpHeaders.cs
  147. +67 −0 ServiceStack/src/ServiceStack.Common/Web/HttpMethods.cs
  148. +310 −0 ServiceStack/src/ServiceStack.Common/Web/HttpResponseFilter.cs
  149. +77 −0 ServiceStack/src/ServiceStack.Common/Web/HttpResponseStreamWrapper.cs
  150. +258 −0 ServiceStack/src/ServiceStack.Common/Web/HttpResult.cs
  151. +97 −0 ServiceStack/src/ServiceStack.Common/Web/HttpResultExtensions.cs
  152. +117 −0 ServiceStack/src/ServiceStack.Common/Web/MimeTypes.cs
  153. +70 −0 ServiceStack/src/ServiceStack.Common/Web/SerializationContext.cs
  154. +11 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/ICacheClearable.cs
  155. +113 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/ICacheClient.cs
  156. +7 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/ICacheHasContentType.cs
  157. +14 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/ICacheManager.cs
  158. +16 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/ICacheTextManager.cs
  159. +7 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/ICacheTextManagerFactory.cs
  160. +11 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/ICompressableCacheTextManager.cs
  161. +7 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/ICompressableCacheTextManagerFactory.cs
  162. +9 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/IDeflateProvider.cs
  163. +9 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/IGZipProvider.cs
  164. +7 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/IHasCacheClient.cs
  165. +107 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/IMemcachedClient.cs
  166. +30 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/IPersistenceProviderCache.cs
  167. +11 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/IPersistenceProviderCacheFactory.cs
  168. +16 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/IRemoveByPattern.cs
  169. +31 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/ISession.cs
  170. +26 −0 ServiceStack/src/ServiceStack.Interfaces/CacheAccess/ISessionFactory.cs
  171. +22 −0 ServiceStack/src/ServiceStack.Interfaces/Configuration/IContainerAdapter.cs
  172. +16 −0 ServiceStack/src/ServiceStack.Interfaces/Configuration/IFactoryProvider.cs
  173. +7 −0 ServiceStack/src/ServiceStack.Interfaces/Configuration/IRelease.cs
  174. +15 −0 ServiceStack/src/ServiceStack.Interfaces/Configuration/IResourceManager.cs
  175. +9 −0 ServiceStack/src/ServiceStack.Interfaces/Configuration/ITypeFactory.cs
  176. +6 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/Criteria/ICriteria.cs
  177. +7 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/Criteria/IOrderAscendingCriteria.cs
  178. +7 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/Criteria/IOrderDescendingCriteria.cs
  179. +8 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/Criteria/IPagingCriteria.cs
  180. +14 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/Criteria/PagingCriteria.cs
  181. +30 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/DataAccessException.cs
  182. +11 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/IAggregatable.cs
  183. +32 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/IBasicPersistenceProvider.Generic.cs
  184. +33 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/IBasicPersistenceProvider.cs
  185. +11 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/IHasDbConnection.cs
  186. +34 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/IPersistenceProvider.cs
  187. +12 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/IPersistenceProviderManager.cs
  188. +7 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/IPersistenceProviderManagerFactory.cs
  189. +12 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/IQueryable.cs
  190. +9 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/IQueryableByComparer.cs
  191. +9 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/IQueryableByExample.cs
  192. +10 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/IQueryableByPredicate.cs
  193. +11 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/IQueryablePersistenceProvider.cs
  194. +11 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/IResultSet.cs
  195. +10 −0 ServiceStack/src/ServiceStack.Interfaces/DataAccess/ITransactionContext.cs
  196. +15 −0 ServiceStack/src/ServiceStack.Interfaces/DataAnnotations/AliasAttribute.cs
  197. +9 −0 ServiceStack/src/ServiceStack.Interfaces/DataAnnotations/AutoIncrementAttribute.cs
  198. +29 −0 ServiceStack/src/ServiceStack.Interfaces/DataAnnotations/CompositeIndexAttribute.cs
  199. +30 −0 ServiceStack/src/ServiceStack.Interfaces/DataAnnotations/DefaultAttribute.cs
  200. +19 −0 ServiceStack/src/ServiceStack.Interfaces/DataAnnotations/IndexAttribute.cs
  201. +15 −0 ServiceStack/src/ServiceStack.Interfaces/DataAnnotations/ReferencesAttribute.cs
  202. +7 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Command/ICommand.cs
  203. +6 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Command/ICommandExec.cs
  204. +8 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Command/ICommandIEnumerable.cs
  205. +8 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Command/ICommandIList.cs
  206. +8 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Command/ICommandList.cs
  207. +8 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Command/ICommandVoid.cs
  208. +8 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Model/IHasGuidId.cs
  209. +7 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Model/IHasId.cs
  210. +6 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Model/IHasIntId.cs
  211. +6 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Model/IHasLongId.cs
  212. +7 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Model/IHasNamed.cs
  213. +8 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Model/IHasNamedCollection.cs
  214. +9 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Model/IHasNamedList.cs
  215. +9 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Model/IHasStringId.cs
  216. +9 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Model/IHasUserId.cs
  217. +11 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Model/IHasUserSession.cs
  218. +10 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Serialization/IStringDeserializer.cs
  219. +7 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Serialization/IStringSerializer.cs
  220. +16 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Serialization/ITextSerializer.cs
  221. +7 −0 ServiceStack/src/ServiceStack.Interfaces/DesignPatterns/Translator/ITranslator.cs
  222. +22 −0 ServiceStack/src/ServiceStack.Interfaces/IO/IVirtualDirectory.cs
  223. +17 −0 ServiceStack/src/ServiceStack.Interfaces/IO/IVirtualFile.cs
  224. +14 −0 ServiceStack/src/ServiceStack.Interfaces/IO/IVirtualNode.cs
  225. +28 −0 ServiceStack/src/ServiceStack.Interfaces/IO/IVirtualPathProvider.cs
  226. +119 −0 ServiceStack/src/ServiceStack.Interfaces/Logging/ILog.cs
  227. +24 −0 ServiceStack/src/ServiceStack.Interfaces/Logging/ILogFactory.cs
  228. +52 −0 ServiceStack/src/ServiceStack.Interfaces/Logging/LogManager.cs
  229. +24 −0 ServiceStack/src/ServiceStack.Interfaces/Logging/Support/Logging/ConsoleLogFactory.cs
  230. +153 −0 ServiceStack/src/ServiceStack.Interfaces/Logging/Support/Logging/ConsoleLogger.cs
  231. +22 −0 ServiceStack/src/ServiceStack.Interfaces/Logging/Support/Logging/DebugLogFactory.cs
  232. +151 −0 ServiceStack/src/ServiceStack.Interfaces/Logging/Support/Logging/DebugLogger.cs
  233. +120 −0 ServiceStack/src/ServiceStack.Interfaces/Logging/Support/Logging/NullDebugLogger.cs
  234. +22 −0 ServiceStack/src/ServiceStack.Interfaces/Logging/Support/Logging/NullLogFactory.cs
  235. +20 −0 ServiceStack/src/ServiceStack.Interfaces/Logging/Support/Logging/TestLogFactory.cs
  236. +136 −0 ServiceStack/src/ServiceStack.Interfaces/Logging/Support/Logging/TestLogger.cs
  237. +16 −0 ServiceStack/src/ServiceStack.Interfaces/LogicFacade/IApplicationContext.cs
  238. +12 −0 ServiceStack/src/ServiceStack.Interfaces/LogicFacade/IInitContext.cs
  239. +9 −0 ServiceStack/src/ServiceStack.Interfaces/LogicFacade/ILogicFacade.cs
  240. +12 −0 ServiceStack/src/ServiceStack.Interfaces/LogicFacade/IOperationContext.cs
  241. +14 −0 ServiceStack/src/ServiceStack.Interfaces/LogicFacade/IServiceModelFinder.cs
  242. +7 −0 ServiceStack/src/ServiceStack.Interfaces/LogicFacade/IXmlRequest.cs
  243. +11 −0 ServiceStack/src/ServiceStack.Interfaces/LogicFacade/InitOptions.cs
  244. +31 −0 ServiceStack/src/ServiceStack.Interfaces/Messaging/IMessage.cs
  245. +9 −0 ServiceStack/src/ServiceStack.Interfaces/Messaging/IMessageFactory.cs
  246. +14 −0 ServiceStack/src/ServiceStack.Interfaces/Messaging/IMessageProducer.cs
  247. +44 −0 ServiceStack/src/ServiceStack.Interfaces/Messaging/IMessageQueueClient.cs
  248. +10 −0 ServiceStack/src/ServiceStack.Interfaces/Messaging/IMessageQueueClientFactory.cs
  249. +60 −0 ServiceStack/src/ServiceStack.Interfaces/Messaging/IMessageService.cs
  250. +14 −0 ServiceStack/src/ServiceStack.Interfaces/Messaging/MessageError.cs
  251. +97 −0 ServiceStack/src/ServiceStack.Interfaces/Messaging/MessageFactory.cs
  252. +62 −0 ServiceStack/src/ServiceStack.Interfaces/Messaging/MessageHandlerStats.cs
  253. +13 −0 ServiceStack/src/ServiceStack.Interfaces/Messaging/MessageOption.cs
  254. +41 −0 ServiceStack/src/ServiceStack.Interfaces/Messaging/MessagingException.cs
  255. +83 −0 ServiceStack/src/ServiceStack.Interfaces/Messaging/QueueNames.cs
  256. +31 −0 ServiceStack/src/ServiceStack.Interfaces/Messaging/UnRetryableMessagingException.cs
  257. +27 −0 ServiceStack/src/ServiceStack.Interfaces/OrmLite/DbConnectionFactory.cs
  258. +10 −0 ServiceStack/src/ServiceStack.Interfaces/OrmLite/IDbConnectionFactory.cs
  259. +39 −0 ServiceStack/src/ServiceStack.Interfaces/Properties/AssemblyInfo.cs
  260. +4 −0 ServiceStack/src/ServiceStack.Interfaces/README.md
  261. +23 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/Generic/IRedisHash.Generic.cs
  262. +50 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/Generic/IRedisList.Generic.cs
  263. +34 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/Generic/IRedisSet.Generic.cs
  264. +38 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/Generic/IRedisSortedSet.Generic.cs
  265. +26 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/Generic/IRedisTransaction.cs
  266. +192 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/Generic/IRedisTypedClient.cs
  267. +11 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/Generic/IRedisTypedPipeline.cs
  268. +53 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/Generic/IRedisTypedQueueableOperation.cs
  269. +292 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/IRedisClient.cs
  270. +45 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/IRedisClientCacheManager.cs
  271. +44 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/IRedisClientsManager.cs
  272. +13 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/IRedisHash.cs
  273. +45 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/IRedisList.cs
  274. +200 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/IRedisNativeClient.cs
  275. +36 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/IRedisSet.cs
  276. +37 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/IRedisSortedSet.cs
  277. +44 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/IRedisSubscription.cs
  278. +27 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/IRedisTransaction.cs
  279. +11 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/IRedisTransactionBase.cs
  280. +8 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/ItemRef.cs
  281. +9 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/Pipeline/IRedisPipeline.cs
  282. +13 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/Pipeline/IRedisPipelineShared.cs
  283. +20 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/Pipeline/IRedisQueueCompletableOperation.cs
  284. +49 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/Pipeline/IRedisQueueableOperation.cs
  285. BIN  ServiceStack/src/ServiceStack.Interfaces/Redis/Redis-annotated.png
  286. +148 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/Redis.cd
  287. BIN  ServiceStack/src/ServiceStack.Interfaces/Redis/Redis.png
  288. +24 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/RedisKeyType.cs
  289. +13 −0 ServiceStack/src/ServiceStack.Interfaces/Redis/SortOptions.cs
  290. +18 −0 ServiceStack/src/ServiceStack.Interfaces/SearchIndex/FullTextIndexAttribute.cs
  291. +17 −0 ServiceStack/src/ServiceStack.Interfaces/SearchIndex/FullTextIndexDocumentAttribute.cs
  292. +35 −0 ServiceStack/src/ServiceStack.Interfaces/SearchIndex/FullTextIndexFieldAttribute.cs
  293. +9 −0 ServiceStack/src/ServiceStack.Interfaces/Service/IOneWayClient.cs
  294. +29 −0 ServiceStack/src/ServiceStack.Interfaces/Service/IReplyClient.cs
  295. +14 −0 ServiceStack/src/ServiceStack.Interfaces/Service/IResponseBase.cs
  296. +13 −0 ServiceStack/src/ServiceStack.Interfaces/Service/IResponseStatus.cs
  297. +39 −0 ServiceStack/src/ServiceStack.Interfaces/Service/IRestClient.cs
  298. +27 −0 ServiceStack/src/ServiceStack.Interfaces/Service/IRestClientAsync.cs
  299. +12 −0 ServiceStack/src/ServiceStack.Interfaces/Service/IServiceClient.cs
  300. +9 −0 ServiceStack/src/ServiceStack.Interfaces/Service/IServiceClientAsync.cs
Sorry, we could not display the entire diff because too many files (741) changed.
45 MonkeyWrench.Web.ServiceStack/BuildBots.cs
View
@@ -0,0 +1,45 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+
+using MonkeyWrench.Database;
+using MonkeyWrench.DataClasses;
+using MonkeyWrench.DataClasses.Logic;
+
+using ServiceStack;
+using ServiceStack.ServiceInterface;
+using ServiceStack.ServiceInterface.ServiceModel;
+using ServiceStack.ServiceHost;
+
+namespace MonkeyWrench.Web.ServiceStack
+{
+ public class BuildBots {}
+
+ public class BuildBotsResponse
+ {
+ public ResponseStatus ResponseStatus { get; set; }
+ public List<BuildBot> BuildBots { get; set; }
+ }
+
+ [Authenticate]
+ [RequiredRole (RoleNames.Admin)]
+ public class BuildBotsService : Service
+ {
+ public object Any (BuildBots request)
+ {
+ List<DBHost> hosts = null;
+ using (DB db = new DB ())
+ hosts = db.GetHosts ();
+
+ return new BuildBotsResponse {
+ BuildBots = hosts.Select (h => new BuildBot {
+ ID = h.id,
+ Name = h.host,
+ Arch = h.architecture,
+ Description = h.description
+ }).ToList ()
+ };
+ }
+ }
+}
+
83 MonkeyWrench.Web.ServiceStack/BuildSteps.cs
View
@@ -0,0 +1,83 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.Common;
+
+using MonkeyWrench.Database;
+using MonkeyWrench.DataClasses;
+using MonkeyWrench.DataClasses.Logic;
+
+using ServiceStack;
+using ServiceStack.ServiceInterface;
+using ServiceStack.ServiceInterface.ServiceModel;
+using ServiceStack.ServiceHost;
+using ServiceStack.DataAnnotations;
+using ServiceStack.FluentValidation;
+
+namespace MonkeyWrench.Web.ServiceStack
+{
+
+ [Route ("/buildsteps/{LaneID}/{HostID}/{RevisionID}")]
+ public class BuildSteps
+ {
+ public int LaneID { get; set; }
+ public int HostID { get; set; }
+ public int RevisionID { get; set; }
+ }
+
+ public class BuildStepsValidator : AbstractValidator<BuildSteps>
+ {
+ public BuildStepsValidator ()
+ {
+ RuleFor (bs => bs.LaneID).GreaterThan (0);
+ RuleFor (bs => bs.HostID).GreaterThan (0);
+ RuleFor (bs => bs.RevisionID).GreaterThan (0);
+ }
+ }
+
+ public class BuildStepsResponse
+ {
+ public ResponseStatus ResponseStatus { get; set; }
+ public List<BuildStep> BuildSteps { get; set; }
+ }
+
+ [Authenticate]
+ [RequiredRole (RoleNames.Admin)]
+ public class BuildStepsService : Service
+ {
+ public object Any (BuildSteps request)
+ {
+ List<DBWorkView2> workViews = null;
+ List<List<DBWorkFileView>> files = null;
+
+ using (var db = new DB ()) {
+ var lane = Utils.FindLane (db, request.LaneID);
+ var host = Utils.FindHost (db, request.HostID);
+ var revision = Utils.FindRevision (db, request.RevisionID);
+ var revisionWork = DBRevisionWork_Extensions.Find (db, lane, host, revision);
+ workViews = db.GetWork (revisionWork);
+ files = new List<List<DBWorkFileView>> ();
+ for (int i = 0; i < workViews.Count; i++)
+ files.Add (DBWork_Extensions.GetFiles (db, workViews [i].id, false));
+ }
+
+ var list = workViews
+ .Where (step => step != null)
+ .Select ((step, i) => new BuildStep {
+ Name = step.command,
+ State = (DBState)step.state,
+ StartDate = step.state > (int)DBState.NotDone && step.state != (int)DBState.Paused ? step.starttime : (DateTime?)null,
+ Duration = step.state >= (int)DBState.Executing && step.state != (int)DBState.Paused ? Utils.GetDurationFromWorkView (step) : (TimeSpan?)null,
+ Author = step.author,
+ LogId = files[i].Count > 0 ? files[i].FirstOrDefault (f => f.filename.StartsWith (step.command)).id.ToString () : null
+ })
+ .ToList ();
+
+ return new BuildStepsResponse {
+ BuildSteps = list
+ };
+ }
+ }
+}
+
110 MonkeyWrench.Web.ServiceStack/Builds.cs
View
@@ -0,0 +1,110 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.Common;
+
+using MonkeyWrench.Database;
+using MonkeyWrench.DataClasses;
+using MonkeyWrench.DataClasses.Logic;
+
+using ServiceStack;
+using ServiceStack.ServiceInterface;
+using ServiceStack.ServiceInterface.ServiceModel;
+using ServiceStack.ServiceHost;
+using ServiceStack.DataAnnotations;
+using ServiceStack.FluentValidation;
+
+namespace MonkeyWrench.Web.ServiceStack
+{
+ [Route ("/builds/{LaneID}")]
+ public class Builds
+ {
+ public int LaneID { get; set; }
+ [Default (0)]
+ public int Offset { get; set; }
+ [Default (10)]
+ public int Limit { get; set; }
+ }
+
+ public class BuildsValidator : AbstractValidator<Builds>
+ {
+ public BuildsValidator ()
+ {
+ RuleFor (bs => bs.LaneID).GreaterThan (0);
+ RuleFor (bs => bs.Offset).GreaterThan (0);
+ RuleFor (bs => bs.Limit).GreaterThanOrEqualTo (0);
+ }
+ }
+
+ public class BuildsResponse
+ {
+ public ResponseStatus ResponseStatus { get; set; }
+ public List<Build> Builds { get; set; }
+ }
+
+ [Authenticate]
+ [RequiredRole (RoleNames.Admin)]
+ public class BuildsService : Service
+ {
+ public object Any (Builds request)
+ {
+ List<DBRevisionWorkView> revisions = new List<DBRevisionWorkView> ();
+ using (var db = new DB ()) {
+ var hostLanes = new List<DBHostLane> ();
+ using (IDbCommand cmd = db.CreateCommand ()) {
+ cmd.CommandText = @"SELECT HostLane.* FROM HostLane WHERE hidden = false AND lane_id = @lane_id";
+ DB.CreateParameter (cmd, "lane_id", request.LaneID);
+
+ using (IDataReader reader = cmd.ExecuteReader ())
+ while (reader.Read ())
+ hostLanes.Add (new DBHostLane (reader));
+ }
+
+ foreach (var hl in hostLanes) {
+ using (IDbCommand cmd = db.CreateCommand ()) {
+ cmd.CommandText = DBRevisionWorkView.SQL;
+ DB.CreateParameter (cmd, "lane_id", request.LaneID);
+ DB.CreateParameter (cmd, "host_id", hl.host_id);
+ DB.CreateParameter (cmd, "limit", request.Limit);
+ DB.CreateParameter (cmd, "offset", request.Offset);
+
+ using (IDataReader reader = cmd.ExecuteReader ())
+ while (reader.Read ())
+ revisions.Add (new DBRevisionWorkView (reader));
+ }
+ }
+ }
+
+ return new BuildsResponse {
+ Builds = revisions.Where (rev => rev != null).Distinct (RevisionWorkViewComparer.Instance).Select (rev => new Build {
+ Commit = rev.revision,
+ CommitId = rev.revision_id,
+ Date = rev.State > DBState.Executing ? rev.endtime : rev.starttime,
+ Lane = string.IsNullOrEmpty (rev.lane) ? "(no lane)" : rev.lane,
+ Project = string.IsNullOrEmpty (rev.lane) ? "(no parent)" : rev.lane,
+ State = rev.RevisionWorkState,
+ Author = rev.author,
+ BuildBot = rev.host,
+
+ }).ToList ()
+ };
+ }
+
+ class RevisionWorkViewComparer : IEqualityComparer<DBRevisionWorkView>
+ {
+ public static readonly RevisionWorkViewComparer Instance = new RevisionWorkViewComparer ();
+
+ public bool Equals (DBRevisionWorkView x, DBRevisionWorkView y)
+ {
+ return x.revision == y.revision;
+ }
+
+ public int GetHashCode (DBRevisionWorkView obj)
+ {
+ return obj.revision.GetHashCode ();
+ }
+ }
+ }
+}
+
1  MonkeyWrench.Web.ServiceStack/Global.asax
View
@@ -0,0 +1 @@
+<%@ Application Inherits="MonkeyWrench.Web.ServiceStack.Global" %>
75 MonkeyWrench.Web.ServiceStack/Global.asax.cs
View
@@ -0,0 +1,75 @@
+
+using System;
+using System.Web;
+using System.Web.SessionState;
+
+using ServiceStack.WebHost.Endpoints;
+using ServiceStack.ServiceInterface;
+using Funq;
+using ServiceStack.CacheAccess;
+using ServiceStack.CacheAccess.Providers;
+using ServiceStack.Configuration;
+using ServiceStack.ServiceInterface.Auth;
+using ServiceStack.Authentication.OpenId;
+using ServiceStack.ServiceInterface.Validation;
+
+namespace MonkeyWrench.Web.ServiceStack
+{
+ public class Global : System.Web.HttpApplication
+ {
+ public class WrenchAppHost : AppHostBase
+ {
+ //Tell Service Stack the name of your application and where to find your web services
+ public WrenchAppHost ()
+ : base ("Wrench ServiceStack-based service", typeof (WrenchAppHost).Assembly)
+ {
+
+ }
+
+ public override void Configure (Container container)
+ {
+ container.Register<ICacheClient> (new MemoryCacheClient ());
+ var appSettings = new AppSettings ();
+ Plugins.Add (new AuthFeature (() => new WrenchAuthUserSession (),
+ new[] { new GoogleOpenIdOAuthProvider (appSettings) }));
+ Plugins.Add (new ValidationFeature ());
+ container.RegisterValidators (typeof (WrenchAppHost).Assembly);
+ Routes.AddFromAssembly (typeof (WrenchAppHost).Assembly);
+ }
+ }
+
+ protected virtual void Application_Start (Object sender, EventArgs e)
+ {
+ new WrenchAppHost ().Init ();
+ }
+
+ protected virtual void Session_Start (Object sender, EventArgs e)
+ {
+ }
+
+ protected virtual void Application_BeginRequest (Object sender, EventArgs e)
+ {
+ }
+
+ protected virtual void Application_EndRequest (Object sender, EventArgs e)
+ {
+ }
+
+ protected virtual void Application_AuthenticateRequest (Object sender, EventArgs e)
+ {
+ }
+
+ protected virtual void Application_Error (Object sender, EventArgs e)
+ {
+ }
+
+ protected virtual void Session_End (Object sender, EventArgs e)
+ {
+ }
+
+ protected virtual void Application_End (Object sender, EventArgs e)
+ {
+ }
+ }
+}
+
112 MonkeyWrench.Web.ServiceStack/HostBuilds.cs
View
@@ -0,0 +1,112 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.Common;
+
+using MonkeyWrench.Database;
+using MonkeyWrench.DataClasses;
+using MonkeyWrench.DataClasses.Logic;
+
+using ServiceStack;
+using ServiceStack.ServiceInterface;
+using ServiceStack.ServiceInterface.ServiceModel;
+using ServiceStack.ServiceHost;
+using ServiceStack.DataAnnotations;
+using ServiceStack.FluentValidation;
+
+namespace MonkeyWrench.Web.ServiceStack
+{
+ [Route ("/hostbuilds/{HostID}")]
+ public class HostBuilds
+ {
+ public int HostID { get; set; }
+ [Default (0)]
+ public int Offset { get; set; }
+ [Default (10)]
+ public int Limit { get; set; }
+ }
+
+ public class HostBuildsValidator : AbstractValidator<HostBuilds>
+ {
+ public HostBuildsValidator ()
+ {
+ RuleFor (hb => hb.HostID).GreaterThan (0);
+ RuleFor (hb => hb.Offset).GreaterThan (0);
+ RuleFor (hb => hb.Limit).GreaterThanOrEqualTo (0);
+ }
+ }
+
+ public class HostBuildsResponse
+ {
+ public ResponseStatus ResponseStatus { get; set; }
+ public List<Build> Builds { get; set; }
+ }
+
+ [Authenticate]
+ [RequiredRole (RoleNames.Admin)]
+ public class HostBuildsService : Service
+ {
+ public object Any (HostBuilds request)
+ {
+ var revisionWorks = new List<DBRevisionWork> ();
+ var revisions = new List<string> ();
+ var lanes = new List<string> ();
+ var startTimes = new List<DateTime> ();
+
+ using (DB db = new DB ()) {
+ using (IDbCommand cmd = db.CreateCommand ()) {
+ cmd.CommandText = @"
+SELECT RevisionWork.*, Host.host, Lane.lane, Revision.revision, MAX (Work.starttime) AS order_date,
+-- calculate the duration of each work and add them up
+ SUM (EXTRACT (EPOCH FROM (
+ (CASE
+ WHEN (Work.starttime = '-infinity' OR Work.starttime < '2001-01-01') AND (Work.endtime = '-infinity' OR Work.endtime < '2001-01-01') THEN LOCALTIMESTAMP - LOCALTIMESTAMP
+ WHEN (Work.endtime = '-infinity' OR Work.endtime < '2001-01-01') THEN CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - Work.starttime
+ ELSE Work.endtime - Work.starttime
+ END)
+ ))) AS duration
+FROM RevisionWork
+INNER JOIN Revision ON RevisionWork.revision_id = Revision.id
+INNER JOIN Lane ON RevisionWork.lane_id = Lane.id
+INNER JOIN Work ON RevisionWork.id = Work.revisionwork_id
+INNER JOIN Host ON RevisionWork.host_id = Host.id
+WHERE RevisionWork.workhost_id = @host_id
+GROUP BY RevisionWork.id, RevisionWork.lane_id, RevisionWork.host_id, RevisionWork.workhost_id, RevisionWork.revision_id, RevisionWork.state, RevisionWork.lock_expires, RevisionWork.completed, RevisionWork.endtime, Lane.lane, Revision.revision, Host.host ";
+ cmd.CommandText += " ORDER BY order_date DESC ";
+ if (request.Limit > 0)
+ cmd.CommandText += " LIMIT " + request.Limit.ToString ();
+ if (request.Offset > 0)
+ cmd.CommandText += " OFFSET " + request.Offset.ToString ();
+ cmd.CommandText += ";";
+ DB.CreateParameter (cmd, "host_id", request.HostID);
+
+ using (IDataReader reader = cmd.ExecuteReader ()) {
+ int lane_idx = reader.GetOrdinal ("lane");
+ int revision_idx = reader.GetOrdinal ("revision");
+ int starttime_idx = reader.GetOrdinal ("order_date");
+ while (reader.Read ()) {
+ revisionWorks.Add (new DBRevisionWork (reader));
+ lanes.Add (reader.GetString (lane_idx));
+ revisions.Add (reader.GetString (revision_idx));
+ startTimes.Add (reader.GetDateTime (starttime_idx));
+ }
+ }
+ }
+ }
+
+ var list = revisionWorks.Select ((e, i) => new Build {
+ Commit = revisions [i],
+ CommitId = revisionWorks[i].revision_id,
+ State = e.State,
+ Date = e.completed ? e.endtime : startTimes[i],
+ Lane = lanes [i]
+ }).ToList ();
+
+ return new HostBuildsResponse {
+ Builds = list
+ };
+ }
+ }
+}
+
91 MonkeyWrench.Web.ServiceStack/LatestBuilds.cs
View
@@ -0,0 +1,91 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.Common;
+
+using MonkeyWrench.Database;
+using MonkeyWrench.DataClasses;
+using MonkeyWrench.DataClasses.Logic;
+
+using ServiceStack;
+using ServiceStack.ServiceInterface;
+using ServiceStack.ServiceInterface.ServiceModel;
+
+namespace MonkeyWrench.Web.ServiceStack
+{
+ public class LatestBuilds {}
+
+ public class LatestBuildsResponse
+ {
+ public ResponseStatus ResponseStatus { get; set; }
+ public List<Build> LatestBuilds { get; set; }
+ }
+
+ [Authenticate]
+ [RequiredRole (RoleNames.Admin)]
+ public class LatestBuildsService : Service
+ {
+ public object Any (LatestBuilds request)
+ {
+ var result = new List<KeyValuePair<DBHost, DBRevisionWorkView2>> ();
+ List<DBLane> lanes = null;
+ var hostLanes = new List<DBHostLane> ();
+
+ using (DB db = new DB ()) {
+ lanes = db.GetAllLanes ();
+
+ using (IDbCommand cmd = db.CreateCommand ()) {
+ cmd.CommandText = @"
+SELECT HostLane.*
+FROM HostLane
+WHERE hidden = false";
+
+ using (IDataReader reader = cmd.ExecuteReader ())
+ while (reader.Read ())
+ hostLanes.Add (new DBHostLane (reader));
+ }
+
+ foreach (DBHostLane hl in hostLanes) {
+ DBRevisionWorkView2 revisionWork = null;
+ using (IDbCommand cmd = db.CreateCommand ()) {
+ cmd.CommandText = @"SELECT R.* FROM (" + DBRevisionWorkView2.SQL.Replace (';', ' ') + ") AS R WHERE R.host_id = @host_id AND R.lane_id = @lane_id LIMIT @limit";
+ DB.CreateParameter (cmd, "host_id", hl.host_id);
+ DB.CreateParameter (cmd, "lane_id", hl.lane_id);
+ DB.CreateParameter (cmd, "limit", 1);
+
+ using (IDataReader reader = cmd.ExecuteReader ())
+ while (reader.Read ())
+ revisionWork = new DBRevisionWorkView2 (reader);
+ }
+
+ result.Add (new KeyValuePair<DBHost, DBRevisionWorkView2> (Utils.FindHost (db, revisionWork.host_id), revisionWork));
+ }
+ }
+
+ var list = result.Where (view => view.Value != null).Select (view => {
+ var item = view.Value;
+ var lane = lanes.Where (l => l.id == item.lane_id).FirstOrDefault ();
+ var parent = Utils.GetTopMostParent (lane, lanes);
+ return new Build {
+ Commit = item.revision,
+ CommitId = item.revision_id,
+ Date = item.completed ? item.endtime : item.date,
+ Lane = lane.lane,
+ LaneID = lane.id,
+ Project = parent.lane,
+ State = item.State,
+ Author = item.author,
+ BuildBot = view.Key == null ? string.Empty : view.Key.host,
+ HostID = item.host_id,
+ Url = Utils.MakeBuildUrl (item.lane_id, item.host_id, item.revision_id)
+ };
+ }).OrderByDescending (b => b.Date).ToList ();
+
+ return new LatestBuildsResponse {
+ LatestBuilds = list
+ };
+ }
+ }
+}
+
96 MonkeyWrench.Web.ServiceStack/MonkeyWrench.Web.ServiceStack.csproj
View
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>10.0.0</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{616B7099-222A-4EF1-AA46-17156B7EA102}</ProjectGuid>
+ <ProjectTypeGuids>{349C5851-65DF-11DA-9384-00065B846F21};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <RootNamespace>MonkeyWrench.Web.ServiceStack</RootNamespace>
+ <AssemblyName>MonkeyWrench.Web.ServiceStack</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>True</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>False</Optimize>
+ <OutputPath>bin</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>False</ConsolePause>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>True</Optimize>
+ <OutputPath>bin</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>False</ConsolePause>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Web.Services" />
+ <Reference Include="System.Data" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Global.asax" />
+ <Content Include="web.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Global.asax.cs">
+ <DependentUpon>Global.asax</DependentUpon>
+ </Compile>
+ <Compile Include="Projects.cs" />
+ <Compile Include="Pocos.cs" />
+ <Compile Include="WrenchAuthUserSession.cs" />
+ <Compile Include="BuildBots.cs" />
+ <Compile Include="LatestBuilds.cs" />
+ <Compile Include="Utils.cs" />
+ <Compile Include="Builds.cs" />
+ <Compile Include="BuildSteps.cs" />
+ <Compile Include="HostBuilds.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
+ <ProjectExtensions>
+ <MonoDevelop>
+ <Properties VerifyCodeBehindFields="True" VerifyCodeBehindEvents="True">
+ <XspParameters Port="8080" Address="127.0.0.1" SslMode="None" SslProtocol="Default" KeyType="None" CertFile="" KeyFile="" PasswordOptions="None" Password="" Verbose="True" />
+ </Properties>
+ </MonoDevelop>
+ </ProjectExtensions>
+ <ItemGroup>
+ <ProjectReference Include="..\ServiceStack\src\ServiceStack\ServiceStack.csproj">
+ <Project>{680A1709-25EB-4D52-A87F-EE03FFD94BAA}</Project>
+ <Name>ServiceStack</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\ServiceStack\src\ServiceStack.Authentication.OpenId\ServiceStack.Authentication.OpenId.csproj">
+ <Project>{6E240294-9D93-4C09-9BB0-38D82A22DEEE}</Project>
+ <Name>ServiceStack.Authentication.OpenId</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\MonkeyWrench\MonkeyWrench.csproj">
+ <Project>{EBFBC3BF-10E1-4482-B9BE-A516934C099A}</Project>
+ <Name>MonkeyWrench</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\MonkeyWrench.Database\MonkeyWrench.Database.csproj">
+ <Project>{1C38937B-F45F-4EB1-B4D1-893FF684C525}</Project>
+ <Name>MonkeyWrench.Database</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\MonkeyWrench.DataClasses\MonkeyWrench.DataClasses.csproj">
+ <Project>{A461423E-8232-42D6-AA34-8DEC97F6D8F8}</Project>
+ <Name>MonkeyWrench.DataClasses</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\ServiceStack\src\ServiceStack.ServiceInterface\ServiceStack.ServiceInterface.csproj">
+ <Project>{5A315F92-80D2-4C60-A5A4-22E027AC7E7E}</Project>
+ <Name>ServiceStack.ServiceInterface</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\ServiceStack\src\ServiceStack.Interfaces\ServiceStack.Interfaces.csproj">
+ <Project>{42E1C8C0-A163-44CC-92B1-8F416F2C0B01}</Project>
+ <Name>ServiceStack.Interfaces</Name>
+ </ProjectReference>
+ </ItemGroup>
+</Project>
47 MonkeyWrench.Web.ServiceStack/Pocos.cs
View
@@ -0,0 +1,47 @@
+using System;
+
+using MonkeyWrench.DataClasses;
+
+namespace MonkeyWrench.Web.ServiceStack
+{
+ public struct BuildBot
+ {
+ public int ID { get; set; }
+ public string Name { get; set; }
+ public string Arch { get; set; }
+ public string Description { get; set; }
+ }
+
+ public struct Build
+ {
+ // Either end date for finished job or start date for running/not ran job
+ public DateTime Date { get; set; }
+ public string Commit { get; set; }
+ public int? CommitId { get; set; }
+ public string Lane { get; set; }
+ public int LaneID { get; set; }
+ public string Project { get; set; }
+ public DBState State { get; set; }
+ public string Author { get; set; }
+ public string BuildBot { get; set; }
+ public int HostID { get; set; }
+ public Uri Url { get; set; }
+ }
+
+ public struct Lane
+ {
+ public int ID { get; set; }
+ public string Name { get; set; }
+ }
+
+ public struct BuildStep
+ {
+ public string Name { get; set; }
+ public DBState State { get; set; }
+ public DateTime? StartDate { get; set; }
+ public TimeSpan? Duration { get; set; }
+ public string Author { get; set; } // Safeguard if we couldn't get info from other source
+ public string LogId { get; set; } // ID of the log file for the step
+ }
+}
+
43 MonkeyWrench.Web.ServiceStack/Projects.cs
View
@@ -0,0 +1,43 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+
+using MonkeyWrench.Database;
+using MonkeyWrench.DataClasses;
+using MonkeyWrench.DataClasses.Logic;
+
+using ServiceStack;
+using ServiceStack.ServiceInterface;
+using ServiceStack.ServiceInterface.ServiceModel;
+using ServiceStack.ServiceHost;
+
+namespace MonkeyWrench.Web.ServiceStack
+{
+ public class Projects {}
+
+ public class ProjectsResponse
+ {
+ public ResponseStatus ResponseStatus { get; set; }
+ public Dictionary<Lane, List<Lane>> Projects { get; set; }
+ }
+
+ [Authenticate]
+ [RequiredRole (RoleNames.Admin)]
+ public class ProjectsService : Service
+ {
+ public object Any (Projects request)
+ {
+ List<DBLane> lanes = null;
+ using (DB db = new DB ())
+ lanes = db.GetAllLanes ();
+ var parents = new HashSet<int?> (lanes.Where (l => l.parent_lane_id != null).Select (l => l.parent_lane_id));
+ return new ProjectsResponse {
+ Projects = lanes.Where (l => !parents.Contains (l.id))
+ .ToLookup (l => Utils.GetTopMostParent (l, lanes))
+ .ToDictionary (ls => new Lane { ID = ls.Key.id, Name = ls.Key.lane },
+ ls => ls.Select (l => new Lane { ID = l.id, Name = l.lane}).ToList ())
+ };
+ }
+ }
+}
+
90 MonkeyWrench.Web.ServiceStack/Utils.cs
View
@@ -0,0 +1,90 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.Common;
+
+using MonkeyWrench.DataClasses;
+
+namespace MonkeyWrench.Web.ServiceStack
+{
+ public static class Utils
+ {
+ public static DBLane GetTopMostParent (DBLane forLane, IEnumerable<DBLane> lanes)
+ {
+ var parent = forLane;
+ while (parent.parent_lane_id != null)
+ parent = lanes.First (l => l.id == parent.parent_lane_id.Value);
+ return parent;
+ }
+
+ public static Uri MakeBuildUrl (int laneId, int hostId, int revisionId)
+ {
+ var url = Configuration.GetWebSiteUrl ();
+ url += string.Format ("/ViewLane.aspx?lane_id={0}&host_id={1}&revision_id={2}", laneId, hostId, revisionId);
+
+ return new Uri (url);
+ }
+
+ public static DBHost FindHost (DB db, int host_id)
+ {
+ using (IDbCommand cmd = db.CreateCommand ()) {
+ cmd.CommandText = "SELECT * FROM Host WHERE id = @id;";
+ DB.CreateParameter (cmd, "id", host_id);
+
+ using (IDataReader reader = cmd.ExecuteReader ()) {
+ if (reader.Read ())
+ return new DBHost (reader);
+ }
+ }
+
+ return null;
+ }
+
+ public static DBLane FindLane (DB db, int lane_id)
+ {
+ using (IDbCommand cmd = db.CreateCommand ()) {
+ cmd.CommandText = "SELECT * FROM Lane WHERE id = @id;";
+ DB.CreateParameter (cmd, "id", lane_id);
+
+ using (IDataReader reader = cmd.ExecuteReader ()) {
+ if (reader.Read ())
+ return new DBLane (reader);
+ }
+ }
+
+ return null;
+ }
+
+ public static DBRevision FindRevision (DB db, int revision_id)
+ {
+ using (IDbCommand cmd = db.CreateCommand ()) {
+ cmd.CommandText = "SELECT * FROM Revision WHERE id = @id;";
+ DB.CreateParameter (cmd, "id", revision_id);
+
+ using (IDataReader reader = cmd.ExecuteReader ()) {
+ if (reader.Read ())
+ return new DBRevision (reader);
+ }
+ }
+
+ return null;
+ }
+
+ public static TimeSpan GetDurationFromWorkView (DBWorkView2 step)
+ {
+ DateTime starttime = step.starttime.ToLocalTime ();
+ DateTime endtime = step.endtime.ToLocalTime ();
+ int duration = (int) (endtime - starttime).TotalSeconds;
+
+ if (step.endtime.Year < DateTime.Now.Year - 1 && step.duration == 0) {// Not ended, endtime defaults to year 2000
+ duration = (int) (DateTime.Now - starttime).TotalSeconds;
+ } else if (step.endtime == DateTime.MinValue) {
+ duration = step.duration;
+ }
+
+ return TimeSpan.FromSeconds (duration);
+ }
+ }
+}
+
29 MonkeyWrench.Web.ServiceStack/WrenchAuthUserSession.cs
View
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Net.Mail;
+
+using ServiceStack.ServiceInterface.Auth;
+using ServiceStack.Authentication.OpenId;
+using ServiceStack.ServiceInterface;
+
+namespace MonkeyWrench.Web.ServiceStack
+{
+ public class WrenchAuthUserSession : AuthUserSession
+ {
+ public override void OnAuthenticated (IServiceBase authService, IAuthSession session, IOAuthTokens tokens, Dictionary<string, string> authInfo)
+ {
+ base.OnAuthenticated (authService, session, tokens, authInfo);
+ try {
+ var mail = new MailAddress (session.Email);
+ // We use a very simple authentification scheme for now solely based on a @xamarin.com email address
+ if (mail.Host == "xamarin.com") {
+ Roles.Add (RoleNames.Admin);
+ Permissions.AddRange (new [] { "CanAccess", "CanModify" });
+ }
+ } catch {
+ // Log
+ }
+ }
+ }
+}
+
31 MonkeyWrench.Web.ServiceStack/web.config
View
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+Web.config file for MonkeyWrench.Web.ServiceStack.
+
+The settings that can be used in this file are documented at
+http://www.mono-project.com/Config_system.web and
+http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx
+-->
+<configuration>
+ <system.web>
+ <compilation defaultLanguage="C#" debug="true">
+ <assemblies>
+ </assemblies>
+ </compilation>
+ <customErrors mode="RemoteOnly">
+ </customErrors>
+ <authentication mode="None">
+ </authentication>
+ <authorization>
+ <allow users="*" />
+ </authorization>
+ <trace enabled="false" localOnly="true" pageOutput="false" requestLimit="10" traceMode="SortByTime" />
+ <sessionState mode="InProc" cookieless="false" timeout="20" />
+ <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
+ <pages>
+ </pages>
+ <httpHandlers>
+ <add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
+ </httpHandlers>
+ </system.web>
+</configuration>
99 MonkeyWrench.sln 100755 → 100644
View
@@ -23,10 +23,28 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmartIrc4net", "SmartIrc4ne
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json", "Newtonsoft.Json\Src\Newtonsoft.Json\Newtonsoft.Json.csproj", "{A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ServiceStack", "ServiceStack", "{0383DE2B-50A5-449C-AAC0-4DDD753764DD}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Common", "ServiceStack\src\ServiceStack.Common\ServiceStack.Common.csproj", "{982416DB-C143-4028-A0C3-CF41892D18D3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Interfaces", "ServiceStack\src\ServiceStack.Interfaces\ServiceStack.Interfaces.csproj", "{42E1C8C0-A163-44CC-92B1-8F416F2C0B01}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack", "ServiceStack\src\ServiceStack\ServiceStack.csproj", "{680A1709-25EB-4D52-A87F-EE03FFD94BAA}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Authentication.OpenId", "ServiceStack\src\ServiceStack.Authentication.OpenId\ServiceStack.Authentication.OpenId.csproj", "{6E240294-9D93-4C09-9BB0-38D82A22DEEE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.ServiceInterface", "ServiceStack\src\ServiceStack.ServiceInterface\ServiceStack.ServiceInterface.csproj", "{5A315F92-80D2-4C60-A5A4-22E027AC7E7E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonkeyWrench.Web.ServiceStack", "MonkeyWrench.Web.ServiceStack\MonkeyWrench.Web.ServiceStack.csproj", "{616B7099-222A-4EF1-AA46-17156B7EA102}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
+ STATIC_ONLY NO_EXPRESSIONS|Any CPU = STATIC_ONLY NO_EXPRESSIONS|Any CPU
+ MonoTouch|Any CPU = MonoTouch|Any CPU
+ MONOTOUCH|Any CPU = MONOTOUCH|Any CPU
+ DEBUG MONO|Any CPU = DEBUG MONO|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{01AAA129-3B2B-4093-A7B4-6153B6BEBED4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -45,6 +63,64 @@ Global
{3737EDC2-5785-424C-92BC-7013B931AF21}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3737EDC2-5785-424C-92BC-7013B931AF21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3737EDC2-5785-424C-92BC-7013B931AF21}.Release|Any CPU.Build.0 = Release|Any CPU
+ {42E1C8C0-A163-44CC-92B1-8F416F2C0B01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {42E1C8C0-A163-44CC-92B1-8F416F2C0B01}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {42E1C8C0-A163-44CC-92B1-8F416F2C0B01}.MonoTouch|Any CPU.ActiveCfg = Debug|Any CPU
+ {42E1C8C0-A163-44CC-92B1-8F416F2C0B01}.MONOTOUCH|Any CPU.ActiveCfg = MONOTOUCH|Any CPU
+ {42E1C8C0-A163-44CC-92B1-8F416F2C0B01}.MonoTouch|Any CPU.Build.0 = Debug|Any CPU
+ {42E1C8C0-A163-44CC-92B1-8F416F2C0B01}.MONOTOUCH|Any CPU.Build.0 = MONOTOUCH|Any CPU
+ {42E1C8C0-A163-44CC-92B1-8F416F2C0B01}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {42E1C8C0-A163-44CC-92B1-8F416F2C0B01}.Release|Any CPU.Build.0 = Release|Any CPU
+ {42E1C8C0-A163-44CC-92B1-8F416F2C0B01}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.ActiveCfg = Debug|Any CPU
+ {42E1C8C0-A163-44CC-92B1-8F416F2C0B01}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.Build.0 = Debug|Any CPU
+ {5A315F92-80D2-4C60-A5A4-22E027AC7E7E}.DEBUG MONO|Any CPU.ActiveCfg = Debug|Any CPU
+ {5A315F92-80D2-4C60-A5A4-22E027AC7E7E}.DEBUG MONO|Any CPU.Build.0 = Debug|Any CPU
+ {5A315F92-80D2-4C60-A5A4-22E027AC7E7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5A315F92-80D2-4C60-A5A4-22E027AC7E7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5A315F92-80D2-4C60-A5A4-22E027AC7E7E}.MONOTOUCH|Any CPU.ActiveCfg = Debug|Any CPU
+ {5A315F92-80D2-4C60-A5A4-22E027AC7E7E}.MonoTouch|Any CPU.ActiveCfg = MonoTouch|Any CPU
+ {5A315F92-80D2-4C60-A5A4-22E027AC7E7E}.MONOTOUCH|Any CPU.Build.0 = Debug|Any CPU
+ {5A315F92-80D2-4C60-A5A4-22E027AC7E7E}.MonoTouch|Any CPU.Build.0 = MonoTouch|Any CPU
+ {5A315F92-80D2-4C60-A5A4-22E027AC7E7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5A315F92-80D2-4C60-A5A4-22E027AC7E7E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5A315F92-80D2-4C60-A5A4-22E027AC7E7E}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.ActiveCfg = STATIC_ONLY NO_EXPRESSIONS|Any CPU
+ {5A315F92-80D2-4C60-A5A4-22E027AC7E7E}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.Build.0 = STATIC_ONLY NO_EXPRESSIONS|Any CPU
+ {616B7099-222A-4EF1-AA46-17156B7EA102}.DEBUG MONO|Any CPU.ActiveCfg = Debug|Any CPU
+ {616B7099-222A-4EF1-AA46-17156B7EA102}.DEBUG MONO|Any CPU.Build.0 = Debug|Any CPU
+ {616B7099-222A-4EF1-AA46-17156B7EA102}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {616B7099-222A-4EF1-AA46-17156B7EA102}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {616B7099-222A-4EF1-AA46-17156B7EA102}.MONOTOUCH|Any CPU.ActiveCfg = Debug|Any CPU
+ {616B7099-222A-4EF1-AA46-17156B7EA102}.MonoTouch|Any CPU.ActiveCfg = Debug|Any CPU
+ {616B7099-222A-4EF1-AA46-17156B7EA102}.MonoTouch|Any CPU.Build.0 = Debug|Any CPU
+ {616B7099-222A-4EF1-AA46-17156B7EA102}.MONOTOUCH|Any CPU.Build.0 = Debug|Any CPU
+ {616B7099-222A-4EF1-AA46-17156B7EA102}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {616B7099-222A-4EF1-AA46-17156B7EA102}.Release|Any CPU.Build.0 = Release|Any CPU
+ {616B7099-222A-4EF1-AA46-17156B7EA102}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.ActiveCfg = Debug|Any CPU
+ {616B7099-222A-4EF1-AA46-17156B7EA102}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.Build.0 = Debug|Any CPU
+ {680A1709-25EB-4D52-A87F-EE03FFD94BAA}.DEBUG MONO|Any CPU.ActiveCfg = DEBUG MONO|Any CPU
+ {680A1709-25EB-4D52-A87F-EE03FFD94BAA}.DEBUG MONO|Any CPU.Build.0 = DEBUG MONO|Any CPU
+ {680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {680A1709-25EB-4D52-A87F-EE03FFD94BAA}.MonoTouch|Any CPU.ActiveCfg = Debug|Any CPU
+ {680A1709-25EB-4D52-A87F-EE03FFD94BAA}.MONOTOUCH|Any CPU.ActiveCfg = MONOTOUCH|Any CPU
+ {680A1709-25EB-4D52-A87F-EE03FFD94BAA}.MonoTouch|Any CPU.Build.0 = Debug|Any CPU
+ {680A1709-25EB-4D52-A87F-EE03FFD94BAA}.MONOTOUCH|Any CPU.Build.0 = MONOTOUCH|Any CPU
+ {680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {680A1709-25EB-4D52-A87F-EE03FFD94BAA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {680A1709-25EB-4D52-A87F-EE03FFD94BAA}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.ActiveCfg = Debug|Any CPU
+ {680A1709-25EB-4D52-A87F-EE03FFD94BAA}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.Build.0 = Debug|Any CPU
+ {6E240294-9D93-4C09-9BB0-38D82A22DEEE}.DEBUG MONO|Any CPU.ActiveCfg = Debug|Any CPU
+ {6E240294-9D93-4C09-9BB0-38D82A22DEEE}.DEBUG MONO|Any CPU.Build.0 = Debug|Any CPU
+ {6E240294-9D93-4C09-9BB0-38D82A22DEEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6E240294-9D93-4C09-9BB0-38D82A22DEEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6E240294-9D93-4C09-9BB0-38D82A22DEEE}.MONOTOUCH|Any CPU.ActiveCfg = Debug|Any CPU
+ {6E240294-9D93-4C09-9BB0-38D82A22DEEE}.MonoTouch|Any CPU.ActiveCfg = Debug|Any CPU
+ {6E240294-9D93-4C09-9BB0-38D82A22DEEE}.MonoTouch|Any CPU.Build.0 = Debug|Any CPU
+ {6E240294-9D93-4C09-9BB0-38D82A22DEEE}.MONOTOUCH|Any CPU.Build.0 = Debug|Any CPU
+ {6E240294-9D93-4C09-9BB0-38D82A22DEEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6E240294-9D93-4C09-9BB0-38D82A22DEEE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6E240294-9D93-4C09-9BB0-38D82A22DEEE}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.ActiveCfg = Debug|Any CPU
+ {6E240294-9D93-4C09-9BB0-38D82A22DEEE}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.Build.0 = Debug|Any CPU
{71ACDF37-9696-42B8-B15A-5178C0C8F0E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71ACDF37-9696-42B8-B15A-5178C0C8F0E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71ACDF37-9696-42B8-B15A-5178C0C8F0E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -57,6 +133,14 @@ Global
{8E126CCA-C7B2-4108-99F0-1F675C23A69B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E126CCA-C7B2-4108-99F0-1F675C23A69B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E126CCA-C7B2-4108-99F0-1F675C23A69B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {982416DB-C143-4028-A0C3-CF41892D18D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {982416DB-C143-4028-A0C3-CF41892D18D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {982416DB-C143-4028-A0C3-CF41892D18D3}.MonoTouch|Any CPU.ActiveCfg = MonoTouch|Any CPU
+ {982416DB-C143-4028-A0C3-CF41892D18D3}.MonoTouch|Any CPU.Build.0 = MonoTouch|Any CPU
+ {982416DB-C143-4028-A0C3-CF41892D18D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {982416DB-C143-4028-A0C3-CF41892D18D3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {982416DB-C143-4028-A0C3-CF41892D18D3}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.ActiveCfg = STATIC_ONLY NO_EXPRESSIONS|Any CPU
+ {982416DB-C143-4028-A0C3-CF41892D18D3}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.Build.0 = STATIC_ONLY NO_EXPRESSIONS|Any CPU
{A461423E-8232-42D6-AA34-8DEC97F6D8F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A461423E-8232-42D6-AA34-8DEC97F6D8F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A461423E-8232-42D6-AA34-8DEC97F6D8F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -73,14 +157,13 @@ Global
{EBFBC3BF-10E1-4482-B9BE-A516934C099A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBFBC3BF-10E1-4482-B9BE-A516934C099A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EBFBC3BF-10E1-4482-B9BE-A516934C099A}.Release|Any CPU.Build.0 = Release|Any CPU
- {A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}.Release|Any CPU.Build.0 = Release|Any CPU
- {A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A9AE40FF-1A21-414A-9FE7-3BE13644CC6D}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {982416DB-C143-4028-A0C3-CF41892D18D3} = {0383DE2B-50A5-449C-AAC0-4DDD753764DD}
+ {42E1C8C0-A163-44CC-92B1-8F416F2C0B01} = {0383DE2B-50A5-449C-AAC0-4DDD753764DD}
+ {680A1709-25EB-4D52-A87F-EE03FFD94BAA} = {0383DE2B-50A5-449C-AAC0-4DDD753764DD}
+ {6E240294-9D93-4C09-9BB0-38D82A22DEEE} = {0383DE2B-50A5-449C-AAC0-4DDD753764DD}
+ {5A315F92-80D2-4C60-A5A4-22E027AC7E7E} = {0383DE2B-50A5-449C-AAC0-4DDD753764DD}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
version = 0.1
15 ServiceStack/src/ServiceStack.Authentication.OpenId/GoogleOpenIdOAuthProvider.cs
View
@@ -0,0 +1,15 @@
+using ServiceStack.Configuration;
+
+namespace ServiceStack.Authentication.OpenId
+{
+ public class GoogleOpenIdOAuthProvider : OpenIdOAuthProvider
+ {
+ public const string Name = "GoogleOpenId";
+ public static string Realm = "https://www.google.com/accounts/o8/id";
+
+ public GoogleOpenIdOAuthProvider(IResourceManager appSettings)
+ : base(appSettings, Name, Realm) { }
+
+
+ }
+}
13 ServiceStack/src/ServiceStack.Authentication.OpenId/MyOpenIdOAuthProvider.cs
View
@@ -0,0 +1,13 @@
+using ServiceStack.Configuration;
+
+namespace ServiceStack.Authentication.OpenId
+{
+ public class MyOpenIdOAuthProvider : OpenIdOAuthProvider
+ {
+ public const string Name = "MyOpenId";
+ public static string Realm = "http://www.myopenid.com";
+
+ public MyOpenIdOAuthProvider(IResourceManager appSettings)
+ : base(appSettings, Name, Realm) { }
+ }
+}
311 ServiceStack/src/ServiceStack.Authentication.OpenId/OpenIdOAuthProvider.cs
View
@@ -0,0 +1,311 @@
+using System;
+using System.Collections.Generic;
+using DotNetOpenAuth.Messaging;
+using DotNetOpenAuth.OpenId.Extensions.AttributeExchange;
+using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration;
+using DotNetOpenAuth.OpenId.RelyingParty;
+using ServiceStack.Common;
+using ServiceStack.Common.Web;
+using ServiceStack.Configuration;
+using ServiceStack.ServiceClient.Web;
+using ServiceStack.ServiceHost;
+using ServiceStack.ServiceInterface;
+using ServiceStack.ServiceInterface.Auth;
+using ServiceStack.Text;
+
+namespace ServiceStack.Authentication.OpenId
+{
+ public class OpenIdOAuthProvider : OAuthProvider
+ {
+ public const string DefaultName = "OpenId";
+
+ public OpenIdOAuthProvider(IResourceManager appSettings, string name = DefaultName, string realm = null)
+ : base(appSettings, realm, name) { }
+
+ public virtual ClaimsRequest CreateClaimsRequest(IHttpRequest httpReq)
+ {
+ return new ClaimsRequest {
+ Country = DemandLevel.Request,
+ Email = DemandLevel.Request,
+ Gender = DemandLevel.Require,
+ PostalCode = DemandLevel.Require,
+ TimeZone = DemandLevel.Require,
+ };
+ }
+
+ public override object Authenticate(IServiceBase authService, IAuthSession session, Auth request)
+ {
+ var tokens = Init(authService, ref session, request);
+
+ var httpReq = authService.RequestContext.Get<IHttpRequest>();
+ var isOpenIdRequest = !httpReq.GetParam("openid.mode").IsNullOrEmpty();
+
+ if (!isOpenIdRequest)
+ {
+ var openIdUrl = httpReq.GetParam("OpenIdUrl") ?? base.AuthRealm;
+ if (openIdUrl.IsNullOrEmpty())
+ throw new ArgumentException("'OpenIdUrl' is required a required field");
+
+ try
+ {
+ using (var openid = new OpenIdRelyingParty())
+ {
+ var openIdRequest = openid.CreateRequest(openIdUrl);
+
+ AddAttributeExchangeExtensions(openIdRequest);
+
+ // This is where you would add any OpenID extensions you wanted
+ // to include in the authentication request.
+ openIdRequest.AddExtension(CreateClaimsRequest(httpReq));
+
+ // Send your visitor to their Provider for authentication.
+ var openIdResponse = openIdRequest.RedirectingResponse;
+ var contentType = openIdResponse.Headers[HttpHeaders.ContentType];
+ var httpResult = new HttpResult(openIdResponse.ResponseStream, contentType) {
+ StatusCode = openIdResponse.Status,
+ StatusDescription = "Moved Temporarily",
+ };
+ foreach (string header in openIdResponse.Headers)
+ {
+ httpResult.Headers[header] = openIdResponse.Headers[header];
+ }
+ // Save the current session to keep the ReferrerUrl available (similar to Facebook provider)
+ authService.SaveSession(session, SessionExpiry);
+ return httpResult;
+ }
+ }
+ catch (ProtocolException ex)
+ {
+ Log.Error("Failed to login to {0}".Fmt(openIdUrl), ex);
+ return authService.Redirect(session.ReferrerUrl.AddHashParam("f", "Unknown"));
+ }
+ }
+
+ if (isOpenIdRequest)
+ {
+ using (var openid = new OpenIdRelyingParty())
+ {
+ var response = openid.GetResponse();
+ if (response != null)
+ {
+ switch (response.Status)
+ {
+ case AuthenticationStatus.Authenticated:
+
+ var authInfo = CreateAuthInfo(response);
+
+ // Use FormsAuthentication to tell ASP.NET that the user is now logged in,
+ // with the OpenID Claimed Identifier as their username.
+ session.IsAuthenticated = true;
+ authService.SaveSession(session, SessionExpiry);
+ OnAuthenticated(authService, session, tokens, authInfo);
+
+ //Haz access!
+ return authService.Redirect(session.ReferrerUrl.AddHashParam("s", "1"));
+
+ case AuthenticationStatus.Canceled:
+ return authService.Redirect(session.ReferrerUrl.AddHashParam("f", "ProviderCancelled"));
+
+ case AuthenticationStatus.Failed:
+ return authService.Redirect(session.ReferrerUrl.AddHashParam("f", "Unknown"));
+ }
+ }
+ }
+ }
+
+ //Shouldn't get here
+ return authService.Redirect(session.ReferrerUrl.AddHashParam("f", "Unknown"));
+ }
+
+ protected virtual Dictionary<string, string> CreateAuthInfo(IAuthenticationResponse response)
+ {
+ // This is where you would look for any OpenID extension responses included
+ // in the authentication assertion.
+ var claimsResponse = response.GetExtension<ClaimsResponse>();
+ var authInfo = claimsResponse.ToDictionary();
+
+ authInfo["user_id"] = response.ClaimedIdentifier; //a url
+
+ // Store off the "friendly" username to display -- NOT for username lookup
+ authInfo["openid_ref"] = response.FriendlyIdentifierForDisplay;
+
+ var provided = GetAttributeEx(response);
+ foreach (var entry in provided)
+ {
+ authInfo[entry.Key] = entry.Value;
+ }
+
+ return authInfo;
+ }
+
+ protected override void LoadUserAuthInfo(AuthUserSession userSession, IOAuthTokens tokens, Dictionary<string, string> authInfo)
+ {
+ if (authInfo.ContainsKey("user_id"))
+ tokens.UserId = authInfo.GetValueOrDefault("user_id");
+
+ if (authInfo.ContainsKey("name"))
+ tokens.DisplayName = authInfo.GetValueOrDefault("name");
+
+ if (authInfo.ContainsKey("FullName"))
+ {
+ tokens.FullName = authInfo.GetValueOrDefault("FullName");
+ if (tokens.DisplayName.IsNullOrEmpty())
+ tokens.DisplayName = tokens.FullName;
+ }
+
+ if (authInfo.ContainsKey("Email"))
+ tokens.Email = authInfo.GetValueOrDefault("Email");
+
+ if (authInfo.ContainsKey("BirthDate"))
+ tokens.BirthDate = authInfo.GetValueOrDefault("BirthDate").FromJsv<DateTime?>();
+
+ if (authInfo.ContainsKey("BirthDateRaw"))
+ tokens.BirthDateRaw = authInfo.GetValueOrDefault("BirthDateRaw");
+
+ if (authInfo.ContainsKey("Country"))
+ tokens.Country = authInfo.GetValueOrDefault("Country");
+
+ if (authInfo.ContainsKey("Culture"))
+ tokens.Culture = authInfo.GetValueOrDefault("Culture");
+
+ if (authInfo.ContainsKey("Gender"))
+ tokens.Gender = authInfo.GetValueOrDefault("Gender");
+
+ if (authInfo.ContainsKey("MailAddress"))
+ tokens.MailAddress = authInfo.GetValueOrDefault("MailAddress");
+
+ if (authInfo.ContainsKey("Nickname"))
+ tokens.Nickname = authInfo.GetValueOrDefault("Nickname");
+
+ if (authInfo.ContainsKey("PostalCode"))
+ tokens.PostalCode = authInfo.GetValueOrDefault("PostalCode");
+
+ if (authInfo.ContainsKey("TimeZone"))
+ tokens.TimeZone = authInfo.GetValueOrDefault("TimeZone");
+
+ LoadUserOAuthProvider(userSession, tokens);
+ }
+
+ public override void LoadUserOAuthProvider(IAuthSession authSession, IOAuthTokens tokens)
+ {
+ var userSession = authSession as AuthUserSession;
+ if (userSession == null) return;
+ }
+
+ private void AddAttributeExchangeExtensions(IAuthenticationRequest auth)
+ {
+ // Try to use OpenId 2.0's attribute exchange
+ var fetch = new FetchRequest();
+ //Technically, http://axschema.org/... are "standard", but we'll still find these in the wild
+ fetch.Attributes.Add(new AttributeRequest("http://schema.openid.net/namePerson", false));
+ fetch.Attributes.Add(new AttributeRequest("http://schema.openid.net/contact/email", false));
+
+ fetch.Attributes.AddRequired("http://axschema.org/contact/country/home");
+ fetch.Attributes.AddRequired("http://axschema.org/namePerson/first");
+ fetch.Attributes.AddRequired("http://axschema.org/namePerson/last");
+ fetch.Attributes.AddRequired("http://axschema.org/pref/language");
+ fetch.Attributes.AddRequired("http://schemas.openid.net/ax/api/user_id");
+
+ //Standard compliant AX schema
+ fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Name.FullName, false));
+
+ //For... no good reason, really, google OpenId requires you "require" an e-mail address to get it
+ bool requireEmail = auth.Provider.Uri.AbsoluteUri.Contains(".google.com");
+ fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email, requireEmail));
+
+ auth.AddExtension(fetch);
+ }
+
+ /// <summary>
+ /// Extracts an Attribute Exchange response, if one exists
+ /// </summary>
+ private Dictionary<string, string> GetAttributeEx(IAuthenticationResponse response)
+ {
+ var ret = new Dictionary<string, string>();
+
+ var fetchResponse = response.GetExtension<FetchResponse>();
+
+ if (fetchResponse == null) return ret;
+
+ var names = new List<string>();
+ var emails = new List<string>();
+
+ if (fetchResponse.Attributes.Contains("http://schema.openid.net/namePerson"))
+ names.AddRange(fetchResponse.Attributes["http://schema.openid.net/namePerson"].Values);
+
+ if (fetchResponse.Attributes.Contains(WellKnownAttributes.Name.FullName))
+ names.AddRange(fetchResponse.Attributes[WellKnownAttributes.Name.FullName].Values);
+
+ if (fetchResponse.Attributes.Contains(WellKnownAttributes.Name.Alias))
+ names.AddRange(fetchResponse.Attributes[WellKnownAttributes.Name.Alias].Values);
+
+ if (fetchResponse.Attributes.Contains(WellKnownAttributes.Name.First))
+ names.AddRange(fetchResponse.Attributes[WellKnownAttributes.Name.First].Values);
+
+ if (fetchResponse.Attributes.Contains(WellKnownAttributes.Name.Last))
+ names.AddRange(fetchResponse.Attributes[WellKnownAttributes.Name.Last].Values);
+
+ if (fetchResponse.Attributes.Contains("http://schema.openid.net/contact/email"))
+ emails.AddRange(fetchResponse.Attributes["http://schema.openid.net/contact/email"].Values);
+
+ if (fetchResponse.Attributes.Contains(WellKnownAttributes.Contact.Email))
+ emails.AddRange(fetchResponse.Attributes[WellKnownAttributes.Contact.Email].Values);
+
+ if (names.Count > 0)
+ ret["FullName"] = names[0];
+
+ if (emails.Count > 0)
+ ret["Email"] = emails[0];
+
+ return ret;
+ }
+
+ public override bool IsAuthorized(IAuthSession session, IOAuthTokens tokens, Auth request = null)
+ {
+ if (request != null)
+ {
+ if (!LoginMatchesSession(session, request.UserName)) return false;
+ }
+
+ // For OpenId, AccessTokenSecret is null/empty, but UserId is populated w/ authenticated url from openId providers
+ return tokens != null && !string.IsNullOrEmpty(tokens.UserId);
+ }
+ }
+
+
+ public static class OpenIdExtensions
+ {
+ public static Dictionary<string, string> ToDictionary(this ClaimsResponse response)
+ {
+ var map = new Dictionary<string, string>();
+ if (response == null) return map;
+
+ if (response.BirthDate.HasValue)
+ map["BirthDate"] = response.BirthDate.Value.ToJsv();
+ if (!response.BirthDateRaw.IsNullOrEmpty())
+ map["BirthDateRaw"] = response.BirthDateRaw;
+ if (!response.Country.IsNullOrEmpty())
+ map["Country"] = response.Country;
+ if (response.Culture != null)
+ map["Culture"] = response.Culture.TwoLetterISOLanguageName;
+ if (!response.Email.IsNullOrEmpty())
+ map["Email"] = response.Email;
+ if (!response.FullName.IsNullOrEmpty())
+ map["FullName"] = response.FullName;
+ if (response.Gender.HasValue)
+ map["Gender"] = response.Gender.Value.ToString();
+ if (!response.Language.IsNullOrEmpty())
+ map["Language"] = response.Language;
+ if (response.MailAddress != null)
+ map["MailAddress"] = response.MailAddress.ToJsv();
+ if (!response.Nickname.IsNullOrEmpty())
+ map["Nickname"] = response.Nickname;
+ if (!response.PostalCode.IsNullOrEmpty())
+ map["PostalCode"] = response.PostalCode;
+ if (!response.TimeZone.IsNullOrEmpty())
+ map["TimeZone"] = response.TimeZone;
+
+ return map;
+ }
+ }
+}
36 ServiceStack/src/ServiceStack.Authentication.OpenId/Properties/AssemblyInfo.cs
View
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ServiceStack.Authentication.OpenId")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ServiceStack.Authentication.OpenId")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f6e833d0-068e-4276-abd0-1462055501d5")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
87 ServiceStack/src/ServiceStack.Authentication.OpenId/ServiceStack.Authentication.OpenId.csproj
View
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{6E240294-9D93-4C09-9BB0-38D82A22DEEE}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ServiceStack.Authentication.OpenId</RootNamespace>
+ <AssemblyName>ServiceStack.Authentication.OpenId</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="DotNetOpenAuth, Version=4.1.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\DotNetOpenAuth.Ultimate.4.1.2.12274\lib\net35-full\DotNetOpenAuth.dll</HintPath>
+ </Reference>
+ <Reference Include="ServiceStack.Text">
+ <HintPath>..\..\lib\ServiceStack.Text.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="GoogleOpenIdOAuthProvider.cs" />
+ <Compile Include="MyOpenIdOAuthProvider.cs" />
+ <Compile Include="OpenIdOAuthProvider.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="YahooOpenIdOAuthProvider.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\ServiceStack.Common\ServiceStack.Common.csproj">
+ <Project>{982416DB-C143-4028-A0C3-CF41892D18D3}</Project>
+ <Name>ServiceStack.Common</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\ServiceStack.Interfaces\ServiceStack.Interfaces.csproj">
+ <Project>{42E1C8C0-A163-44CC-92B1-8F416F2C0B01}</Project>
+ <Name>ServiceStack.Interfaces</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\ServiceStack.ServiceInterface\ServiceStack.ServiceInterface.csproj">
+ <Project>{5A315F92-80D2-4C60-A5A4-22E027AC7E7E}</Project>
+ <Name>ServiceStack.ServiceInterface</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\ServiceStack\ServiceStack.csproj">
+ <Project>{680A1709-25EB-4D52-A87F-EE03FFD94BAA}</Project>
+ <Name>ServiceStack</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
13 ServiceStack/src/ServiceStack.Authentication.OpenId/YahooOpenIdOAuthProvider.cs
View
@@ -0,0 +1,13 @@
+using ServiceStack.Configuration;
+
+namespace ServiceStack.Authentication.OpenId
+{
+ public class YahooOpenIdOAuthProvider : OpenIdOAuthProvider
+ {
+ public const string Name = "YahooOpenId";
+ public static string Realm = "https://me.yahoo.com";
+
+ public YahooOpenIdOAuthProvider(IResourceManager appSettings)
+ : base(appSettings, Name, Realm) { }
+ }
+}
4 ServiceStack/src/ServiceStack.Authentication.OpenId/packages.config
View
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="DotNetOpenAuth.Ultimate" version="4.1.2.12274" />
+</packages>
96 ServiceStack/src/ServiceStack.Common/ActionExecExtensions.cs
View
@@ -0,0 +1,96 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using ServiceStack.Common.Support;
+
+#if NETFX_CORE
+using Windows.System.Threading;
+#endif
+
+namespace ServiceStack.Common
+{
+ public static class ActionExecExtensions
+ {
+ public static void ExecAllAndWait(this ICollection<Action> actions, TimeSpan timeout)
+ {
+ var waitHandles = new WaitHandle[actions.Count];
+ var i = 0;
+ foreach (var action in actions)
+ {
+ waitHandles[i++] = action.BeginInvoke(null, null).AsyncWaitHandle;
+ }
+
+ WaitAll(waitHandles, timeout);
+ }
+
+ public static List<WaitHandle> ExecAsync(this IEnumerable<Action> actions)
+ {
+ var waitHandles = new List<WaitHandle>();
+ foreach (var action in actions)
+ {
+ var waitHandle = new AutoResetEvent(false);
+ waitHandles.Add(waitHandle);
+ var commandExecsHandler = new ActionExecHandler(action, waitHandle);
+#if NETFX_CORE
+ ThreadPool.RunAsync(new WorkItemHandler((IAsyncAction) => commandExecsHandler.Execute()));
+#else
+ ThreadPool.QueueUserWorkItem(x => ((ActionExecHandler)x).Execute(), commandExecsHandler);
+#endif
+ }
+ return waitHandles;
+ }
+
+ public static bool WaitAll(this List<WaitHandle> waitHandles, int timeoutMs)
+ {
+ return WaitAll(waitHandles.ToArray(), timeoutMs);
+ }
+
+ public static bool WaitAll(this ICollection<WaitHandle> waitHandles, int timeoutMs)
+ {
+ return WaitAll(waitHandles.ToArray(), timeoutMs);
+ }
+
+ public static bool WaitAll(this ICollection<WaitHandle> waitHandles, TimeSpan timeout)
+ {
+ return WaitAll(waitHandles.ToArray(), (int)timeout.TotalMilliseconds);
+ }
+
+#if !SILVERLIGHT && !MONOTOUCH && !XBOX
+ public static bool WaitAll(this List<IAsyncResult> asyncResults, TimeSpan timeout)
+ {
+ var waitHandles = asyncResults.ConvertAll(x => x.AsyncWaitHandle);
+ return WaitAll(waitHandles.ToArray(), (int)timeout.TotalMilliseconds);
+ }
+
+ public static bool WaitAll(WaitHandle[] waitHandles, TimeSpan timeout)
+ {
+ return WaitAll(waitHandles, (int)timeout.TotalMilliseconds);
+ }
+
+ public static bool WaitAll(WaitHandle[] waitHandles, int timeOutMs)
+ {
+ // throws an exception if there are no wait handles
+ if (waitHandles == null) throw new ArgumentNullException("waitHandles");
+ if (waitHandles.Length == 0) return true;
+
+ if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
+ {
+ // WaitAll for multiple handles on an STA thread is not supported.
+ // CurrentThread is ApartmentState.STA when run under unit tests
+ var successfullyComplete = true;
+ foreach (var waitHandle in waitHandles)
+ {
+ successfullyComplete = successfullyComplete
+ && waitHandle.WaitOne(timeOutMs, false);
+ }
+ return successfullyComplete;
+ }
+
+ return WaitHandle.WaitAll(waitHandles, timeOutMs, false);
+ }
+#endif
+
+ }
+
+}
73 ServiceStack/src/ServiceStack.Common/AssertExtensions.cs
View
@@ -0,0 +1,73 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace ServiceStack.Common
+{
+ public static class AssertExtensions
+ {
+ public static void ThrowOnFirstNull(params object[] objs)
+ {
+ foreach (var obj in objs)
+ {
+ ThrowIfNull(obj);
+ }
+ }
+
+ public static void ThrowIfNull(this object obj)
+ {
+ ThrowIfNull(obj, null);
+ }
+
+ public static void ThrowIfNull(this object obj, string varName)
+ {
+ if (obj == null)
+ throw new ArgumentNullException(varName ?? "object");
+ }
+
+ public static void ThrowIfNullOrEmpty(this string strValue)
+ {
+ ThrowIfNullOrEmpty(strValue, null);
+ }
+
+ public static void ThrowIfNullOrEmpty(this string strValue, string varName)
+ {
+ if (string.IsNullOrEmpty(strValue))
+ throw new ArgumentNullException(varName ?? "string");
+ }
+
+ public static void ThrowIfNullOrEmpty(this ICollection collection)
+ {
+ ThrowIfNullOrEmpty(collection, null);
+ }
+
+ public static void ThrowIfNullOrEmpty(this ICollection collection, string varName)
+ {
+ var fieldName = varName ?? "collection";
+
+ if (collection == null)
+ throw new ArgumentNullException(fieldName);
+
+ if (collection.Count == 0)
+ throw new ArgumentException(fieldName + " is empty");
+ }
+
+ public static void ThrowIfNullOrEmpty<T>(this ICollection<T> collection)
+ {
+ ThrowIfNullOrEmpty(collection, null);
+ }
+
+ public static void ThrowIfNullOrEmpty<T>(this ICollection<T> collection, string varName)
+ {
+ var fieldName = varName ?? "collection";
+
+ if (collection == null)
+ throw new ArgumentNullException(fieldName);
+
+ if (collection.Count == 0)
+ throw new ArgumentException(fieldName + " is empty");
+ }
+
+ }
+
+}
20 ServiceStack/src/ServiceStack.Common/ByteArrayExtensions.cs
View
@@ -0,0 +1,20 @@
+namespace ServiceStack.Common
+{
+ public static class ByteArrayExtensions
+ {
+ public static bool AreEqual(this byte[] b1, byte[] b2)
+ {
+ if (b1 == b2) return true;
+ if (b1 == null || b2 == null) return false;
+ if (b1.Length != b2.Length) return false;
+
+ for (var i = 0; i < b1.Length; i++)
+ {
+ if (b1[i] != b2[i]) return false;
+ }
+
+ return true;
+ }
+
+ }
+}
152 ServiceStack/src/ServiceStack.Common/CryptUtils.cs
View
@@ -0,0 +1,152 @@
+using System;
+using System.Collections;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace ServiceStack.Common
+{
+ public enum RsaKeyLengths
+ {
+ Bit1024 = 1024,
+ Bit2048 = 2048,
+ Bit4096 = 4096
+ }
+
+ public class RsaKeyPair
+ {
+ public string PrivateKey { get; set; }
+ public string PublicKey { get; set; }
+ }
+
+ /// <summary>
+ /// Useful .NET Encryption Utils from:
+ /// http://andrewlocatelliwoodcock.com/2011/08/01/implementing-rsa-asymmetric-public-private-key-encryption-in-c-encrypting-under-the-public-key/
+ /// </summary>
+ public static class CryptUtils
+ {
+ /// <summary>
+ /// Encrypt an arbitrary string of data under the supplied public key
+ /// </summary>
+ /// <param name="publicKey">The public key to encrypt under</param>
+ /// <param name="data">The data to encrypt</param>
+ /// <param name="length">The bit length or strength of the public key: 1024, 2048 or 4096 bits. This must match the
+ /// value actually used to create the publicKey</param>
+ /// <returns></returns>
+ public static string Encrypt(string publicKey, string data, RsaKeyLengths length = RsaKeyLengths.Bit2048)
+ {
+ // full array of bytes to encrypt
+ byte[] bytesToEncrypt;
+
+ // worker byte array
+ byte[] block;
+
+ // encrypted bytes
+ byte[] encryptedBytes;
+
+ // length of bytesToEncrypt
+ var dataLength = 0;
+
+ // number of bytes in key
+ var keySize = 0;
+
+ // maximum block length to encrypt
+ var maxLength = 0;
+
+ // how many blocks must we encrypt to encrypt entire message?
+ var iterations = 0;
+
+ // the encrypted data
+ var encryptedData = new StringBuilder();
+
+ // instantiate the crypto provider with the correct key length
+ var rsaCryptoServiceProvider = new RSACryptoServiceProvider((int)length);
+
+ // initialize the RSA object from the given public key
+ rsaCryptoServiceProvider.FromXmlString(publicKey);
+
+ // convert data to byte array
+ bytesToEncrypt = Encoding.Unicode.GetBytes(data);
+
+ // get length of byte array
+ dataLength = bytesToEncrypt.Length;
+
+ // convert length of key from bits to bytes
+ keySize = (int)length / 8;
+
+ // .NET RSACryptoServiceProvider uses SHA1 Hash function
+ // use this to work out the maximum length to encrypt per block
+ maxLength = ((keySize - 2) - (2 * SHA1.Create().ComputeHash(bytesToEncrypt).Length));
+
+ // how many blocks do we need to encrypt?
+ iterations = dataLength / maxLength;
+
+ // encrypt block by block
+ for (int index = 0; index <= iterations; index++)
+ {
+ // is there more than one full block of data left to encrypt?
+ if ((dataLength - maxLength * index) > maxLength)
+ {
+ block = new byte[maxLength];
+ }
+ else
+ {
+ block = new byte[dataLength - maxLength * index];
+ }
+
+ // copy the required number of bytes from the array of bytes to encrypt to our worker array
+ Buffer.BlockCopy(bytesToEncrypt, maxLength * index, block, 0, block.Length);
+
+ // encrypt the current worker array block of bytes
+ encryptedBytes = rsaCryptoServiceProvider.Encrypt(block, true);
+
+ // RSACryptoServiceProvider reverses the order of encrypted bytesToEncrypt after encryption and before decryption.
+ // Undo this reversal for compatibility with other implementations
+ Array.Reverse(encryptedBytes);
+
+ // convert to base 64 string
+ encryptedData.Append(Convert.ToBase64String(encryptedBytes));
+ }
+
+ return encryptedData.ToString();
+ }
+
+ public static string Decrypt(string privateKey, string data, RsaKeyLengths length = RsaKeyLengths.Bit2048)
+ {
+ var dwKeySize = (int)length;
+ // TODO: Add Proper Exception Handlers
+ var rsaCryptoServiceProvider = new RSACryptoServiceProvider(dwKeySize);
+ rsaCryptoServiceProvider.FromXmlString(privateKey);
+
+ int base64BlockSize = ((dwKeySize / 8) % 3 != 0) ?
+ (((dwKeySize / 8) / 3) * 4) + 4 : ((dwKeySize / 8) / 3) * 4;
+
+ int iterations = data.Length / base64BlockSize;
+
+ var arrayList = new ArrayList();
+ for (int i = 0; i < iterations; i++)
+ {
+ byte[] encryptedBytes = Convert.FromBase64String(
+ data.Substring(base64BlockSize * i, base64BlockSize));
+ // Be aware the RSACryptoServiceProvider reverses the order of
+ // encrypted bytes after encryption and before decryption.
+ // If you do not require compatibility with Microsoft Cryptographic
+ // API (CAPI) and/or other vendors.
+ // Comment out the next line and the corresponding one in the
+ // EncryptString function.
+ Array.Reverse(encryptedBytes);
+ arrayList.AddRange(rsaCryptoServiceProvider.Decrypt(encryptedBytes, true));
+ }
+
+ return Encoding.Unicode.GetString(arrayList.ToArray(typeof(byte)) as byte[]);
+ }
+
+ public static RsaKeyPair CreatePublicAndPrivateKeyPair(RsaKeyLengths length = RsaKeyLengths.Bit2048)
+ {
+ var rsaProvider = new RSACryptoServiceProvider((int)length);
+ return new RsaKeyPair {
+ PrivateKey = rsaProvider.ToXmlString(true),
+ PublicKey = rsaProvider.ToXmlString(false),
+ };
+ }
+ }
+}
63 ServiceStack/src/ServiceStack.Common/DictionaryExtensions.cs
View
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using ServiceStack.Common.Extensions;
+
+namespace ServiceStack.Common
+{
+ public static class DictionaryExtensions
+ {
+ public static TValue GetValueOrDefault<TValue, TKey>(this Dictionary<TKey, TValue> dictionary, TKey key)
+ {
+ return dictionary.ContainsKey(key) ? dictionary[key] : default(TValue);
+ }
+
+ public static void ForEach<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, Action<TKey, TValue> onEachFn)
+ {
+ foreach (var entry in dictionary)
+ {
+ onEachFn(entry.Key, entry.Value);
+ }
+ }
+
+ public static bool EquivalentTo<K, V>(this IDictionary<K, V> thisMap, IDictionary<K, V> otherMap)
+ {
+ if (thisMap == null || otherMap == null) return thisMap == otherMap;
+ if (thisMap.Count != otherMap.Count) return false;
+
+ foreach (var entry in thisMap)
+ {
+ V otherValue;
+ if (!otherMap.TryGetValue(entry.Key, out otherValue)) return false;
+ if (!Equals(entry.Value, otherValue)) return false;
+ }
+
+ return true;
+ }
+
+ public static List<T> ConvertAll<T, K, V>(IDictionary<K, V> map, Func<K, V, T> createFn)
+ {
+ var list = new List<T>();
+ map.ForEach((kvp) => list.Add(createFn(kvp.Key, kvp.Value)));
+ return list;
+ }
+
+ public static V GetOrAdd<K, V>(this Dictionary<K, V> map, K key, Func<K, V> createFn)
+ {
+ //simulate ConcurrentDictionary.GetOrAdd
+ lock (map)
+ {
+ V val;
+ if (!map.TryGetValue(key, out val))
+ map[key] = val = createFn(key);
+
+ return val;
+ }
+ }
+
+ public static KeyValuePair<TKey, TValue> PairWith<TKey, TValue>(this TKey key, TValue value)
+ {
+ return new KeyValuePair<TKey, TValue>(key, value);
+ }
+ }
+}
44 ServiceStack/src/ServiceStack.Common/DirectoryInfoExtensions.cs
View
@@ -0,0 +1,44 @@
+#if !SILVERLIGHT
+using System.Collections.Generic;
+using System.IO;
+
+namespace ServiceStack.Common
+{
+ public static class DirectoryInfoExtensions
+ {
+ public static IEnumerable<string> GetMatchingFiles(this DirectoryInfo rootDirPath, string fileSearchPattern)
+ {
+ return GetMatchingFiles(rootDirPath.FullName, fileSearchPattern);
+ }
+
+ public static IEnumerable<string> GetMatchingFiles(string rootDirPath, string fileSearchPattern)
+ {
+ var pending = new Queue<string>();
+ pending.Enqueue(rootDirPath);
+ string[] paths;
+
+ while (pending.Count > 0)
+ {
+ rootDirPath = pending.Dequeue();
+ paths = Directory.GetFiles(rootDirPath, fileSearchPattern);
+ foreach (var filePath in paths) {
+ yield return filePath;
+ }
+ paths = Directory.GetDirectories(rootDirPath);