Hello guys,

I'm still trying to configure a groovy script for access strategy but I 
have some errors

Here's my access-strategy.groovy


import org.apereo.cas.services.*
import java.util.*

class GroovyRegisteredAccessStrategy extends 
DefaultRegisteredServiceAccessStrategy {
    @Override
    boolean isServiceAccessAllowed() {
            return true
    }

    @Override
    boolean isServiceAccessAllowedForSso() {
            return true
    }

    @Override
    boolean doPrincipalAttributesAllowServiceAccess(String principal, 
Map<String, Object> attributes) {
    for (Map.Entry<String, Object> entry : map.entrySet()){
                if (entry.getKey().equals(principal)){
                        return true
                }
        }
        return false
    }
    }

    @Override
    java.net.URI getUnauthorizedRedirectUrl(){
    return "https://blocked-acc.html";
    }
}



org.springframework.webflow.execution.ActionExecutionException: Exception 
thrown executing org.apereo.cas.web.flow.login.InitialFlowSetupAction@2357e4bc 
in state 'null' of flow 'login' -- action execution attributes were 
'map[[empty]]'
Caused by: java.lang.NullPointerException
        at 
org.apereo.cas.services.GroovyRegisteredServiceAccessStrategy.isServiceAccessAllowed(GroovyRegisteredServiceAccessStrategy.java:49)
        at 
org.apereo.cas.web.flow.login.InitialFlowSetupAction.configureWebflowContextForService(InitialFlowSetupAction.java:62)
        at 
org.apereo.cas.web.flow.login.InitialFlowSetupAction.doExecute(InitialFlowSetupAction.java:51)
        at 
org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
        at sun.reflect.GeneratedMethodAccessor447.invoke(Unknown Source)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:216)
        at 
org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.invoke(GenericScope.java:470)
        at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
        at com.sun.proxy.$Proxy376.execute(Unknown Source)
        at 
org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51)
        ... 100 more


I'd like to set some attributes required and redirection url. 

For example if the account attribute = Active, i'll be able to join the 
service

but 

if the account attribute = blocked, i'll be redirect to 
https://blocked-acc.html <https://blocked.acc.html> 

or 

if the account attribute = waiting, i'll be redirect to 
https://waiting-acc/html <https://waiting.acc/html>

I'm new to groovy and I dont understand the issue, May I have some help 
pls? 

Regards,

-- 
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/4cf61a61-ce2f-4a01-84e4-bba76d84efef%40apereo.org.

Reply via email to