Re: [cas-user] Cas Custom Login Field
Thanks. On Wed, Feb 7, 2018 at 8:52 AM, Ramakrishna Gwrote: > > @Override > > protected HandlerResult authenticateUsernamePasswordInternal(final > UsernamePasswordCredential credentials, final String originalPassword) > > throws GeneralSecurityException, PreventedException > > { > > try > > { > > if(validateCredentials(credentials.getUsername(), > credentials.getPassword(), > credentials.getPancard())) > > { > > final String username = credentials.getUsername(); > > HandlerResult result = createHandlerResult(credentials, this. > principalFactory.createPrincipal(username), null); > > return result; > > } > > } > > catch (final Exception e) > > { > > throw new FailedLoginException(); > > } > > throw new FailedLoginException(); > > } > > > validateCredentials method takes all my parameters and validates the user. > > > On Wednesday, February 7, 2018 at 6:22:03 PM UTC+5:30, Jeffrey Ramsay > wrote: >> >> :) Let us know how your custom authentication handler works out; I'm >> interesting in doing this the correct way, eventually. >> >> -Jeff >> >> On Wed, Feb 7, 2018 at 7:32 AM, Ramakrishna G wrote: >> >>> Hey Jeffrey Ramsay, Thankyou so much. You have saved me!! >>> >>> >>> Ramakrishna G >>> >>> On Tue, Feb 6, 2018 at 6:18 PM, Jeffrey Ramsay >>> wrote: >>> In addition to modding the login-webflow.xml form to add "database" as a required property, I modified UsernamePasswordCredential.java and AbstractUsernamePasswordAuthenticationHandler.java to get the value of the new form element; see highlighted. Also, I modified QueryDatabaseAuthenticationHandler.java to extend the SQL query with a new conditional for jdbc authentication: cas.authn.jdbc.query[0].sql=select * from cas_users where cas_user=? and cas_domain=? I'm now stuck trying to mod CasPersonDirectoryConfiguration.java to get attributes per user by domain/database cas.authn.attributeRepository.jdbc[0].sql=*select * from cas_attrs where {0}* I plan to rename database to domain as to not confuse anyone. file: UsernamePasswordCredential.java package org.apereo.cas.authentication; import org.apache.commons.lang3.builder.HashCodeBuilder; import javax.validation.constraints.Size; import java.io.Serializable; /** * Credential for authenticating with a username and password. * * @author Scott Battaglia * @author Marvin S. Addison * @since 3.0.0 */ public class UsernamePasswordCredential implements Credential, Serializable { /** * Authentication attribute name for password. **/ public static final String AUTHENTICATION_ATTRIBUTE_PASSWORD = "credential"; public static final String AUTHENTICATION_ATTRIBUTE_DATABASE = "credential"; private static final long serialVersionUID = -700605081472810939L; @Size(min = 1, message = "required.username") private String username; @Size(min = 1, message = "required.password") private String password; private String database; /** * Default constructor. */ public UsernamePasswordCredential() { } /** * Creates a new instance with the given username and password. * * @param userName Non-null user name. * @param password Non-null password. */ public UsernamePasswordCredential(final String userName, final String password, final String database) { this.username = userName; this.password = password; this.database = database; } public String getPassword() { return this.password; } public void setPassword(final String password) { this.password = password; } public String getDatabase() { return this.database; } public void setDatabase(final String database) { this.database = database; } public String getUsername() { return this.username; } public void setUsername(final String userName) { this.username = userName; } @Override public String getId() { return this.username; } @Override public String toString() { return this.username; } @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() !=
Re: [cas-user] Cas Custom Login Field
@Override protected HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credentials, final String originalPassword) throws GeneralSecurityException, PreventedException { try { if(validateCredentials(credentials.getUsername(), credentials.getPassword(), credentials.getPancard())) { final String username = credentials.getUsername(); HandlerResult result = createHandlerResult(credentials, this. principalFactory.createPrincipal(username), null); return result; } } catch (final Exception e) { throw new FailedLoginException(); } throw new FailedLoginException(); } validateCredentials method takes all my parameters and validates the user. On Wednesday, February 7, 2018 at 6:22:03 PM UTC+5:30, Jeffrey Ramsay wrote: > > :) Let us know how your custom authentication handler works out; I'm > interesting in doing this the correct way, eventually. > > -Jeff > > On Wed, Feb 7, 2018 at 7:32 AM, Ramakrishna G> wrote: > >> Hey Jeffrey Ramsay, Thankyou so much. You have saved me!! >> >> >> Ramakrishna G >> >> On Tue, Feb 6, 2018 at 6:18 PM, Jeffrey Ramsay > > wrote: >> >>> In addition to modding the login-webflow.xml form to add "database" as >>> a required property, I modified UsernamePasswordCredential.java and >>> AbstractUsernamePasswordAuthenticationHandler.java to get the value of the >>> new form element; see highlighted. >>> >>> Also, I modified QueryDatabaseAuthenticationHandler.java to extend the >>> SQL query with a new conditional for jdbc authentication: >>> >>> cas.authn.jdbc.query[0].sql=select * from cas_users where cas_user=? and >>> cas_domain=? >>> >>> I'm now stuck trying to mod CasPersonDirectoryConfiguration.java to get >>> attributes per user by domain/database >>> >>> cas.authn.attributeRepository.jdbc[0].sql=*select * from cas_attrs >>> where {0}* >>> >>> I plan to rename database to domain as to not confuse anyone. >>> >>> file: UsernamePasswordCredential.java >>> >>> package org.apereo.cas.authentication; >>> >>> import org.apache.commons.lang3.builder.HashCodeBuilder; >>> >>> import javax.validation.constraints.Size; >>> import java.io.Serializable; >>> >>> /** >>> * Credential for authenticating with a username and password. >>> * >>> * @author Scott Battaglia >>> * @author Marvin S. Addison >>> * @since 3.0.0 >>> */ >>> public class UsernamePasswordCredential implements Credential, >>> Serializable { >>> >>> /** >>> * Authentication attribute name for password. >>> **/ >>> public static final String AUTHENTICATION_ATTRIBUTE_PASSWORD = >>> "credential"; >>> public static final String AUTHENTICATION_ATTRIBUTE_DATABASE = >>> "credential"; >>> >>> private static final long serialVersionUID = -700605081472810939L; >>> >>> @Size(min = 1, message = "required.username") >>> private String username; >>> >>> @Size(min = 1, message = "required.password") >>> private String password; >>> >>> private String database; >>> >>> /** >>> * Default constructor. >>> */ >>> public UsernamePasswordCredential() { >>> } >>> >>> /** >>> * Creates a new instance with the given username and password. >>> * >>> * @param userName Non-null user name. >>> * @param password Non-null password. >>> */ >>> public UsernamePasswordCredential(final String userName, final >>> String password, final String database) { >>> this.username = userName; >>> this.password = password; >>> this.database = database; >>> } >>> >>> public String getPassword() { >>> return this.password; >>> } >>> >>> public void setPassword(final String password) { >>> this.password = password; >>> } >>> >>> public String getDatabase() { >>> return this.database; >>> } >>> >>> public void setDatabase(final String database) { >>> this.database = database; >>> } >>> >>> public String getUsername() { >>> return this.username; >>> } >>> >>> public void setUsername(final String userName) { >>> this.username = userName; >>> } >>> >>> @Override >>> public String getId() { >>> return this.username; >>> } >>> >>> @Override >>> public String toString() { >>> return this.username; >>> } >>> >>> @Override >>> public boolean equals(final Object o) { >>> if (this == o) { >>> return true; >>> } >>> if (o == null || getClass() != o.getClass()) { >>> return false; >>> } >>> >>> final UsernamePasswordCredential that = >>> (UsernamePasswordCredential) o; >>> >>> if (this.password != null ? !this.password.equals(that.password) >>> : that.password !=
[cas-user] Cas Custom Login Field
Hi Community, I am using cas-overlay-maven with version 5.2.1 I need to have 3 fields. Login, Pancard and then Password. I copied login-webflow.xml inside src/main/resources and added the binding. It does not show anything on ui. What else I am missing? -- - Website: https://apereo.github.io/cas - Gitter Chatroom: https://gitter.im/apereo/cas - List Guidelines: https://goo.gl/1VRrw7 - Contributions: https://goo.gl/mh7qDG --- You received this message because you are subscribed to the Google Groups "CAS Community" group. To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+unsubscr...@apereo.org. To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/12d510ba-147e-4422-8042-ae05761757ee%40apereo.org.