javax.security.auth.spi.LoginModule Java Examples
The following examples show how to use
javax.security.auth.spi.LoginModule.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BookLoginModule.java From cxf with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private static Class<LoginModule> getLoginModuleClass() { Class<?> clz = null; try { // try the jetty9 version clz = Class.forName("org.eclipse.jetty.jaas.spi.PropertyFileLoginModule", true, BookLoginModule.class.getClassLoader()); } catch (Throwable t) { if (clz == null) { try { // try the jetty8 version clz = Class.forName("org.eclipse.jetty.plus.jaas.spi.PropertyFileLoginModule", true, BookLoginModule.class.getClassLoader()); } catch (Throwable t2) { // ignore } } } return (Class<LoginModule>)clz; }
Example #2
Source File: KafkaProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@BuildStep void contributeClassesToIndex(BuildProducer<AdditionalIndexedClassesBuildItem> additionalIndexedClasses, BuildProducer<IndexDependencyBuildItem> indexDependency) { // This is needed for SASL authentication additionalIndexedClasses.produce(new AdditionalIndexedClassesBuildItem( LoginModule.class.getName(), javax.security.auth.Subject.class.getName(), javax.security.auth.login.AppConfigurationEntry.class.getName(), javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag.class.getName())); indexDependency.produce(new IndexDependencyBuildItem("org.apache.kafka", "kafka-clients")); }
Example #3
Source File: KafkaProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@BuildStep public void withSasl(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<ReflectiveHierarchyBuildItem> reflectiveHierarchy) { reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, AbstractLogin.DefaultLoginCallbackHandler.class)); reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, SaslClientCallbackHandler.class)); reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, DefaultLogin.class)); final Type loginModuleType = Type .create(DotName.createSimple(LoginModule.class.getName()), Kind.CLASS); reflectiveHierarchy.produce(new ReflectiveHierarchyBuildItem(loginModuleType)); }
Example #4
Source File: ProxyLoginModule.java From lams with GNU General Public License v2.0 | 5 votes |
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String,?> sharedState, Map<String,?> options) { log = Logger.getLogger(getClass()); /* TODO: this module should really extend AbstractServerLoginModule where the options check is integrated. * the code here has been intentionally kept identical */ HashSet<String> validOptions = new HashSet<String>(Arrays.asList(ALL_VALID_OPTIONS)); for (Object key : options.keySet()) { if (!validOptions.contains(key)) { PicketBoxLogger.LOGGER.warnInvalidModuleOption((String) key); } } moduleName = (String) options.get(MODULE_NAME); if( moduleName == null ) { return; } // Load the delegate module using the thread class loader ClassLoader loader = SecurityActions.getContextClassLoader(); try { Class<?> clazz = loader.loadClass(moduleName); delegate = (LoginModule) clazz.newInstance(); } catch(Throwable t) { t.printStackTrace(); return; } delegate.initialize(subject, callbackHandler, sharedState, options); }
Example #5
Source File: AbstractServerAuthModule.java From lams with GNU General Public License v2.0 | 5 votes |
/** * This method delegates to a login module if configured in the module options. * The sub classes will need to validate the request */ public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, Subject serviceSubject) throws AuthException { String loginModuleName = (String) options.get("login-module-delegate"); if(loginModuleName != null) { ClassLoader tcl = SecurityActions.getContextClassLoader(); try { Class clazz = tcl.loadClass(loginModuleName); LoginModule lm = (LoginModule) clazz.newInstance(); lm.initialize(clientSubject, callbackHandler, new HashMap(), options); lm.login(); lm.commit(); } catch (Exception e) { throw new AuthException(e.getLocalizedMessage()); } } else { return validate(clientSubject, messageInfo) ? AuthStatus.SUCCESS : AuthStatus.FAILURE; } return AuthStatus.SUCCESS; }
Example #6
Source File: ProxyLoginModule.java From mobi with GNU Affero General Public License v3.0 | 5 votes |
@Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) { BundleContext context = (BundleContext) options.get(BundleContext.class.getName()); if (context == null) { throw new IllegalStateException("Option " + BundleContext.class.getName() + " must be set to the BundleContext of the module"); } String module = (String) options.get(MODULE); if (module == null) { throw new IllegalStateException("Option " + MODULE + " must be set to the name of the module"); } String bundleId = (String) options.get(BUNDLE_ID); if (bundleId == null) { throw new IllegalStateException("Option " + BUNDLE_ID + " must be set to the name of the bundle with the module"); } Bundle bundle = context.getBundle(Long.parseLong(bundleId)); if (bundle == null) { throw new IllegalStateException("No bundle found for id " + bundleId); } try { target = (LoginModule) bundle.loadClass(module).newInstance(); } catch (Exception e) { throw new IllegalStateException("Can not load or create login module " + module + " for bundle " + bundleId, e); } target.initialize(subject, callbackHandler, sharedState, options); }
Example #7
Source File: LDAPLoginModuleTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testCommitOnFailedLogin() throws LoginException { LoginModule loginModule = new LDAPLoginModule(); JaasCallbackHandler callbackHandler = new JaasCallbackHandler(null, null, null); loginModule.initialize(new Subject(), callbackHandler, null, new HashMap<String, Object>()); // login should return false due to null username assertFalse(loginModule.login()); // since login failed commit should return false as well assertFalse(loginModule.commit()); }
Example #8
Source File: LoginContext.java From Bytecoder with Apache License 2.0 | 4 votes |
ModuleInfo(AppConfigurationEntry newEntry, LoginModule newModule) { this.entry = newEntry; this.module = newModule; }
Example #9
Source File: LoginContext.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
ModuleInfo(AppConfigurationEntry newEntry, LoginModule newModule) { this.entry = newEntry; this.module = newModule; }