1 package org.modeshape.jcr.api; 2 3 import javax.jcr.Credentials; 4 5 /** 6 * {@link Credentials} implementation that wraps a {@link SecurityContext ModeShape JCR security context}. 7 * <p> 8 * This class provides a means of passing security information about an authenticated user into the ModeShape JCR session 9 * implementation without using JAAS. This class effectively bypasses ModeShape's internal authentication mechanisms, so it is 10 * very important that this context be provided for <i>authenticated users only</i>. 11 * </p> 12 */ 13 public final class SecurityContextCredentials implements Credentials { 14 private static final long serialVersionUID = 1L; 15 private final SecurityContext jcrSecurityContext; 16 17 /** 18 * Initializes the class with an existing {@link SecurityContext JCR security context}. 19 * 20 * @param jcrSecurityContext the security context; may not be null 21 */ 22 public SecurityContextCredentials( final SecurityContext jcrSecurityContext ) { 23 assert jcrSecurityContext != null; 24 25 this.jcrSecurityContext = jcrSecurityContext; 26 } 27 28 /** 29 * Returns the {@link SecurityContext JCR security context} for this instance. 30 * 31 * @return the {@link SecurityContext JCR security context} for this instance; never null 32 */ 33 public final SecurityContext getSecurityContext() { 34 return this.jcrSecurityContext; 35 } 36 }