Extends LdapAuthenticationHandler in cas 5.2

236 views
Skip to first unread message

satnam

unread,
Jan 11, 2018, 6:37:05 PM1/11/18
to CAS Community
Hello,

We are trying to upgrade CAS from 4.2.7 to 5.2.x.  In 4.2, we extended LdapAuthenticationHandler to make our customization (to convert GUID to databaseUserID.. we use LDAP to verifty password, then return database mapped ID to application, which application use latter in the process).  When we try to do same thing in 5.2, we get error on build. 

Is there better way to do this in 5.2.x? 


[ERROR] /C:/Projects/PASS5.2/trunk/build/CAS_Server/post-cas-server/src/main/java/gov/ca/post/PostLdapAuthenticationHandler.java:[16,8] cannot access org.apereo.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandler
  class file for org.apereo.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandler not found
[ERROR] /C:/Projects/PASS5.2/trunk/build/CAS_Server/post-cas-server/src/main/java/gov/ca/post/PostLdapAuthenticationHandler.java:[10,37] cannot find symbol
  symbol:   class UsernamePasswordCredential
  location: package org.apereo.cas.authentication
[ERROR] /C:/Projects/PASS5.2/trunk/build/CAS_Server/post-cas-server/src/main/java/gov/ca/post/PostLdapAuthenticationHandler.java:[11,47] cannot find symbol
  symbol:   class DefaultPrincipalFactory
  location: package org.apereo.cas.authentication.principal



package org.apereo.cas;

import java.util.Map;

import javax.validation.constraints.NotNull;

import org.apereo.cas.authentication.HandlerResult;
import org.apereo.cas.authentication.LdapAuthenticationHandler;
import org.apereo.cas.authentication.Credential;
import org.apereo.cas.authentication.UsernamePasswordCredential;
import org.apereo.cas.authentication.principal.DefaultPrincipalFactory;
import org.apereo.cas.authentication.principal.Principal;
import org.apereo.cas.authentication.principal.PrincipalFactory;
import org.ldaptive.auth.Authenticator;

public class PostLdapAuthenticationHandler extends LdapAuthenticationHandler {
    private IDAL dal = null;

    public PostLdapAuthenticationHandler(@NotNull final Authenticator authenticator, final IDAL dal) {
        super(authenticator);
        this.dal = dal;
    }


......

Pablo Vidaurri

unread,
Jan 11, 2018, 11:46:42 PM1/11/18
to CAS Community
Are you trying to map/release attributes? If so try to define a mapping in your service config:

"attributeReleasePolicy" : {
    "@class" : "org.apereo.cas.services.ReturnMappedAttributeReleasePolicy",
    "allowedAttributes" : {
      "@class" : "java.util.TreeMap",
      "mail" : "Email",
      "GivenName" : "GivenName",
      "commonName" : "Aliases"       <-- retrieves commonName from ldap but released as "Aliases" to client

Abylay

unread,
Jan 12, 2018, 4:36:14 AM1/12/18
to CAS Community
Did you try to add the dependency with NotFound class?

1. Find the class in your IDE.
2. Add the dependency in which this class is located.

For AbstractUsernamePasswordAuthenticationHandler it would be 
<dependency>
   
<groupId>org.apereo.cas</groupId>
   
<artifactId>cas-server-core-authentication</artifactId>
   
<version>${cas.version}</version>
   
<scope>compile</scope>
</dependency>


satnam

unread,
Jan 16, 2018, 1:01:22 PM1/16/18
to CAS Community

Thanks,


In 4.2, we were overwriting preAuthenticate and postAuthenticate function to make our changes.


what is the best way to do this in 5.2?  attached is flow chart of what we are doing in 4.2
cas custom.pdf
Reply all
Reply to author
Forward
0 new messages