Signed-off-by: Simo Sorce <simo@redhat.com>
+class ProviderException(Exception):
+
+ def __init__(self, message):
+ super(ProviderException, self).__init__(message)
+ self.message = message
+
+ def __str__(self):
+ return repr(self.message)
+
+ def _debug(self, fact):
+ if cherrypy.config.get('debug', False):
+ cherrypy.log('%s: %s' % (self.__class__.__name__, fact))
+
+
class ProviderBase(PluginObject):
def __init__(self, name, path):
class ProviderBase(PluginObject):
def __init__(self, name, path):
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from ipsilon.providers.common import ProviderPageBase
+from ipsilon.providers.common import ProviderPageBase, ProviderException
from ipsilon.providers.saml2.provider import ServiceProvider
from ipsilon.providers.saml2.provider import InvalidProviderId
from ipsilon.providers.saml2.provider import NameIdNotAllowed
from ipsilon.providers.saml2.provider import ServiceProvider
from ipsilon.providers.saml2.provider import InvalidProviderId
from ipsilon.providers.saml2.provider import NameIdNotAllowed
-class AuthenticationError(Exception):
+class AuthenticationError(ProviderException):
def __init__(self, message, code):
super(AuthenticationError, self).__init__(message)
def __init__(self, message, code):
super(AuthenticationError, self).__init__(message)
+ self._debug('%s [%s]' % (message, code))
- def __str__(self):
- return repr(self.message)
-
-class InvalidRequest(Exception):
+class InvalidRequest(ProviderException):
def __init__(self, message):
super(InvalidRequest, self).__init__(message)
def __init__(self, message):
super(InvalidRequest, self).__init__(message)
- self.message = message
-
- def __str__(self):
- return repr(self.message)
class AuthenticateRequest(ProviderPageBase):
class AuthenticateRequest(ProviderPageBase):
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from ipsilon.providers.common import ProviderException
import cherrypy
import lasso
import cherrypy
import lasso
-class InvalidProviderId(Exception):
+class InvalidProviderId(ProviderException):
- def __init__(self, message):
- msg = 'Invalid Provider ID: %s' % message
- super(InvalidProviderId, self).__init__(msg)
- self.message = msg
-
- def __str__(self):
- return repr(self.message)
+ def __init__(self, code):
+ message = 'Invalid Provider ID: %s' % code
+ super(InvalidProviderId, self).__init__(message)
+ self._debug(message)
class NameIdNotAllowed(Exception):
class NameIdNotAllowed(Exception):
for nameid in allowed:
if nip.format == NAMEID_MAP[nameid]:
return nip.format
for nameid in allowed:
if nip.format == NAMEID_MAP[nameid]:
return nip.format
- raise NameIdNotAllowed()
+ raise NameIdNotAllowed(nip.format)
def _debug(self, fact):
if cherrypy.config.get('debug', False):
def _debug(self, fact):
if cherrypy.config.get('debug', False):