SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
Aspectos de segurança em
ambiente JavaEE
Walter Itamar Mourão
walter.mourao@gmail.com
Arquitetura em camadas
Acesso às páginas
Acesso aos serviços
Acesso aos dados
(fraco em aplicações JavaEE típicas)
Podem estar em camadas
físicas diferentes
Permissões de acesso - web.xml
 As permissões de acessos são definidas no
arquivo web.xml
<security-role>
<role-name>LOG_ONE_ADMIN</role-name>
</security-role>
<security-role>
<role-name>DTE_TARGA</role-name>
</security-role>
<security-role>
<role-name>CONTEINER_TARGA</role-name>
</security-role>
Autenticação via realm
 Realms são mecanismos para autenticação do
usuário
<Realm
className="c.a.logOne.targa.realm.tomcat.TargaRealm"
dataSourceName="jdbc/logone"/>
Mecanismos mais granulados
 Deve-se usar a propriedade rendered, readonly
e outras para controlar o acesso do usuário a
componentes e parte específicas da página
<h:inputText id="input1"
value="#{helloWorldBacking.name}"
required="true"
rendered=
"#{ssm:userHasPermission('NameField','View')}"
readonly=
"#{not
ssm:userHasPermission('NameField','Change')}"
/>
Spring Security
 Projeto iniciado em 2003 (ACEGI), é o mais
usado em segurança JavaEE
 Usado por agências do governo e outros
ambientes críticos
 Pode ser usado na camada de apresentação
ou serviços
 Configuração via XML ou anotações
Spring Security na Apresentação
 Controla o acesso a páginas e recursos
baseado em roles
<http auto-config="true" access-denied-page="/403.jsp">
<intercept-url pattern="/index.jsp"
access="ROLE_ADMINISTRATOR,ROLE_USER"/>
<intercept-url pattern="/securePage.jsp"
access="ROLE_ADMINISTRATOR"/>
<intercept-url pattern="/**" access="ROLE_ANONYMOUS" />
</http>
Spring Security na Apresentação
 Permite que mecanismos dinâmicos sejam
agregados para definição de roles->recursos
em tempo de execução
<beans:bean id="accessDecisionManager"
class="org.springframework.security.vote.AffirmativeBased">
<beans:property name="decisionVoters">
<beans:list>
<beans:bean
class="org.springframework.security.vote.RoleVoter"/>
<beans:bean
class="org.springframework.security.vote.AuthenticatedVoter"/>
</beans:list>
</beans:property>
</beans:bean>
Spring Security nos Serviços
 Intercepta as chamadas aos serviços, tratando
de forma semelhante ao que é feito na camada
de Apresentação
<global-method-security secured-
annotations="enabled">
<protect-pointcut
expression="execution(*
o.s.s.petclinic.Clinic.storeVisit(..))"
access="ROLE_SUPERVISOR"/>
</global-method-security>
Autenticação no Spring Security
 JDBC, DAO
 LDAP, JAAS, OpenID
 X.509 (SSL/HTTPS), CAS (single sign on)
 Específico da aplicação
 ...
Andromda – Servidor JSP
 O Andromda tem suporte à segurança na
camada de apresentação através da geração
do controle de acesso no arquivo web.xml a
partir das associações Ator – Caso de uso
Andromda – Servidor JSP
 Além da geração das permissões de acesso no
web.xml, o Andromda gera também o código
JSF para o login do usuário
<tr:inputText id="j_username" onkeypress="submitForm(event)"
label="#{messages['login.username']}:"
contentStyle="width:170px;" />
<tr:inputText id="j_password" onkeypress="submitForm(event)"
secret="true" label="#{messages['login.password']}:"
contentStyle="width:170px;" />
Andromda - Acegi
 Pode-se restringir o acesso aos serviços
traçando dependência do ator para o
serviço/método
Referências
 http://www.springsource.com/
 http://www.andromda.org/

Mais conteúdo relacionado

Destaque

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Aspectos segurança javaee

  • 1. Aspectos de segurança em ambiente JavaEE Walter Itamar Mourão walter.mourao@gmail.com
  • 2. Arquitetura em camadas Acesso às páginas Acesso aos serviços Acesso aos dados (fraco em aplicações JavaEE típicas) Podem estar em camadas físicas diferentes
  • 3. Permissões de acesso - web.xml  As permissões de acessos são definidas no arquivo web.xml <security-role> <role-name>LOG_ONE_ADMIN</role-name> </security-role> <security-role> <role-name>DTE_TARGA</role-name> </security-role> <security-role> <role-name>CONTEINER_TARGA</role-name> </security-role>
  • 4. Autenticação via realm  Realms são mecanismos para autenticação do usuário <Realm className="c.a.logOne.targa.realm.tomcat.TargaRealm" dataSourceName="jdbc/logone"/>
  • 5. Mecanismos mais granulados  Deve-se usar a propriedade rendered, readonly e outras para controlar o acesso do usuário a componentes e parte específicas da página <h:inputText id="input1" value="#{helloWorldBacking.name}" required="true" rendered= "#{ssm:userHasPermission('NameField','View')}" readonly= "#{not ssm:userHasPermission('NameField','Change')}" />
  • 6. Spring Security  Projeto iniciado em 2003 (ACEGI), é o mais usado em segurança JavaEE  Usado por agências do governo e outros ambientes críticos  Pode ser usado na camada de apresentação ou serviços  Configuração via XML ou anotações
  • 7. Spring Security na Apresentação  Controla o acesso a páginas e recursos baseado em roles <http auto-config="true" access-denied-page="/403.jsp"> <intercept-url pattern="/index.jsp" access="ROLE_ADMINISTRATOR,ROLE_USER"/> <intercept-url pattern="/securePage.jsp" access="ROLE_ADMINISTRATOR"/> <intercept-url pattern="/**" access="ROLE_ANONYMOUS" /> </http>
  • 8. Spring Security na Apresentação  Permite que mecanismos dinâmicos sejam agregados para definição de roles->recursos em tempo de execução <beans:bean id="accessDecisionManager" class="org.springframework.security.vote.AffirmativeBased"> <beans:property name="decisionVoters"> <beans:list> <beans:bean class="org.springframework.security.vote.RoleVoter"/> <beans:bean class="org.springframework.security.vote.AuthenticatedVoter"/> </beans:list> </beans:property> </beans:bean>
  • 9. Spring Security nos Serviços  Intercepta as chamadas aos serviços, tratando de forma semelhante ao que é feito na camada de Apresentação <global-method-security secured- annotations="enabled"> <protect-pointcut expression="execution(* o.s.s.petclinic.Clinic.storeVisit(..))" access="ROLE_SUPERVISOR"/> </global-method-security>
  • 10. Autenticação no Spring Security  JDBC, DAO  LDAP, JAAS, OpenID  X.509 (SSL/HTTPS), CAS (single sign on)  Específico da aplicação  ...
  • 11. Andromda – Servidor JSP  O Andromda tem suporte à segurança na camada de apresentação através da geração do controle de acesso no arquivo web.xml a partir das associações Ator – Caso de uso
  • 12. Andromda – Servidor JSP  Além da geração das permissões de acesso no web.xml, o Andromda gera também o código JSF para o login do usuário <tr:inputText id="j_username" onkeypress="submitForm(event)" label="#{messages['login.username']}:" contentStyle="width:170px;" /> <tr:inputText id="j_password" onkeypress="submitForm(event)" secret="true" label="#{messages['login.password']}:" contentStyle="width:170px;" />
  • 13. Andromda - Acegi  Pode-se restringir o acesso aos serviços traçando dependência do ator para o serviço/método