def createClient(self, context): registerRequest = context.getRegisterRequest() configurationAttributes = context.getConfigurationAttibutes() client = context.getClient() print "Casa client registration. CreateClient method" redirectUris = client.getRedirectUris() print "Casa client registration. Redirect Uris: %s" % redirectUris credManagerClient = False for redirectUri in redirectUris: if self.clientRedirectUrisSet.contains(redirectUri): credManagerClient = True break if not credManagerClient: return True print "Casa client registration. Client is Janssen Casa" self.setClientScopes(client, configurationAttributes.get("scopes")) #Extend client lifetime for one year cal=GregorianCalendar() cal.add(1,10) client.setClientSecretExpiresAt(Date(cal.getTimeInMillis())) client.setTrustedClient(True) return True
def _to_timestamp(d): if isinstance(d, datetime.datetime): calendar = GregorianCalendar() calendar.set(d.year, d.month - 1, d.day, d.hour, d.minute, d.second) ts = Timestamp(calendar.getTimeInMillis()) ts.setNanos(d.microsecond * 1000) return ts else: return d
def updateClient(self, registerRequest, client, configurationAttributes): print "Casa client registration. UpdateClient method" redirectUris = client.getRedirectUris() print "Casa client registration. Redirect Uris: %s" % redirectUris credManagerClient = False for redirectUri in redirectUris: if (self.clientRedirectUrisSet.contains(redirectUri)): credManagerClient = True break if not credManagerClient: return True print "Casa client registration. Client is Cred-manager" newScopes = client.getScopes() scopeService = CdiUtil.bean(ScopeService) requiredScopes = [ "openid", "profile", "user_name", "clientinfo", "uma_protection" ] for scopeName in requiredScopes: scope = scopeService.getScopeByDisplayName(scopeName) if not scope.getIsDefault(): print "Casa client registration. Adding scope '%s'" % scopeName newScopes = ArrayHelper.addItemToStringArray( newScopes, scope.getDn()) print "Casa client registration. Result scopes: %s" % newScopes client.setScopes(newScopes) #Extend client lifetime for one year cal = GregorianCalendar() cal.add(1, 1) client.setClientSecretExpiresAt(Date(cal.getTimeInMillis())) #this style complains: client.setClientSecretExpiresAt(Date(Date().getTime + 31536000000)) return True
def createClient(self, registerRequest, client, configurationAttributes): print "Casa client registration. CreateClient method" redirectUris = client.getRedirectUris() print "Casa client registration. Redirect Uris: %s" % redirectUris credManagerClient = False for redirectUri in redirectUris: if self.clientRedirectUrisSet.contains(redirectUri): credManagerClient = True break if not credManagerClient: return True print "Casa client registration. Client is Gluu Casa" self.setClientScopes(client, configurationAttributes.get("scopes")) #Extend client lifetime for one year cal=GregorianCalendar() cal.add(1,1) client.setClientSecretExpiresAt(Date(cal.getTimeInMillis())) return True