use of org.jboss.as.security.plugins.SecurityDomainContext in project wildfly by wildfly.
the class UndertowDeploymentInfoService method handleIdentityManager.
private void handleIdentityManager(final DeploymentInfo deploymentInfo) {
if (securityDomain != null) {
SecurityDomainContext sdc = securityDomainContextValue.getValue();
deploymentInfo.setIdentityManager(new JAASIdentityManagerImpl(sdc));
AuditManager auditManager = sdc.getAuditManager();
if (auditManager != null && !mergedMetaData.isDisableAudit()) {
deploymentInfo.addNotificationReceiver(new AuditNotificationReceiver(auditManager));
}
}
}
use of org.jboss.as.security.plugins.SecurityDomainContext in project wildfly by wildfly.
the class SecurityDomainJndiInjectable method lookupSecurityDomain.
/**
* Creates a {@code SecurityDomainContext} if one cannot be found in JNDI for a given security domain
*
* @param securityManagement security management
* @param securityManagerMap security manager map
* @param securityDomain the name of the security domain
* @return an instance of {@code SecurityDomainContext}
* @throws Exception if an error occurs
*/
private SecurityDomainContext lookupSecurityDomain(final JNDIBasedSecurityManagement securityManagement, final ConcurrentHashMap<String, SecurityDomainContext> securityManagerMap, final String securityDomain) throws Exception {
SecurityDomainContext sdc = securityManagerMap.get(securityDomain);
if (sdc == null) {
sdc = securityManagement.createSecurityDomainContext(securityDomain, new DefaultAuthenticationCacheFactory());
securityManagerMap.put(securityDomain, sdc);
}
return sdc;
}
use of org.jboss.as.security.plugins.SecurityDomainContext in project teiid by teiid.
the class TestJBossSecurityHelper method testAuthenticate.
public void testAuthenticate() throws Exception {
Credentials credentials = new Credentials("pass1".toCharArray());
String domains = "testFile";
AuthenticationManager authManager = new AuthenticationManager() {
public String getSecurityDomain() {
return null;
}
public boolean isValid(Principal principal, Object credential, Subject activeSubject) {
return true;
}
public boolean isValid(Principal principal, Object credential) {
return true;
}
@Override
public Principal getTargetPrincipal(Principal anotherDomainPrincipal, Map<String, Object> contextMap) {
return null;
}
@Override
public Subject getActiveSubject() {
return null;
}
@Override
public void logout(Principal arg0, Subject arg1) {
}
};
final SecurityDomainContext securityContext = new SecurityDomainContext(authManager, null, null, null, null, null);
JBossSecurityHelper ms = buildSecurityHelper(domains, securityContext);
// $NON-NLS-1$
Object c = ms.authenticate(domains, "user1", credentials, null);
// $NON-NLS-1$
assertTrue(c instanceof JBossSecurityContext);
assertEquals(domains, ((JBossSecurityContext) c).getSecurityDomain());
}
use of org.jboss.as.security.plugins.SecurityDomainContext in project teiid by teiid.
the class TestJBossSecurityHelper method validateSession.
public void validateSession(boolean securityEnabled) throws Exception {
final ArrayList<String> domains = new ArrayList<String>();
domains.add("somedomain");
AuthenticationManager authManager = Mockito.mock(AuthenticationManager.class);
Mockito.stub(authManager.isValid(new SimplePrincipal("steve"), "pass1", new Subject())).toReturn(true);
final SecurityDomainContext securityContext = new SecurityDomainContext(authManager, null, null, null, null, null);
SessionServiceImpl jss = new SessionServiceImpl() {
@Override
protected VDBMetaData getActiveVDB(String vdbName, String vdbVersion) throws SessionServiceException {
return Mockito.mock(VDBMetaData.class);
}
};
jss.setSecurityHelper(buildSecurityHelper("somedomain", securityContext));
jss.setSecurityDomain("somedomain");
try {
jss.validateSession(String.valueOf(1));
// $NON-NLS-1$
fail("exception expected");
} catch (InvalidSessionException e) {
}
// $NON-NLS-1$ //$NON-NLS-2$
SessionMetadata info = jss.createSession("x", "1", AuthenticationType.USERPASSWORD, "steve", new Credentials("pass1".toCharArray()), "foo", new Properties());
if (securityEnabled) {
Mockito.verify(authManager).isValid(new SimplePrincipal("steve"), "pass1", new Subject());
}
String id1 = info.getSessionId();
jss.validateSession(id1);
assertEquals(1, jss.getActiveSessionsCount());
// $NON-NLS-1$
assertEquals(0, jss.getSessionsLoggedInToVDB(new VDBKey("a", 1)).size());
jss.closeSession(id1);
try {
jss.validateSession(id1);
// $NON-NLS-1$
fail("exception expected");
} catch (InvalidSessionException e) {
}
try {
jss.closeSession(id1);
// $NON-NLS-1$
fail("exception expected");
} catch (InvalidSessionException e) {
}
}
use of org.jboss.as.security.plugins.SecurityDomainContext in project teiid by teiid.
the class JBossSecurityHelper method getSecurityDomainContext.
protected SecurityDomainContext getSecurityDomainContext(String securityDomain) {
if (securityDomain != null && !securityDomain.isEmpty()) {
// $NON-NLS-1$ //$NON-NLS-2$
ServiceName name = ServiceName.JBOSS.append("security", "security-domain", securityDomain);
ServiceController<SecurityDomainContext> controller = (ServiceController<SecurityDomainContext>) CurrentServiceContainer.getServiceContainer().getService(name);
if (controller != null) {
return controller.getService().getValue();
}
}
return null;
}
Aggregations