As seguintes amostras descrevem maneiras que você pode usar as políticas de aplicativo num domínio de segurança.
A única política de autenticação é declarada nas amostras para maior clareza, no entanto você pode incluir os elementos <authorization> e <mapping> no mesmo <application-policy>. Refira-se à Seção 6.1, “<authentication>” para uma informação detalhada sobre o elemento <authentication>.
Exemplo 7.1. Política de autenticação da pilha de logon único
Esta amostra descreve uma configuração de domínio de segurança única nomeada jmx-console que usa um módulo de logon único, UsersRolesLoginModule (refira-se à Seção 12.1.5, “UsersRolesLoginModule”).
O módulo de logon é fornecido pelo usuário e as propriedades de arquivos do diretório jboss-as/server/$PROFILE/conf/props.
Nesta instância, o <login-module> deve suceder ou a autenticação falhará.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Exemplo 7.2. Política da autenticação da pilha de logon múltiplo
Esta amostra descreve a configuração do domínio de segurança nomeado web-console que usa dois módulos de logon na pilha de módulo de logon de autenticação.
Um <login-module> obtém os credenciais de logon usando o LdapLoginModule (referia-se à Seção 12.1.1, “LdapLoginModule”), onde o outro <login-module> obtém as credenciais de autenticação usando o BaseCertLoginModule (refira-se à Seção 12.1.7, “BaseCertLoginModule”).
Nesta instância, ambos os módulos são marcados como suficientes, portanto apenas um deles deve suceder para que a autenticação ocorra com êxito.
Copiar o linkLink copiado para a área de transferência!
A implementação dos manuseadores de chamada de retorno em procedimentos de autenticação permite que um módulo de logon autentique um usuário independente do método de autenticação do aplicativo do cliente.
Você pode implementar os manuseadores de chamada de retorno usando os seguintes métodos:
Especificando o atributo CallbackHandlerClassName na definição JaasSecurityManagerService MBean do conf/jboss-service.xml.
Injetando a instância do manuseador da chamada de retorno no JNDISecurityManagement bean do deploy/security/security-jboss-beans.xml.
Procedimento 7.1. Define o manuseador de chamada de retorno usando os atributos
Este procedimento descreve como especificar um manuseador da chamada de retorno no arquivo de configuração do jboss-service.xml.
<?xml version="1.0" encoding="UTF-8"?>
...
<!-- ==================================================================== -->
<!-- Security -->
<!-- ==================================================================== -->
<!-- JAAS security manager and realm mapping -->
<mbean code="org.jboss.security.plugins.JaasSecurityManagerService" name="jboss.security:service=JaasSecurityManager">
<!-- A flag which indicates whether the SecurityAssociation server mode
is set on service creation. This is true by default since the
SecurityAssociation should be thread local for multi-threaded server
operation.-->
<attribute name="ServerMode">true</attribute>
<attribute name="SecurityManagerClassName">org.jboss.security.plugins.JaasSecurityManager</attribute>
<attribute name="DefaultUnauthenticatedPrincipal">anonymous</attribute>
<!-- DefaultCacheTimeout: Specifies the default timed cache policy timeout
in seconds.
If you want to disable caching of security credentials, set this to 0 to
force authentication to occur every time. This has no affect if the
AuthenticationCacheJndiName has been changed from the default value.-->
<attribute name="DefaultCacheTimeout">1800</attribute>
<!-- DefaultCacheResolution: Specifies the default timed cache policy
resolution in seconds. This controls the interval at which the cache
current timestamp is updated and should be less than the DefaultCacheTimeout
in order for the timeout to be meaningful. This has no affect if the
AuthenticationCacheJndiName has been changed from the default value.-->
<attribute name="DefaultCacheResolution">60</attribute>
<!-- DeepCopySubjectMode: This set the copy mode of subjects done by the
security managers to be deep copies that makes copies of the subject
principals and credentials if they are cloneable. It should be set to
true if subject include mutable content that can be corrupted when
multiple threads have the same identity and cache flushes/logout clearing
the subject in one thread results in subject references affecting other
threads.-->
<attribute name="DeepCopySubjectMode">false</attribute>
</mbean>
...
<?xml version="1.0" encoding="UTF-8"?>
...
<!-- ==================================================================== -->
<!-- Security -->
<!-- ==================================================================== -->
<!-- JAAS security manager and realm mapping -->
<mbean code="org.jboss.security.plugins.JaasSecurityManagerService" name="jboss.security:service=JaasSecurityManager">
<!-- A flag which indicates whether the SecurityAssociation server mode
is set on service creation. This is true by default since the
SecurityAssociation should be thread local for multi-threaded server
operation.-->
<attribute name="ServerMode">true</attribute>
<attribute name="SecurityManagerClassName">org.jboss.security.plugins.JaasSecurityManager</attribute>
<attribute name="DefaultUnauthenticatedPrincipal">anonymous</attribute>
<!-- DefaultCacheTimeout: Specifies the default timed cache policy timeout
in seconds.
If you want to disable caching of security credentials, set this to 0 to
force authentication to occur every time. This has no affect if the
AuthenticationCacheJndiName has been changed from the default value.-->
<attribute name="DefaultCacheTimeout">1800</attribute>
<!-- DefaultCacheResolution: Specifies the default timed cache policy
resolution in seconds. This controls the interval at which the cache
current timestamp is updated and should be less than the DefaultCacheTimeout
in order for the timeout to be meaningful. This has no affect if the
AuthenticationCacheJndiName has been changed from the default value.-->
<attribute name="DefaultCacheResolution">60</attribute>
<!-- DeepCopySubjectMode: This set the copy mode of subjects done by the
security managers to be deep copies that makes copies of the subject
principals and credentials if they are cloneable. It should be set to
true if subject include mutable content that can be corrupted when
multiple threads have the same identity and cache flushes/logout clearing
the subject in one thread results in subject references affecting other
threads.-->
<attribute name="DeepCopySubjectMode">false</attribute>
</mbean>
...
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Anexe o atributo
Para definir o manuseador da chamada de retorno padrão, anexe um elemento <attribute> como um filho do elemento <mbean> e especifique o nome inteiramente qualificado do manuseador da chamada de retorno. Refira-se ao Exemplo 7.4, “chamador da chamada de retorno anexado do jboss-service” para uma amostra do elemento <attribute>, com o manuseador da chamada de retorno especificada.
Exemplo 7.4. chamador da chamada de retorno anexado do jboss-service
<?xml version="1.0" encoding="UTF-8"?>
...
<!-- ==================================================================== -->
<!-- Security -->
<!-- ==================================================================== -->
<!-- JAAS security manager and realm mapping -->
<mbean code="org.jboss.security.plugins.JaasSecurityManagerService" name="jboss.security:service=JaasSecurityManager">
<!-- A flag which indicates whether the SecurityAssociation server mode
is set on service creation. This is true by default since the
SecurityAssociation should be thread local for multi-threaded server
operation.-->
<attribute name="ServerMode">true</attribute>
<attribute name="SecurityManagerClassName">org.jboss.security.plugins.JaasSecurityManager</attribute>
<attribute name="DefaultUnauthenticatedPrincipal">anonymous</attribute>
<!-- DefaultCacheTimeout: Specifies the default timed cache policy timeout
in seconds.
If you want to disable caching of security credentials, set this to 0 to
force authentication to occur every time. This has no affect if the
AuthenticationCacheJndiName has been changed from the default value.-->
<attribute name="DefaultCacheTimeout">1800</attribute>
<!-- DefaultCacheResolution: Specifies the default timed cache policy
resolution in seconds. This controls the interval at which the cache
current timestamp is updated and should be less than the DefaultCacheTimeout
in order for the timeout to be meaningful. This has no affect if the
AuthenticationCacheJndiName has been changed from the default value.-->
<attribute name="DefaultCacheResolution">60</attribute>
<!-- DeepCopySubjectMode: This set the copy mode of subjects done by the
security managers to be deep copies that makes copies of the subject
principals and credentials if they are cloneable. It should be set to
true if subject include mutable content that can be corrupted when
multiple threads have the same identity and cache flushes/logout clearing
the subject in one thread results in subject references affecting other
threads.-->
<attribute name="DeepCopySubjectMode">false</attribute>
<attribute name="CallbackHandlerClassName">org.jboss.security.plugins.[Custom_Callback_Handler_Name]</attribute>
</mbean>
...
<?xml version="1.0" encoding="UTF-8"?>
...
<!-- ==================================================================== -->
<!-- Security -->
<!-- ==================================================================== -->
<!-- JAAS security manager and realm mapping -->
<mbean code="org.jboss.security.plugins.JaasSecurityManagerService" name="jboss.security:service=JaasSecurityManager">
<!-- A flag which indicates whether the SecurityAssociation server mode
is set on service creation. This is true by default since the
SecurityAssociation should be thread local for multi-threaded server
operation.-->
<attribute name="ServerMode">true</attribute>
<attribute name="SecurityManagerClassName">org.jboss.security.plugins.JaasSecurityManager</attribute>
<attribute name="DefaultUnauthenticatedPrincipal">anonymous</attribute>
<!-- DefaultCacheTimeout: Specifies the default timed cache policy timeout
in seconds.
If you want to disable caching of security credentials, set this to 0 to
force authentication to occur every time. This has no affect if the
AuthenticationCacheJndiName has been changed from the default value.-->
<attribute name="DefaultCacheTimeout">1800</attribute>
<!-- DefaultCacheResolution: Specifies the default timed cache policy
resolution in seconds. This controls the interval at which the cache
current timestamp is updated and should be less than the DefaultCacheTimeout
in order for the timeout to be meaningful. This has no affect if the
AuthenticationCacheJndiName has been changed from the default value.-->
<attribute name="DefaultCacheResolution">60</attribute>
<!-- DeepCopySubjectMode: This set the copy mode of subjects done by the
security managers to be deep copies that makes copies of the subject
principals and credentials if they are cloneable. It should be set to
true if subject include mutable content that can be corrupted when
multiple threads have the same identity and cache flushes/logout clearing
the subject in one thread results in subject references affecting other
threads.-->
<attribute name="DeepCopySubjectMode">false</attribute>
<attribute name="CallbackHandlerClassName">org.jboss.security.plugins.[Custom_Callback_Handler_Name]</attribute>
</mbean>
...
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Reinicie o servidor
Você acabou de configurar o arquivo jboss-service.xml para uso com o manuseador de chamada de retorno.
Reinicie o servidor para garantir de que a nova política de segurança fará efeito.
Procedimento 7.2. Defina o manuseador da chamada de retorno usando a injeção
Este procedimento descreve como injetar uma instância do manuseador da chamada de retorno de segurança no JNDISecurityManagement bean.
Crie uma instância de chamada de retorno personalizada
Você deve criar uma instância do manuseador da chamada de retorno personalizada e registrá-la.
Abra o arquivo de configuração
Navigue ao $JBOSS_HOME/server/$PROFILE/deploy/security/
Exemplo 7.5. configuração padrão do security-jboss-beans
<!-- JNDI Based Security Management -->
<bean name="JBossSecuritySubjectFactory" class="org.jboss.security.integration.JBossSecuritySubjectFactory" />
<!-- JNDI Based Security Management -->
<bean name="JBossSecuritySubjectFactory" class="org.jboss.security.integration.JBossSecuritySubjectFactory" />
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Anexe a propriedade de injeção
Para injetar o manuseador da chamada de retorno, anexe um elemento <property> como filho do elemento <mbean> do JNDIBasedSecurityManagement. Especifique o manuseador da chamada de retorno usando os elementos <property> e <inject> descritos no Exemplo 7.4, “chamador da chamada de retorno anexado do jboss-service”.
Exemplo 7.6. manuseador da chamada de retorno do security-jboss-beans
Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar. Explore nossas atualizações recentes.
Tornando o open source mais inclusivo
A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja o Blog da Red Hat.
Sobre a Red Hat
Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.