This example doesnt work for me too: https://issues.apache.org/jira/browse/EXTCDI-262
El 20 de abril de 2012 09:57, José Luis Cetina <maxtorz...@gmail.com>escribió: > This dont work for me, here are my small test: > > *//DECISION VOTER* > import java.util.Set; > import javax.interceptor.InvocationContext; > import > org.apache.myfaces.extensions.cdi.core.api.security.AbstractAccessDecisionVoter; > import > org.apache.myfaces.extensions.cdi.core.api.security.AccessDecisionVoter; > import > org.apache.myfaces.extensions.cdi.core.api.security.SecurityViolation; > > @javax.enterprise.context.ApplicationScoped > public class PermissionAccessDecisionVoter extends > AbstractAccessDecisionVoter implements AccessDecisionVoter{ > > @Override > protected void checkPermission(InvocationContext ic, > Set<SecurityViolation> violations) { > System.out.println("verifying .........."); > } > } > --------------------------------------------------------------------------------------------------------------------------------------- > > *//Interface for annotation* > > import java.lang.annotation.ElementType; > import java.lang.annotation.Retention; > import java.lang.annotation.RetentionPolicy; > import java.lang.annotation.Target; > import javax.enterprise.inject.Stereotype; > import org.apache.myfaces.extensions.cdi.core.api.security.Secured; > > @Stereotype > @Target(value = {ElementType.METHOD, ElementType.FIELD, ElementType.TYPE}) > @Retention(value = RetentionPolicy.RUNTIME) > @Secured(PermissionAccessDecisionVoter.class) > public @interface ModuloPantallaBinding { > > } > > --------------------------------------------------------------------------------------------------------------------------------------- > *//ViewConfig* > import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig; > import org.apache.myfaces.extensions.cdi.jsf.api.config.view.Page; > > @Page(navigation = Page.NavigationMode.REDIRECT) > public class Index implements ViewConfig{ > > } > --------------------------------------------------------------------------------------------------------------------------------------- > > *//BEAN* > import java.io.Serializable; > import javax.faces.application.FacesMessage; > import javax.faces.context.FacesContext; > import javax.faces.event.ActionEvent; > import javax.inject.Named; > import org.apache.myfaces.extensions.cdi.core.api.config.view.View; > import > org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessScoped; > import org.apache.myfaces.extensions.cdi.jsf.api.config.view.InitView; > > @Named > @View(Index.class) > @ViewAccessScoped > @ModuloPantallaBinding > public class MyBean implements Serializable{ > > @InitView > public void init(){ > System.out.println("init method"); > } > > public void test(ActionEvent e){ > FacesContext.getCurrentInstance().addMessage(null, new > FacesMessage(FacesMessage.SEVERITY_INFO, "msg", "msg detail")); > } > } > > --------------------------------------------------------------------------------------------------------------------------------------- > > > *//XHTML* > I Have only a commandbutton in a form: > > <p:commandButton value="Test" update="public_messages" > actionListener="#{myBean.test}" /> > > > > --------------------------------------------------------------------------------------------------------------------------------------- > > *//LOG* > Información: > org.apache.myfaces.extensions.cdi.core.impl.provider.DefaultServiceProvider > installed successfully. > Información: > org.apache.myfaces.extensions.cdi.core.impl.provider.DefaultServiceProviderContext > installed successfully. > Información: Computed the following CODI ProjectStage: Production > Información: abc.Index will be used as page-definition. > Información: abc.MyBean will be used as page-bean. > Información: Initializing Mojarra 2.1.6 (SNAPSHOT 20111206) for context > '/WebApplication2' > Información: [Started] MyFaces CODI (Extensions CDI) alternative config > org.apache.myfaces.extensions.cdi.core.alternative.config.AlternativeCodiCoreConfig > is active (v1.0.4) > > Información: [Started] MyFaces CODI (Extensions CDI) alternative config > org.apache.myfaces.extensions.cdi.jsf.alternative.config.AlternativeJsfModuleConfig > is active (v1.0.4) > > Información: Running on PrimeFaces 3.2 > Información: WEB0671: Loading application [WebApplication2] at > [/WebApplication2] > Información: WebApplication2 was successfully deployed in 11,853 > milliseconds. > Información: WEB0169: Created HTTP listener [http-listener-2] on host/port > [0.0.0.0:8181] > Información: Grizzly Framework 1.9.46 started in: 69ms - bound to [ > 0.0.0.0:8181] > Información: [Started] MyFaces CODI (Extensions CDI) alternative config > org.apache.myfaces.extensions.cdi.core.alternative.scope.conversation.config.AlternativeWindowContextConfig > is active (v1.0.4) > > Información: [Started] MyFaces CODI (Extensions CDI) alternative config > org.apache.myfaces.extensions.cdi.core.alternative.scope.conversation.config.AlternativeConversationConfig > is active (v1.0.4) > > Información: [Started] MyFaces CODI JSF-Module v1.0.4 for JSF 2.0 > Used JSF implementation: Mojarra v2.1.6-SNAPSHOT > config implementation: > org.apache.myfaces.extensions.cdi.jsf.alternative.config.AlternativeJsfModuleConfig$Proxy$_$$_WeldClientProxy > config implementation: > org.apache.myfaces.extensions.cdi.jsf.alternative.config.AlternativeJsfModuleConfig > config implementation: > org.apache.myfaces.extensions.cdi.jsf.api.config.JsfModuleConfig > method: isInvalidValueAwareMessageInterpolatorEnabled > value: true > method: isUseViewConfigsAsNavigationCasesEnabled > value: true > method: isInitialRedirectEnabled > value: true > method: isAlwaysKeepMessages > value: true > config implementation: > org.apache.myfaces.extensions.cdi.core.alternative.scope.conversation.config.AlternativeWindowContextConfig$Proxy$_$$_WeldClientProxy > config implementation: > org.apache.myfaces.extensions.cdi.core.alternative.scope.conversation.config.AlternativeWindowContextConfig > config implementation: > org.apache.myfaces.extensions.cdi.core.api.scope.conversation.config.WindowContextConfig > method: isAddWindowIdToActionUrlsEnabled > value: false > method: getWindowContextTimeoutInMinutes > value: 60 > method: isCloseEmptyWindowContextsEnabled > value: false > method: isEagerWindowContextDetectionEnabled > value: true > method: isCreateWindowContextEventEnabled > value: false > method: isCloseWindowContextEventEnabled > value: false > method: isUrlParameterSupported > value: true > method: isUnknownWindowIdsAllowed > value: false > method: getMaxWindowContextCount > value: 64 > config implementation: > org.apache.myfaces.extensions.cdi.core.alternative.scope.conversation.config.AlternativeConversationConfig$Proxy$_$$_WeldClientProxy > config implementation: > org.apache.myfaces.extensions.cdi.core.alternative.scope.conversation.config.AlternativeConversationConfig > config implementation: > org.apache.myfaces.extensions.cdi.core.api.scope.conversation.config.ConversationConfig > method: isConversationRequiredEnabled > value: true > method: isRestartConversationEventEnabled > value: false > method: isCloseConversationEventEnabled > value: false > method: isStartConversationEventEnabled > value: false > method: getConversationTimeoutInMinutes > value: 30 > method: isScopeBeanEventEnabled > value: false > method: isAccessBeanEventEnabled > value: false > method: isUnscopeBeanEventEnabled > value: false > MessageContextConfig class: > org.apache.myfaces.extensions.cdi.message.impl.DefaultMessageContextConfig > MessageInterpolator class: class > org.apache.myfaces.extensions.cdi.jsf.impl.message.FacesMessageInterpolator > MessageResolver class: class > org.apache.myfaces.extensions.cdi.jsf.impl.message.JsfAwareApplicationMessagesMessageResolver > MessageHandler class: class > org.apache.myfaces.extensions.cdi.jsf.impl.message.JsfAwareMessageHandler > LocaleResolver class: class > org.apache.myfaces.extensions.cdi.jsf.impl.message.JsfAwareLocaleResolver > FormatterFactory class: class > org.apache.myfaces.extensions.cdi.message.impl.DefaultFormatterFactory > > Información: [Started] MyFaces CODI JPA-Module v1.0.4 > > Información: [Started] MyFaces CODI (Extensions CDI) Core v1.0.4 > Used CDI implementation: Weld v20111122-2001 > project-stage: Production > project-stage class: > org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage$Production > application-parameters: > name: com.sun.faces.forceLoadConfiguration > value: true > name: com.sun.faces.validateXml > value: true > name: javax.faces.PROJECT_STAGE > value: Development > config implementation: > org.apache.myfaces.extensions.cdi.core.alternative.config.AlternativeCodiCoreConfig$Proxy$_$$_WeldClientProxy > config implementation: > org.apache.myfaces.extensions.cdi.core.alternative.config.AlternativeCodiCoreConfig > config implementation: > org.apache.myfaces.extensions.cdi.core.api.config.CodiCoreConfig > method: isAdvancedQualifierRequiredForDependencyInjection > value: true > method: isConfigurationLoggingEnabled > value: true > method: isInvalidBeanCreationEventEnabled > value: false > > Advertencia: The value of the JSF 2 project stage (Development) is > different from the CODI project stage (Production) > Información: [Started] MyFaces CODI Scripting-Module v1.0.4 > > Información: [Started] MyFaces CODI Bean-Validation-Module v1.0.4 > *Información: init method* > > > > As you can see in the last line of log file the init method call correct > but the legen verifying.... never occur... > > BUT if i set the @Secure to the viewconfig it works (and removing the > @ModuloPantallaBinding annotation from managedbean): > > > *//ViewConfig with Secured annotation* > import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig; > import org.apache.myfaces.extensions.cdi.core.api.security.Secured; > import org.apache.myfaces.extensions.cdi.jsf.api.config.view.Page; > > @Page(navigation = Page.NavigationMode.REDIRECT) > @Secured(PermissionAccessDecisionVoter.class) > public class Index implements ViewConfig{ > > } > > --------------------------------------------------------------------------------------------------------------------------------------- > > * > * > *//LOG* > Información: > org.apache.myfaces.extensions.cdi.core.impl.provider.DefaultServiceProvider > installed successfully. > Información: > org.apache.myfaces.extensions.cdi.core.impl.provider.DefaultServiceProviderContext > installed successfully. > Información: Computed the following CODI ProjectStage: Production > Información: abc.Index will be used as page-definition. > Información: abc.MyBean will be used as page-bean. > Información: Initializing Mojarra 2.1.6 (SNAPSHOT 20111206) for context > '/WebApplication2' > Información: [Started] MyFaces CODI (Extensions CDI) alternative config > org.apache.myfaces.extensions.cdi.core.alternative.config.AlternativeCodiCoreConfig > is active (v1.0.4) > > Información: [Started] MyFaces CODI (Extensions CDI) alternative config > org.apache.myfaces.extensions.cdi.jsf.alternative.config.AlternativeJsfModuleConfig > is active (v1.0.4) > > Información: Running on PrimeFaces 3.2 > Información: WEB0671: Loading application [WebApplication2] at > [/WebApplication2] > Información: WebApplication2 was successfully deployed in 8,759 > milliseconds. > Información: > org.apache.myfaces.extensions.cdi.core.impl.provider.DefaultServiceProvider > installed successfully. > Información: > org.apache.myfaces.extensions.cdi.core.impl.provider.DefaultServiceProviderContext > installed successfully. > Información: Computed the following CODI ProjectStage: Production > Información: abc.Index will be used as page-definition. > Información: abc.MyBean will be used as page-bean. > Información: Initializing Mojarra 2.1.6 (SNAPSHOT 20111206) for context > '/WebApplication2' > Información: [Started] MyFaces CODI (Extensions CDI) alternative config > org.apache.myfaces.extensions.cdi.core.alternative.config.AlternativeCodiCoreConfig > is active (v1.0.4) > > Información: [Started] MyFaces CODI (Extensions CDI) alternative config > org.apache.myfaces.extensions.cdi.jsf.alternative.config.AlternativeJsfModuleConfig > is active (v1.0.4) > > Información: Running on PrimeFaces 3.2 > Información: WEB0671: Loading application [WebApplication2] at > [/WebApplication2] > Información: WebApplication2 was successfully deployed in 5,790 > milliseconds. > Información: [Started] MyFaces CODI (Extensions CDI) alternative config > org.apache.myfaces.extensions.cdi.core.alternative.scope.conversation.config.AlternativeWindowContextConfig > is active (v1.0.4) > > Información: [Started] MyFaces CODI (Extensions CDI) alternative config > org.apache.myfaces.extensions.cdi.core.alternative.scope.conversation.config.AlternativeConversationConfig > is active (v1.0.4) > > Información: [Started] MyFaces CODI JSF-Module v1.0.4 for JSF 2.0 > Used JSF implementation: Mojarra v2.1.6-SNAPSHOT > config implementation: > org.apache.myfaces.extensions.cdi.jsf.alternative.config.AlternativeJsfModuleConfig$Proxy$_$$_WeldClientProxy > config implementation: > org.apache.myfaces.extensions.cdi.jsf.alternative.config.AlternativeJsfModuleConfig > config implementation: > org.apache.myfaces.extensions.cdi.jsf.api.config.JsfModuleConfig > method: isInvalidValueAwareMessageInterpolatorEnabled > value: true > method: isUseViewConfigsAsNavigationCasesEnabled > value: true > method: isInitialRedirectEnabled > value: true > method: isAlwaysKeepMessages > value: true > config implementation: > org.apache.myfaces.extensions.cdi.core.alternative.scope.conversation.config.AlternativeWindowContextConfig$Proxy$_$$_WeldClientProxy > config implementation: > org.apache.myfaces.extensions.cdi.core.alternative.scope.conversation.config.AlternativeWindowContextConfig > config implementation: > org.apache.myfaces.extensions.cdi.core.api.scope.conversation.config.WindowContextConfig > method: isAddWindowIdToActionUrlsEnabled > value: false > method: getWindowContextTimeoutInMinutes > value: 60 > method: isCloseEmptyWindowContextsEnabled > value: false > method: isEagerWindowContextDetectionEnabled > value: true > method: isCreateWindowContextEventEnabled > value: false > method: isCloseWindowContextEventEnabled > value: false > method: isUrlParameterSupported > value: true > method: isUnknownWindowIdsAllowed > value: false > method: getMaxWindowContextCount > value: 64 > config implementation: > org.apache.myfaces.extensions.cdi.core.alternative.scope.conversation.config.AlternativeConversationConfig$Proxy$_$$_WeldClientProxy > config implementation: > org.apache.myfaces.extensions.cdi.core.alternative.scope.conversation.config.AlternativeConversationConfig > config implementation: > org.apache.myfaces.extensions.cdi.core.api.scope.conversation.config.ConversationConfig > method: isConversationRequiredEnabled > value: true > method: isRestartConversationEventEnabled > value: false > method: isCloseConversationEventEnabled > value: false > method: isStartConversationEventEnabled > value: false > method: getConversationTimeoutInMinutes > value: 30 > method: isScopeBeanEventEnabled > value: false > method: isAccessBeanEventEnabled > value: false > method: isUnscopeBeanEventEnabled > value: false > MessageContextConfig class: > org.apache.myfaces.extensions.cdi.message.impl.DefaultMessageContextConfig > MessageInterpolator class: class > org.apache.myfaces.extensions.cdi.jsf.impl.message.FacesMessageInterpolator > MessageResolver class: class > org.apache.myfaces.extensions.cdi.jsf.impl.message.JsfAwareApplicationMessagesMessageResolver > MessageHandler class: class > org.apache.myfaces.extensions.cdi.jsf.impl.message.JsfAwareMessageHandler > LocaleResolver class: class > org.apache.myfaces.extensions.cdi.jsf.impl.message.JsfAwareLocaleResolver > FormatterFactory class: class > org.apache.myfaces.extensions.cdi.message.impl.DefaultFormatterFactory > > Información: [Started] MyFaces CODI JPA-Module v1.0.4 > > Información: [Started] MyFaces CODI (Extensions CDI) Core v1.0.4 > Used CDI implementation: Weld v20111122-2001 > project-stage: Production > project-stage class: > org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage$Production > application-parameters: > name: com.sun.faces.forceLoadConfiguration > value: true > name: com.sun.faces.validateXml > value: true > name: javax.faces.PROJECT_STAGE > value: Development > config implementation: > org.apache.myfaces.extensions.cdi.core.alternative.config.AlternativeCodiCoreConfig$Proxy$_$$_WeldClientProxy > config implementation: > org.apache.myfaces.extensions.cdi.core.alternative.config.AlternativeCodiCoreConfig > config implementation: > org.apache.myfaces.extensions.cdi.core.api.config.CodiCoreConfig > method: isAdvancedQualifierRequiredForDependencyInjection > value: true > method: isConfigurationLoggingEnabled > value: true > method: isInvalidBeanCreationEventEnabled > value: false > > Advertencia: The value of the JSF 2 project stage (Development) is > different from the CODI project stage (Production) > Información: [Started] MyFaces CODI Scripting-Module v1.0.4 > > Información: [Started] MyFaces CODI Bean-Validation-Module v1.0.4 > *Información: verifying ..........* > *Información: verifying ..........* > *Información: init method* > *Información: verifying ..........* > *Información: verifying ..........* > * > * > * > * > * > * > * > * > * > * > --------------------------------------------------------------------------------------------------------------------------------------- > > * > * > * > * > *Why? Thanks* > * > * > > 2012/4/19 Gerhard Petracek <gerhard.petra...@gmail.com> > >> hi jose, >> >> here it works without an issue -> please provide the codi startup-log >> about >> the configuration you are using. >> >> @ package: >> please use: javax.enterprise.context >> >> regards, >> gerhard >> >> http://www.irian.at >> >> Your JSF/JavaEE powerhouse - >> JavaEE Consulting, Development and >> Courses in English and German >> >> Professional Support for Apache MyFaces >> >> >> >> 2012/4/19 José Luis Cetina <maxtorz...@gmail.com> >> >> > Thanks Gerhard, but i have a problem. >> > My checkpermision method never get called, i dont know why, i have this: >> > >> > *//ANOTATION* >> > @Stereotype >> > @Target(value = {ElementType.METHOD, ElementType.FIELD, >> ElementType.TYPE}) >> > @Retention(value = RetentionPolicy.RUNTIME) >> > @Secured(PermissionAccessDecisionVoter.class) >> > public @interface ModuloPantallaBinding { >> > ModulosPantallasEnum codigoModulo(); >> > } >> > >> > *//MANAGED BEAN* >> > @Named >> > @ViewAccessScoped >> > @View(IInicio.SeleccionRoles.class) >> > >> > >> @ModuloPantallaBinding(codigoModulo=ModulosPantallasEnum.SELECCION_ROLES_INICIO) >> > public class SeleccionRolesMBean implements Serializable { >> > . >> > . >> > . >> > } >> > >> > *//Secure class* >> > import javax.faces.bean.ApplicationScoped; >> > @ApplicationScoped >> > public class PermissionAccessDecisionVoter extends >> > AbstractAccessDecisionVoter implements AccessDecisionVoter{ >> > . >> > >> > protected void checkPermission(InvocationContext ic, >> Set<SecurityViolation> >> > violations) { >> > *ModuloPantallaBinding obj*= >> > voterContext.getMetaDataFor(ModuloPantallaBinding.class.getName(), >> > ModuloPantallaBinding.class); >> > >> > >> > } >> > . >> > } >> > >> > >> > is correct the package javax.faces.bean.ApplicationScoped >> > for @ApplicationScoped or have to be: >> > javax.enterprise.context.ApplicationScoped;??? >> > >> > My checkPermission method never get called, but if i use the anottation >> > @Secure in my: >> > @Secured(PermissionAccessDecisionVoter.class) >> > public @Page(name="seleccion_roles") class SeleccionRoles implements >> > IInicio{} >> > >> > it works but the obj always is null. >> > >> > Thanks >> > >> > >> > 2012/4/19 Gerhard Petracek <gerhard.petra...@gmail.com> >> > >> > > hi jose, >> > > >> > > see the description at [1] - it will be added to the wiki soon. >> > > >> > > regards, >> > > gerhard >> > > >> > > [1] https://issues.apache.org/jira/browse/EXTCDI-262 >> > > >> > > http://www.irian.at >> > > >> > > Your JSF/JavaEE powerhouse - >> > > JavaEE Consulting, Development and >> > > Courses in English and German >> > > >> > > Professional Support for Apache MyFaces >> > > >> > > >> > > >> > > 2012/4/19 José Luis Cetina <maxtorz...@gmail.com> >> > > >> > > > Hello somebody know where i can find an example of >> > > > @Secured and Stereotypes >> > > > >> > > > Im triying to work with @Secured and Stereotypes with metadata but i >> > have >> > > > some doubts >> > > > >> > > > >> > > > -- >> > > > ------------------------------------------------------------------- >> > > > *SCJA. José Luis Cetina* >> > > > ------------------------------------------------------------------- >> > > > >> > > >> > >> > >> > >> > -- >> > ------------------------------------------------------------------- >> > *SCJA. José Luis Cetina* >> > ------------------------------------------------------------------- >> > >> > > > > -- > ------------------------------------------------------------------- > *SCJA. José Luis Cetina* > ------------------------------------------------------------------- > > -- ------------------------------------------------------------------- *SCJA. José Luis Cetina* -------------------------------------------------------------------