# 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
}
-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):
def get_valid_nameid(self, nip):
self._debug('Requested NameId [%s]' % (nip.format,))
- if nip.format == None:
+ if nip.format is None:
return NAMEID_MAP[self.default_nameid]
elif nip.format == lasso.SAML2_NAME_IDENTIFIER_FORMAT_UNSPECIFIED:
return NAMEID_MAP[self.default_nameid]
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):
cherrypy.log(fact)
+
+ def normalize_username(self, username):
+ if 'strip domain' in self._properties:
+ return username.split('@', 1)[0]
+ return username