@@ -0,0 +1,2847 @@
+# oxAuth is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.%0A# Copyright (c) 2017, Gluu%0A#%0A# Author: Jose Gonzalez%0A# Adapted from previous 3.0.1 script of Yuriy Movchan%0A#%0A# oxConfigurationProperty required: %0A#   allowed_clients - comma separated list of dns of allowed clients %0A#   (i.e. the SCIM RP client)%0A%0Afrom org.xdi.model.custom.script.type.uma import UmaRptPolicyType%0Afrom org.xdi.model.uma import ClaimDefinitionBuilder%0Afrom org.xdi.util import StringHelper, ArrayHelper%0Afrom java.util import Arrays, ArrayList, HashSet%0Afrom java.lang import String%0A%0Aclass UmaRptPolicy(UmaRptPolicyType):%0A%0A    def __init__(self, currentTimeMillis):%0A        self.currentTimeMillis = currentTimeMillis%0A%0A    def init(self, configurationAttributes):%0A        print %22RPT Policy. Initializing ...%22%0A        self.clientsSet = self.prepareClientsSet(configurationAttributes)%0A        print %22RPT Policy. Initialized successfully%22%0A        return True%0A%0A    def destroy(self, configurationAttributes):%0A        print %22RPT Policy. Destroyed successfully%22%0A        return True%0A%0A    def getApiVersion(self):%0A        return 1%0A%0A    def getRequiredClaims(self, context): %0A        json = %22%22%22%5B%0A        %5D%22%22%22%0A        return ClaimDefinitionBuilder.build(json)%0A        %0A    def authorize(self, context): # context is reference of org.xdi.oxauth.uma.authorization.UmaAuthorizationContext%0A        print %22RPT Policy. Authorizing ...%22%0A        client_id = context.getHttpRequest().getParameter(%22client_id%22)%0A            %0A        print %22UmaRptPolicy. client_id=%22, client_id%0A%0A     if (StringHelper.isEmpty(client_id)):%0A            return False%0A     %0A        if (self.clientsSet.contains(client_id)):%0A            print %22UmaRptPolicy. Authorizing client%22%0A            return True%0A        else:%0A            print %22UmaRptPolicy. Client isn't authorized%22%0A            return False%0A%0A        %0A    def prepareClientsSet(self, configurationAttributes):%0A        clientsSet = HashSet()%0A        if (not configurationAttributes.containsKey(%22allowed_clients%22)):%0A            return clientsSet%0A%0A        allowedClientsList = configurationAttributes.get(%22allowed_clients%22).getValue2()%0A        if (StringHelper.isEmpty(allowedClientsList)):%0A            print %22UmaRptPolicy. The property allowed_clients is empty%22%0A            return clientsSet    %0A%0A        allowedClientsListArray = StringHelper.split(allowedClientsList, %22,%22)%0A        if (ArrayHelper.isEmpty(allowedClientsListArray)):%0A            print %22UmaRptPolicy. No clients specified in allowed_clients property%22%0A            return clientsSet%0A        %0A        # Convert to HashSet to quick search%0A        i = 0%0A        count = len(allowedClientsListArray)%0A        while (i %3C count):%0A            client = allowedClientsListArray%5Bi%5D%0A            clientsSet.add(client)%0A            i = i + 1%0A%0A        return clientsSet%0A

Add UMA 2.0 SCIM/Passport script