1 module hunt.shiro.Exceptions; 2 3 import hunt.Exceptions; 4 5 6 class ShiroException : Exception { 7 mixin BasicExceptionCtors; 8 } 9 10 class AuthenticationException : ShiroException { 11 mixin BasicExceptionCtors; 12 } 13 14 /** 15 * Exception thrown if there is a problem during authorization (access control check). 16 */ 17 class AuthorizationException : ShiroException { 18 mixin BasicExceptionCtors; 19 } 20 21 /** 22 * Root class of all Shiro exceptions related to caching operations. 23 * 24 * @since 0.2 25 */ 26 class CacheException : ShiroException { 27 mixin BasicExceptionCtors; 28 } 29 30 /** 31 * Root exception related to issues during encoding or decoding. 32 * 33 * @since 0.9 34 */ 35 class CodecException : ShiroException { 36 mixin BasicExceptionCtors; 37 } 38 39 /** 40 * Root exception indicating there was a problem parsing or processing the Shiro configuration. 41 * 42 * @since 0.9 43 */ 44 // class ConfigurationException : ShiroException{ 45 // mixin BasicExceptionCtors; 46 // } 47 48 /** 49 * Base Shiro exception for problems encountered during cryptographic operations. 50 * 51 * @since 1.0 52 */ 53 class CryptoException : ShiroException { 54 mixin BasicExceptionCtors; 55 } 56 57 /** 58 * Generic exception representing a problem when attempting to access data. 59 * <p/> 60 * The idea was borrowed from the Spring Framework, which has a nice model for a generic DAO exception hierarchy. 61 * Unfortunately we can't use it as we can't force a Spring API usage on all Shiro end-users. 62 */ 63 class DataAccessException : ShiroException { 64 mixin BasicExceptionCtors; 65 } 66 67 /** 68 * Exception thrown for errors related to {@link Environment} instances or configuration. 69 */ 70 class EnvironmentException : ShiroException { 71 mixin BasicExceptionCtors; 72 } 73 74 /** 75 * Thrown by {@link PermissionResolver#resolvePermission(string)} when the string being parsed is not 76 * valid for that resolver. 77 */ 78 class InvalidPermissionStringException : ShiroException { 79 mixin BasicExceptionCtors; 80 } 81 82 /** 83 * General security exception attributed to problems during interaction with the system during 84 * a session. 85 * 86 */ 87 class SessionException : ShiroException { 88 mixin BasicExceptionCtors; 89 } 90 91 class UnavailableSecurityManagerException : ShiroException { 92 mixin BasicExceptionCtors; 93 } 94 95 96 /** 97 * Exception thrown when attempting to acquire an object of a required type and that object does not equal, extend, or 98 * implement a specified {@code Class}. 99 */ 100 class RequiredTypeException : EnvironmentException { 101 mixin BasicExceptionCtors; 102 } 103 104 class AccountException : AuthenticationException { 105 mixin BasicExceptionCtors; 106 } 107 108 class CredentialsException : AuthenticationException { 109 mixin BasicExceptionCtors; 110 } 111 112 /** 113 * Exception thrown during the authentication process when an 114 * {@link hunt.shiro.authc.AuthenticationToken AuthenticationToken} implementation is encountered that is not 115 * supported by one or more configured {@link hunt.shiro.realm.Realm Realm}s. 116 * 117 * @see hunt.shiro.authc.pam.AuthenticationStrategy 118 */ 119 class UnsupportedTokenException : AuthenticationException { 120 mixin BasicExceptionCtors; 121 } 122 123 124 class ConcurrentAccessException : AccountException { 125 mixin BasicExceptionCtors; 126 } 127 128 129 class DisabledAccountException : AccountException { 130 mixin BasicExceptionCtors; 131 } 132 133 class ExcessiveAttemptsException : AccountException { 134 mixin BasicExceptionCtors; 135 } 136 137 /** 138 * Thrown during the authentication process when the system determines the submitted credential(s) 139 * has expired and will not allow login. 140 * 141 * <p>This is most often used to alert a user that their credentials (e.g. password or 142 * cryptography key) has expired and they should change the value. In such systems, the component 143 * invoking the authentication might catch this exception and redirect the user to an appropriate 144 * view to allow them to update their password or other credentials mechanism. 145 * 146 */ 147 class ExpiredCredentialsException : CredentialsException { 148 mixin BasicExceptionCtors; 149 } 150 151 /** 152 * Thrown when attempting to authenticate with credential(s) that do not match the actual 153 * credentials associated with the account principal. 154 * 155 * <p>For example, this exception might be thrown if a user's password is "secret" and 156 * "secrets" was entered by mistake. 157 * 158 * <p>Whether or not an application wishes to let 159 * the user know if they entered incorrect credentials is at the discretion of those 160 * responsible for defining the view and what happens when this exception occurs. 161 * 162 */ 163 class IncorrectCredentialsException : CredentialsException { 164 mixin BasicExceptionCtors; 165 } 166 167 /** 168 * A special kind of <tt>DisabledAccountException</tt>, this exception is thrown when attempting 169 * to authenticate and the corresponding account has been disabled explicitly due to being locked. 170 * 171 * <p>For example, an account can be locked if an administrator explicitly locks an account or 172 * perhaps an account can be locked automatically by the system if too many unsuccessful 173 * authentication attempts take place during a specific period of time (perhaps indicating a 174 * hacking attempt). 175 * 176 */ 177 class LockedAccountException : DisabledAccountException { 178 mixin BasicExceptionCtors; 179 } 180 181 182 /** 183 * Exception thrown if attempting to create a new {@code Subject} 184 * {@link hunt.shiro.subject.Subject#getSession() session}, but that {@code Subject}'s sessions are disabled. 185 * <p/> 186 * Note that this exception represents an invalid API usage scenario - where Shiro has been configured to disable 187 * sessions for a particular subject, but a developer is attempting to use that Subject's session. 188 * <p/> 189 * In other words, if this exception is encountered, it should be resolved by a configuration change for Shiro and 190 * <em>not</em> by checking every Subject to see if they are enabled or not (which would likely introduce very 191 * ugly/paranoid code checks everywhere a session is needed). This is why there is no 192 * {@code subject.isSessionEnabled()} method. 193 */ 194 class DisabledSessionException : SessionException { 195 mixin BasicExceptionCtors; 196 } 197 198 /** 199 * A special case of a StoppedSessionException. An expired session is a session that has 200 * stopped explicitly due to inactivity (i.e. time-out), as opposed to stopping due to log-out or 201 * other reason. 202 * 203 */ 204 class ExpiredSessionException : StoppedSessionException { 205 mixin BasicExceptionCtors; 206 } 207 208 209 /** 210 * Exception thrown when attempting to interact with the system under the pretense of a 211 * particular session (e.g. under a specific session id), and that session does not exist in 212 * the system. 213 */ 214 class UnknownSessionException : InvalidSessionException { 215 mixin BasicExceptionCtors; 216 } 217 218 /** 219 * Exception thrown when attempting to interact with the system under a session that has been 220 * stopped. A session may be stopped in any number of ways, most commonly due to explicit 221 * stopping (e.g. from logging out), or due to expiration. 222 */ 223 class StoppedSessionException : InvalidSessionException { 224 mixin BasicExceptionCtors; 225 } 226 227 /** 228 * Exception thrown when attempting to interact with the system under an established session 229 * when that session is considered invalid. The meaning of the term 'invalid' is based on 230 * application behavior. For example, a Session is considered invalid if it has been explicitly 231 * stopped (e.g. when a user logs-out or when explicitly 232 * {@link Session#stop() stopped} programmatically. A Session can also be 233 * considered invalid if it has expired. 234 * 235 * @see StoppedSessionException 236 * @see ExpiredSessionException 237 * @see UnknownSessionException 238 */ 239 class InvalidSessionException : SessionException { 240 mixin BasicExceptionCtors; 241 } 242 243 244 /** 245 * Root exception indicating invalid or incorrect usage of a data access resource. This is thrown 246 * typically when incorrectly using the resource or its API. 247 */ 248 class InvalidResourceUsageException : DataAccessException { 249 mixin BasicExceptionCtors; 250 } 251 252 253 /** 254 * Exception thrown when attempting to execute an authorization action when a successful 255 * authentication hasn't yet occurred. 256 * 257 * <p>Authorizations can only be performed after a successful 258 * authentication because authorization data (roles, permissions, etc) must always be associated 259 * with a known identity. Such a known identity can only be obtained upon a successful log-in. 260 */ 261 class UnauthenticatedException : AuthorizationException { 262 mixin BasicExceptionCtors; 263 } 264 265 /** 266 * Thrown to indicate a requested operation or access to a requested resource is not allowed. 267 */ 268 class UnauthorizedException : AuthorizationException { 269 mixin BasicExceptionCtors; 270 } 271 272 /** 273 * Thrown when a particular client (that is, host address) has not been enabled to access the system 274 * or if the client has been enabled access but is not permitted to perform a particular operation 275 * or access a particular resource. 276 * 277 */ 278 class HostUnauthorizedException : UnauthorizedException { 279 mixin BasicExceptionCtors; 280 } 281 282 283 /** 284 * Exception thrown when attempting to lookup or use a cryptographic algorithm that does not exist in the current 285 * JVM environment. 286 * 287 * @since 1.2 288 */ 289 public class UnknownAlgorithmException : CryptoException { 290 mixin BasicExceptionCtors; 291 } 292 293 294 /** 295 * Thrown when attempting to authenticate with a principal that doesn't exist in the system (e.g. 296 * by specifying a username that doesn't relate to a user account). 297 * 298 * <p>Whether or not an application wishes to alert a user logging in to the system of this fact is 299 * at the discretion of those responsible for designing the view and what happens when this 300 * exception occurs. 301 * 302 */ 303 class UnknownAccountException : AccountException { 304 mixin BasicExceptionCtors; 305 } 306 307 308 /** 309 * Exception thrown when a reference to an object is made, but that object cannot be found. This is most likely 310 * thrown due to a configuration line that references an object that hasn't been defined yet. 311 * 312 * @since 0.9 RC2 313 */ 314 class UnresolveableReferenceException : ConfigurationException { 315 mixin BasicExceptionCtors; 316 }