/** * Set the authentication name for this authentication. If the name is already set, then the new name must be * equal to the old name, or else an exception is thrown. * * @param name the authentication name * @throws IllegalArgumentException if the name is syntactically invalid * @throws RealmUnavailableException if the realm is not available * @throws IllegalStateException if the authentication name was already set and there is a mismatch */ public void setAuthenticationName(String name) throws IllegalArgumentException, RealmUnavailableException, IllegalStateException { setAuthenticationName(name, false); }
private boolean restoreIdentity() { if (securityDomain == null) { return false; } HttpScope sessionScope = httpExchangeSpi.getScope(Scope.SESSION); if (sessionScope != null && sessionScope.supportsAttachments()) { String principalName = sessionScope.getAttachment(AUTHENTICATED_PRINCIPAL_KEY, String.class); if (principalName != null) { ServerAuthenticationContext authenticationContext = securityDomain.createNewAuthenticationContext(); try { authenticationContext.setAuthenticationName(principalName); if (authenticationContext.authorize()) { SecurityIdentity authorizedIdentity = authenticationContext.getAuthorizedIdentity(); httpExchangeSpi.authenticationComplete(authorizedIdentity, programaticMechanismName); setupProgramaticLogout(sessionScope); return true; } else { sessionScope.setAttachment(AUTHENTICATED_PRINCIPAL_KEY, null); // Whatever was in there no longer works so just drop it. } } catch (IllegalArgumentException | RealmUnavailableException | IllegalStateException e) { httpExchangeSpi.authenticationFailed(e.getMessage(), programaticMechanismName); } } } return false; }
final PasswordGuessEvidence evidence = new PasswordGuessEvidence(credential != null ? credential : null); try { context.setAuthenticationName(username); if (context.verifyEvidence(evidence)) { if (context.authorize()) {
authenticationContext.setAuthenticationName(username); if (authenticationContext.verifyEvidence(evidence)) { if (authenticationContext.authorize()) {
if (authenticationID != null) { setAuthenticationName(authenticationID); } else { log.tracef("Handling ExclusiveNameCallback: authenticationName = %s needsExclusiveAccess = %b", name, exclusive); if (exclusive) { setAuthenticationName(name, true); exclusiveNameCallback.setExclusiveAccess(true); } else { setAuthenticationName(name); try { log.tracef("Handling NameCallback: authenticationName = %s", name); setAuthenticationName(name); } catch (Exception e) { throw new IOException(e);
/** * Set the authentication name for this authentication. If the name is already set, then the new name must be * equal to the old name, or else an exception is thrown. * * @param name the authentication name * @throws IllegalArgumentException if the name is syntactically invalid * @throws RealmUnavailableException if the realm is not available * @throws IllegalStateException if the authentication name was already set and there is a mismatch */ public void setAuthenticationName(String name) throws IllegalArgumentException, RealmUnavailableException, IllegalStateException { setAuthenticationName(name, false); }
/** * Set the authentication name for this authentication. If the name is already set, then the new name must be * equal to the old name, or else an exception is thrown. * * @param name the authentication name * @throws IllegalArgumentException if the name is syntactically invalid * @throws RealmUnavailableException if the realm is not available * @throws IllegalStateException if the authentication name was already set and there is a mismatch */ public void setAuthenticationName(String name) throws IllegalArgumentException, RealmUnavailableException, IllegalStateException { setAuthenticationName(name, false); }
/** * Set the authentication name for this authentication. If the name is already set, then the new name must be * equal to the old name, or else an exception is thrown. * * @param name the authentication name * @throws IllegalArgumentException if the name is syntactically invalid * @throws RealmUnavailableException if the realm is not available * @throws IllegalStateException if the authentication name was already set and there is a mismatch */ public void setAuthenticationName(String name) throws IllegalArgumentException, RealmUnavailableException, IllegalStateException { setAuthenticationName(name, false); }
authenticationContext.setAuthenticationName(principalName);
private boolean restoreIdentity() { if (securityDomain == null) { return false; } HttpScope sessionScope = httpExchangeSpi.getScope(Scope.SESSION); if (sessionScope != null && sessionScope.supportsAttachments()) { String principalName = sessionScope.getAttachment(AUTHENTICATED_PRINCIPAL_KEY, String.class); if (principalName != null) { ServerAuthenticationContext authenticationContext = securityDomain.createNewAuthenticationContext(); try { authenticationContext.setAuthenticationName(principalName); if (authenticationContext.authorize()) { SecurityIdentity authorizedIdentity = authenticationContext.getAuthorizedIdentity(); httpExchangeSpi.authenticationComplete(authorizedIdentity, programaticMechanismName); setupProgramaticLogout(sessionScope); return true; } else { sessionScope.setAttachment(AUTHENTICATED_PRINCIPAL_KEY, null); // Whatever was in there no longer works so just drop it. } } catch (IllegalArgumentException | RealmUnavailableException | IllegalStateException e) { httpExchangeSpi.authenticationFailed(e.getMessage(), programaticMechanismName); } } } return false; }
private boolean restoreIdentity() { if (securityDomain == null) { return false; } HttpScope sessionScope = httpExchangeSpi.getScope(Scope.SESSION); if (sessionScope != null && sessionScope.supportsAttachments()) { String principalName = sessionScope.getAttachment(AUTHENTICATED_PRINCIPAL_KEY, String.class); if (principalName != null) { ServerAuthenticationContext authenticationContext = securityDomain.createNewAuthenticationContext(); try { authenticationContext.setAuthenticationName(principalName); if (authenticationContext.authorize()) { SecurityIdentity authorizedIdentity = authenticationContext.getAuthorizedIdentity(); httpExchangeSpi.authenticationComplete(authorizedIdentity, programaticMechanismName); setupProgramaticLogout(sessionScope); return true; } else { sessionScope.setAttachment(AUTHENTICATED_PRINCIPAL_KEY, null); // Whatever was in there no longer works so just drop it. } } catch (IllegalArgumentException | RealmUnavailableException | IllegalStateException e) { httpExchangeSpi.authenticationFailed(e.getMessage(), programaticMechanismName); } } } return false; }
private boolean restoreIdentity() { if (securityDomain == null) { return false; } HttpScope sessionScope = httpExchangeSpi.getScope(Scope.SESSION); if (sessionScope != null && sessionScope.supportsAttachments()) { String principalName = sessionScope.getAttachment(AUTHENTICATED_PRINCIPAL_KEY, String.class); if (principalName != null) { ServerAuthenticationContext authenticationContext = securityDomain.createNewAuthenticationContext(); try { authenticationContext.setAuthenticationName(principalName); if (authenticationContext.authorize()) { SecurityIdentity authorizedIdentity = authenticationContext.getAuthorizedIdentity(); httpExchangeSpi.authenticationComplete(authorizedIdentity, programaticMechanismName); setupProgramaticLogout(sessionScope); return true; } else { sessionScope.setAttachment(AUTHENTICATED_PRINCIPAL_KEY, null); // Whatever was in there no longer works so just drop it. } } catch (IllegalArgumentException | RealmUnavailableException | IllegalStateException e) { httpExchangeSpi.authenticationFailed(e.getMessage(), programaticMechanismName); } } } return false; }
final PasswordGuessEvidence evidence = new PasswordGuessEvidence(credential != null ? credential : null); try { context.setAuthenticationName(username); if (context.verifyEvidence(evidence)) { if (context.authorize()) {
private SecurityIdentity authenticate(final String username, final String password) { ServerAuthenticationContext context = this.securityDomain.createNewAuthenticationContext(); PasswordGuessEvidence evidence = new PasswordGuessEvidence(password != null ? password.toCharArray() : null); try { context.setAuthenticationName(username); if (context.verifyEvidence(evidence)) { if (context.authorize()) { context.succeed(); return context.getAuthorizedIdentity(); } else { context.fail(); WSLogger.ROOT_LOGGER.failedAuthorization(username); } } else { context.fail(); WSLogger.ROOT_LOGGER.failedAuthentication(username); } } catch (IllegalArgumentException | IllegalStateException | RealmUnavailableException e) { context.fail(); WSLogger.ROOT_LOGGER.failedAuthenticationWithException(e, username, e.getMessage()); } finally { if (!context.isDone()) context.fail(); //prevent leaks of RealmIdentity instances evidence.destroy(); } return null; }
private SecurityIdentity authenticate(final String username, final String password) { ServerAuthenticationContext context = this.securityDomain.createNewAuthenticationContext(); PasswordGuessEvidence evidence = new PasswordGuessEvidence(password != null ? password.toCharArray() : null); try { context.setAuthenticationName(username); if (context.verifyEvidence(evidence)) { if (context.authorize()) { context.succeed(); return context.getAuthorizedIdentity(); } else { context.fail(); WSLogger.ROOT_LOGGER.failedAuthorization(username); } } else { context.fail(); WSLogger.ROOT_LOGGER.failedAuthentication(username); } } catch (IllegalArgumentException | IllegalStateException | RealmUnavailableException e) { context.fail(); WSLogger.ROOT_LOGGER.failedAuthenticationWithException(e, username, e.getMessage()); } finally { if (!context.isDone()) context.fail(); //prevent leaks of RealmIdentity instances evidence.destroy(); } return null; }
authenticationContext.setAuthenticationName(username); if (authenticationContext.verifyEvidence(evidence)) { if (authenticationContext.authorize()) {
authenticationContext.setAuthenticationName(username); if (authenticationContext.verifyEvidence(evidence)) { if (authenticationContext.authorize()) {
context.setAuthenticationName(username); evidence = new PasswordGuessEvidence(password.toCharArray()); if (context.verifyEvidence(evidence)) {
context.setAuthenticationName(username); evidence = new PasswordGuessEvidence(password.toCharArray()); if (context.verifyEvidence(evidence)) {
authenticationContext.setAuthenticationName(username); if (authenticationContext.verifyEvidence(evidence)) { if (evidence instanceof PasswordGuessEvidence) {