org.apache.activemq.artemis.spi.core.security.jaas.JaasCallbackHandler

Here are the examples of the java api class org.apache.activemq.artemis.spi.core.security.jaas.JaasCallbackHandler taken from open source projects.

1. PropertiesLoginModuleRaceConditionTest#before()

View license
@Before
public void before() throws FileNotFoundException, IOException {
    createUsers();
    createGroups();
    options = new HashMap<>();
    // Used to simplify reproduction of the
    options.put("reload", "true");
    // race condition
    options.put("org.apache.activemq.jaas.properties.user", USERS_FILE);
    options.put("org.apache.activemq.jaas.properties.role", ROLES_FILE);
    options.put("baseDir", temp.getRoot().getAbsolutePath());
    errors = new ArrayBlockingQueue<>(processorCount());
    pool = Executors.newFixedThreadPool(processorCount(), ActiveMQThreadFactory.defaultThreadFactory());
    callback = new JaasCallbackHandler(USERNAME, PASSWORD, null);
}

2. CertificateLoginModuleTest#loginWithCredentials()

View license
private void loginWithCredentials(String userName, Set<String> rolesNames) throws LoginException {
    loginModule = new StubCertificateLoginModule(userName, new HashSet<>(rolesNames));
    JaasCallbackHandler callbackHandler = new JaasCallbackHandler(null, null, null);
    loginModule.initialize(subject, callbackHandler, null, new HashMap<String, Object>());
    loginModule.login();
    loginModule.commit();
}

3. TextFileCertificateLoginModuleTest#loginTest()

View license
private void loginTest(String usersFiles, String groupsFile) throws LoginException {
    HashMap<String, String> options = new HashMap<>();
    options.put("org.apache.activemq.jaas.textfiledn.user", usersFiles);
    options.put("org.apache.activemq.jaas.textfiledn.role", groupsFile);
    options.put("reload", "true");
    JaasCallbackHandler[] callbackHandlers = new JaasCallbackHandler[NUMBER_SUBJECTS];
    Subject[] subjects = new Subject[NUMBER_SUBJECTS];
    for (int i = 0; i < callbackHandlers.length; i++) {
        callbackHandlers[i] = getJaasCertificateCallbackHandler("DN=TEST_USER_" + (i + 1));
    }
    long startTime = System.currentTimeMillis();
    for (int outer = 0; outer < 500; outer++) {
        for (int i = 0; i < NUMBER_SUBJECTS; i++) {
            Subject subject = doAuthenticate(options, callbackHandlers[i]);
            subjects[i] = subject;
        }
    }
    long endTime = System.currentTimeMillis();
    long timeTaken = endTime - startTime;
    for (int i = 0; i < NUMBER_SUBJECTS; i++) {
        ActiveMQServerLogger.LOGGER.info("subject is: " + subjects[i].getPrincipals().toString());
    }
    ActiveMQServerLogger.LOGGER.info(usersFiles + ": Time taken is " + timeTaken);
}