shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lhazlew...@apache.org
Subject svn commit: r915429 - in /incubator/shiro/trunk/core/src/main/java/org/apache/shiro: SecurityUtils.java UnavailableSecurityManagerException.java
Date Tue, 23 Feb 2010 16:58:40 GMT
Author: lhazlewood
Date: Tue Feb 23 16:58:39 2010
New Revision: 915429

URL: http://svn.apache.org/viewvc?rev=915429&view=rev
Log:
Changed SecurityUtils from throwing an IllegalStateException during SecurityManager lookup
to a more descriptive UnavailableSecurityManagerException

Added:
    incubator/shiro/trunk/core/src/main/java/org/apache/shiro/UnavailableSecurityManagerException.java
Modified:
    incubator/shiro/trunk/core/src/main/java/org/apache/shiro/SecurityUtils.java

Modified: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/SecurityUtils.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/SecurityUtils.java?rev=915429&r1=915428&r2=915429&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/SecurityUtils.java (original)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/SecurityUtils.java Tue Feb 23
16:58:39 2010
@@ -100,10 +100,11 @@
      * Returns the SecurityManager accessible to the calling code.
      *
      * @return the SecurityManager accessible to the calling code.
-     * @throws IllegalStateException if there is no {@code SecurityManager} instance available
to the calling code,
-     *                               which indicates an invalid application configuration.
+     * @throws UnavailableSecurityManagerException
+     *          if there is no {@code SecurityManager} instance available to the
+     *          calling code, which typically indicates an invalid application configuration.
      */
-    public static SecurityManager getSecurityManager() throws IllegalStateException {
+    public static SecurityManager getSecurityManager() throws UnavailableSecurityManagerException
{
         SecurityManager securityManager = ThreadContext.getSecurityManager();
         if (securityManager == null) {
             securityManager = SecurityUtils.securityManager;
@@ -112,7 +113,7 @@
             String msg = "No SecurityManager accessible to the calling code, either bound
to the " +
                     ThreadContext.class.getName() + " or as a vm static singleton.  This
is an invalid application " +
                     "configuration.";
-            throw new IllegalStateException(msg);
+            throw new UnavailableSecurityManagerException(msg);
         }
         return securityManager;
     }

Added: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/UnavailableSecurityManagerException.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/UnavailableSecurityManagerException.java?rev=915429&view=auto
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/UnavailableSecurityManagerException.java
(added)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/UnavailableSecurityManagerException.java
Tue Feb 23 16:58:39 2010
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro;
+
+/**
+ * Exception thrown when attempting to acquire the application's {@code SecurityManager}
instance, but Shiro's
+ * lookup heuristics cannot find one.  This typically indicates an invalid application configuration.
+ *
+ * @since 1.0
+ */
+public class UnavailableSecurityManagerException extends ShiroException {
+
+    public UnavailableSecurityManagerException(String message) {
+        super(message);
+    }
+
+    public UnavailableSecurityManagerException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}



Mime
View raw message