/** * Returns an authentication request initialized with the supplied request. * * @param request authentication request to read properties from * * @return authentication request */ public static AuthenticationRequest newAuthenticationRequest(final AuthenticationRequest request) { final AuthenticationRequest r = new AuthenticationRequest(); r.setUser(request.getUser()); r.setCredential(request.getCredential()); r.setReturnAttributes(request.getReturnAttributes()); r.setControls(request.getControls()); return r; }
/** * Creates a new authentication request. * * @param u that identifies the user * @param c credential to authenticate the user */ public AuthenticationRequest(final User u, final Credential c) { setUser(u); setCredential(c); }
/** * Creates a new authentication request. * * @param u that identifies the user * @param c credential to authenticate the user * @param attrs attributes to return */ public AuthenticationRequest(final User u, final Credential c, final String... attrs) { setUser(u); setCredential(c); setReturnAttributes(attrs); }
/** * Initialize an authentication request with command line options. * * @param line parsed command line arguments * * @return authentication request that has been initialized */ protected AuthenticationRequest initAuthenticationRequest(final CommandLine line) { final AuthenticationRequest request = new AuthenticationRequest(); final AuthenticationRequestPropertySource arSource = new AuthenticationRequestPropertySource( request, getPropertiesFromOptions(PropertyDomain.AUTH.value(), line)); arSource.initialize(); if (request.getUser() == null) { // prompt for a user name final String user = System.console().readLine("[Enter user name]: "); request.setUser(user); } if (request.getCredential() == null) { // prompt the user to enter a password final char[] pass = System.console().readPassword("[Enter password for %s]: ", request.getUser()); request.setCredential(new Credential(pass)); } return request; }
@Override public AuthenticationRequest createAuthenticationRequest(final Map<String, ?> jaasOptions) { final AuthenticationRequest ar = new AuthenticationRequest(); final AuthenticationRequestPropertySource source = new AuthenticationRequestPropertySource( ar, createProperties(jaasOptions)); source.initialize(); logger.trace("Created authentication request {} from {}", ar, jaasOptions); return ar; }
final AuthenticationRequest newRequest = AuthenticationRequest.newAuthenticationRequest(request); if (returnAttributes != null) { if (newRequest.getReturnAttributes() == null || ReturnAttributes.NONE.equalsAttributes(newRequest.getReturnAttributes())) { newRequest.setReturnAttributes(returnAttributes); } else { newRequest.setReturnAttributes(LdapUtils.concatArrays(newRequest.getReturnAttributes(), returnAttributes));
if (entryResolver != null) { er = entryResolver; } else if (!ReturnAttributes.NONE.equalsAttributes(request.getReturnAttributes())) { er = new SearchEntryResolver(); } else {
if (request.getReturnAttributes() != null && request.getReturnAttributes().length == 0) { request.setReturnAttributes(ReturnAttributes.ALL_USER.value());
@Override public void handle(final String dn, final AuthenticationRequest request) throws LdapException { final RequestControl[] ctls = controlFactory.getControls(dn, request.getUser()); logger.trace("{} produced controls {}", controlFactory, Arrays.toString(ctls)); if (ctls != null && ctls.length > 0) { if (request.getControls() != null && request.getControls().length > 0) { request.setControls(LdapUtils.concatArrays(request.getControls(), ctls)); } else { request.setControls(ctls); } } }
/** * Returns the credential. * * @return credential to authenticate dn */ public Credential getCredential() { return authenticationRequest.getCredential(); }
/** * Authenticate the user in the supplied request. * * @param request authentication request * * @return response containing the ldap entry of the user authenticated * * @throws LdapException if an LDAP error occurs */ public AuthenticationResponse authenticate(final AuthenticationRequest request) throws LdapException { return authenticate(resolveDn(request.getUser()), request); }
authRequest.setReturnAttributes(userRoleAttribute); logger.debug("Retrieved authentication request from factory: {}", authRequest);
/** * Initialize an authentication request with command line options. * * @param line parsed command line arguments * * @return authentication request that has been initialized */ protected AuthenticationRequest initAuthenticationRequest(final CommandLine line) { final AuthenticationRequest request = new AuthenticationRequest(); final AuthenticationRequestPropertySource arSource = new AuthenticationRequestPropertySource( request, getPropertiesFromOptions(PropertyDomain.AUTH.value(), line)); arSource.initialize(); if (request.getUser() == null) { // prompt for a user name final String user = System.console().readLine("[Enter user name]: "); request.setUser(new User(user)); } if (request.getCredential() == null) { // prompt the user to enter a password final char[] pass = System.console().readPassword("[Enter password for %s]: ", request.getUser()); request.setCredential(new Credential(pass)); } return request; }
@Override public AuthenticationRequest createAuthenticationRequest(final Map<String, ?> jaasOptions) { final AuthenticationRequest ar = new AuthenticationRequest(); final AuthenticationRequestPropertySource source = new AuthenticationRequestPropertySource( ar, createProperties(jaasOptions)); source.initialize(); logger.trace("Created authentication request {} from {}", ar, jaasOptions); return ar; }
/** * Creates a new authentication request. * * @param u that identifies the user * @param c credential to authenticate the user * @param attrs attributes to return */ public AuthenticationRequest(final User u, final Credential c, final String... attrs) { setUser(u); setCredential(c); setReturnAttributes(attrs); }
/** * Creates a new authentication request. * * @param id that identifies the user * @param c credential to authenticate the user */ public AuthenticationRequest(final String id, final Credential c) { setUser(id); setCredential(c); }
final AuthenticationRequest newRequest = AuthenticationRequest.newAuthenticationRequest(request); if (returnAttributes != null) { if (newRequest.getReturnAttributes() == null || ReturnAttributes.NONE.equalsAttributes(newRequest.getReturnAttributes())) { newRequest.setReturnAttributes(returnAttributes); } else { newRequest.setReturnAttributes(LdapUtils.concatArrays(newRequest.getReturnAttributes(), returnAttributes));
if (entryResolver != null) { er = entryResolver; } else if (!ReturnAttributes.NONE.equalsAttributes(criteria.getAuthenticationRequest().getReturnAttributes())) { if (dnResolver instanceof AggregateDnResolver) { er = ((AggregateDnResolver) dnResolver).createEntryResolver(new SearchEntryResolver());
if (request.getReturnAttributes() != null && request.getReturnAttributes().length == 0) { request.setReturnAttributes(ReturnAttributes.ALL_USER.value());
@Override public void handle(final String dn, final AuthenticationRequest request) throws LdapException { final RequestControl[] ctls = controlFactory.getControls(dn, request.getUser()); logger.trace("{} produced controls {}", controlFactory, Arrays.toString(ctls)); if (ctls != null && ctls.length > 0) { if (request.getControls() != null && request.getControls().length > 0) { request.setControls(LdapUtils.concatArrays(request.getControls(), ctls)); } else { request.setControls(ctls); } } }