public key
- Publicly shared encryption key
- Encrypts sensitive data
- Verifies digital signatures
- Paired with private key
- Cannot decrypt private data
private key
- Secret cryptographic key
- Decrypts encrypted data
- Creates digital signatures
- Paired with public key
- Must remain confidential
certificate
- Verifies entity identity
- Contains public key
- Issued by Certificate Authority
- Enables secure communication
- Used in SSL/TLS
pkcs file
- Stores cryptographic keys securely
- Contains certificates and keys
- Password-protected file format
- Commonly uses .p12
- Used for SSL/TLS
pem file
- Base64-encoded text format
- Stores certificates or keys
- Uses ASCII encoding
- Begins with BEGIN header
- Commonly used for SSL
cacerts
- JVM trusted certificates store
- Contains CA certificates
- Validates SSL/TLS connections
- Used by HTTPS clients
- Managed using keytool
cookie
- Stored in browser
- Maintains user session
- Sent with requests
- Can store small data
- Supports authentication state
session
- Stores user-specific state
- Maintained on server
- Identified using session ID
- Persists across requests
- Expires after inactivity
JWT
Stateless authentication mechanism
Contains signed user claims
Validated by security filter
No server-side session
Secures protected API endpoints
Spring Cloud Gateway
- Centralized API authentication
- Validates JWT tokens
- Applies authorization rules
- Routes secured requests
- Protects downstream services
@PreAuthorize
- Method-level security annotation
- Checks access before execution
- Uses SpEL expressions
- Supports roles and permissions
- Blocks unauthorized access
claims
- JWT payload information
- Contains user identity
- Includes roles and permissions
- Digitally signed data
- Used for authorization
principal
- Represents authenticated user
- Contains user identity
- Available in SecurityContext
- Used for authorization
- Retrieved after authentication
session
Stores client session state
Maintained on server side
Identified using session ID
Uses
HttpSessionAPISupports login session management
cookie
Stores data in browser
Sent with HTTP requests
Can maintain session state
Supports secure authentication cookies
Configured using cookie attributes
session Id
Uniquely identifies user session
Usually stored in cookie
Maps client to server
Generated when session created
Should be unpredictable and secure
What is the difference between DelegatingFilterProxy and FilterChainProxy in Spring Security?
- DelegatingFilterProxy: A standard Servlet filter registered in the traditional web.xml or Servlet container context. It does not perform security checks itself. Instead, it bridges the gap by delegating the filter workload to a Spring-managed bean.
- FilterChainProxy: The actual Spring-managed bean that wraps the SecurityFilterChain. It orchestrates the sequence of custom and predefined security filters (JwtAuthenticationFilter, UsernamePasswordAuthenticationFilter, etc.)
How do you protect a Java application against SQL Injection (SQLi) and Cross-Site Scripting (XSS)?
- SQL Injection: Never concatenate input variables directly inside raw queries. Use PreparedStatementor robust Object-Relational Mappings (ORMs) like Hibernate/JPA. They separate query logic from data parameters using automated placeholder binding.
- XSS Mitigation: Treat all incoming data as untrusted. Use context-aware HTML/Javascript escaping via libraries like OWASP Java Encoder. Implement strict Content Security Policies (CSP) headers to stop unauthorized third-party scripts from executing inside your UI layer.
No comments:
Post a Comment