Search in sources :

Example 1 with AuthenticationService

use of org.glassfish.security.services.api.authentication.AuthenticationService in project Payara by payara.

the class AuthenticationServiceFactory method provide.

@SecurityScope
public AuthenticationService provide() {
    String currentState = manager.getCurrent();
    // Get Service Instance
    AuthenticationService atnService = AccessController.doPrivileged(new PrivilegedLookup<AuthenticationService>(serviceLocator, AuthenticationService.class));
    // Get Service Configuration
    org.glassfish.security.services.config.AuthenticationService atnConfiguration = serviceLocator.getService(org.glassfish.security.services.config.AuthenticationService.class, currentState);
    // Initialize Service
    atnService.initialize(atnConfiguration);
    return atnService;
}
Also used : AuthenticationService(org.glassfish.security.services.api.authentication.AuthenticationService) SecurityScope(org.glassfish.security.services.common.SecurityScope)

Example 2 with AuthenticationService

use of org.glassfish.security.services.api.authentication.AuthenticationService in project Payara by payara.

the class GlassFishSecurityProvider method authenticate.

@Override
public Object authenticate(String username, String password) {
    gf = getGlassFish();
    AuthenticationService authService = null;
    try {
        authService = getAuthService();
    } catch (GlassFishException gfe) {
        gfe.printStackTrace();
        return null;
    }
    Subject fs = null;
    try {
        fs = authService.login(username, password.toCharArray(), fs);
    } catch (LoginException e) {
        e.printStackTrace();
        return null;
    }
    return fs;
}
Also used : GlassFishException(org.glassfish.embeddable.GlassFishException) LoginException(javax.security.auth.login.LoginException) AuthenticationService(org.glassfish.security.services.api.authentication.AuthenticationService) Subject(javax.security.auth.Subject)

Aggregations

AuthenticationService (org.glassfish.security.services.api.authentication.AuthenticationService)2 Subject (javax.security.auth.Subject)1 LoginException (javax.security.auth.login.LoginException)1 GlassFishException (org.glassfish.embeddable.GlassFishException)1 SecurityScope (org.glassfish.security.services.common.SecurityScope)1