Search in sources :

Example 16 with JaasRealm

use of org.apache.karaf.jaas.config.JaasRealm in project ddf by codice.

the class UPBSTValidator method addRealm.

public void addRealm(ServiceReference<JaasRealm> serviceReference) {
    Bundle bundle = FrameworkUtil.getBundle(UPBSTValidator.class);
    if (null != bundle) {
        JaasRealm realm = bundle.getBundleContext().getService(serviceReference);
        LOGGER.trace("Adding validator for JaasRealm {}", realm.getName());
        JAASUsernameTokenValidator validator = new JAASUsernameTokenValidator();
        validator.setContextName(realm.getName());
        validators.put(realm.getName(), validator);
    }
}
Also used : JaasRealm(org.apache.karaf.jaas.config.JaasRealm) JAASUsernameTokenValidator(org.apache.wss4j.dom.validate.JAASUsernameTokenValidator) Bundle(org.osgi.framework.Bundle)

Example 17 with JaasRealm

use of org.apache.karaf.jaas.config.JaasRealm in project ddf by codice.

the class UsernamePasswordRealmTest method setup.

@Before
public void setup() {
    List<ClaimsHandler> claimsHandlers = new ArrayList<>();
    claimsHandlers.add(mock(ClaimsHandler.class));
    claimsHandlers.add(mock(ClaimsHandler.class));
    ClaimsCollection claims1 = new ClaimsCollectionImpl();
    ClaimImpl email1 = new ClaimImpl("email");
    email1.addValue("test@example.com");
    claims1.add(email1);
    ClaimsCollection claims2 = new ClaimsCollectionImpl();
    ClaimImpl email2 = new ClaimImpl("email");
    email2.addValue("tester@example.com");
    claims2.add(email2);
    when(claimsHandlers.get(0).retrieveClaims(any())).thenReturn(claims1);
    when(claimsHandlers.get(1).retrieveClaims(any())).thenReturn(claims2);
    upRealm.setClaimsHandlers(claimsHandlers);
    JaasRealm jaasRealm = mock(JaasRealm.class);
    when(jaasRealm.getName()).thenReturn("realm");
    upRealm.realmList.add(jaasRealm);
}
Also used : JaasRealm(org.apache.karaf.jaas.config.JaasRealm) ClaimsHandler(ddf.security.claims.ClaimsHandler) ClaimsCollectionImpl(ddf.security.claims.impl.ClaimsCollectionImpl) ArrayList(java.util.ArrayList) ClaimImpl(ddf.security.claims.impl.ClaimImpl) ClaimsCollection(ddf.security.claims.ClaimsCollection) Before(org.junit.Before)

Example 18 with JaasRealm

use of org.apache.karaf.jaas.config.JaasRealm in project ddf by codice.

the class UsernamePasswordRealm method removeRealm.

public void removeRealm(ServiceReference<JaasRealm> serviceReference) {
    Bundle bundle = FrameworkUtil.getBundle(UsernamePasswordRealm.class);
    if (null != bundle) {
        JaasRealm realm = bundle.getBundleContext().getService(serviceReference);
        LOGGER.trace("Removing validator for JaasRealm {}", realm.getName());
        realmList.remove(realm);
    }
}
Also used : JaasRealm(org.apache.karaf.jaas.config.JaasRealm) Bundle(org.osgi.framework.Bundle)

Aggregations

JaasRealm (org.apache.karaf.jaas.config.JaasRealm)18 AppConfigurationEntry (javax.security.auth.login.AppConfigurationEntry)7 Bundle (org.osgi.framework.Bundle)6 Queue (java.util.Queue)3 BackingEngine (org.apache.karaf.jaas.modules.BackingEngine)3 ArrayList (java.util.ArrayList)2 Module (org.apache.karaf.jaas.config.impl.Module)2 JAASUsernameTokenValidator (org.apache.wss4j.dom.validate.JAASUsernameTokenValidator)2 ClaimsCollection (ddf.security.claims.ClaimsCollection)1 ClaimsHandler (ddf.security.claims.ClaimsHandler)1 ClaimImpl (ddf.security.claims.impl.ClaimImpl)1 ClaimsCollectionImpl (ddf.security.claims.impl.ClaimsCollectionImpl)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Subject (javax.security.auth.Subject)1 LoginException (javax.security.auth.login.LoginException)1 KeystoreInstance (org.apache.karaf.jaas.config.KeystoreInstance)1 KeystoreManager (org.apache.karaf.jaas.config.KeystoreManager)1 Config (org.apache.karaf.jaas.config.impl.Config)1 ShellTable (org.apache.karaf.shell.support.table.ShellTable)1