It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

custom JiraSeraphAuthenticator class compiling issues

shivanand kadalli Nov 08, 2011

Hi,

I am trying to implement SSO for JIRA and trying to extend JiraSeraphAuthenticator class. Here is my code

package com.siteminder.jira;

//For version 2.1.x of Confluence with UID

import java.security.*;
import javax.servlet.http.*;
import org.apache.log4j.*;

import com.atlassian.seraph.auth.*;
import com.atlassian.user.User;
import com.atlassian.spring.container.ContainerManager;
import java.util.*;
import com.atlassian.confluence.user.UserAccessor;
import com.atlassian.jira.security.*;
public class SiteMinderAuthenticator
extends com.atlassian.jira.security.login.JiraSeraphAuthenticator

{
private static final Category log;
static
{
log = Category.getInstance(SiteMinderAuthenticator.class);
}

public Principal getUser(HttpServletRequest request,
HttpServletResponse response)
{
log.debug("SMAuthenticator::getUser(HttpServletRequest request, HttpServletResponse response)");
Principal user = super.getUser(request, response);
String username = request.getHeader("SM_USER");
Cookie c[] = request.getCookies();


for(int i=0;i<c.length;i++)
{

Cookie ck=c[i];
if ("newuser".equals(ck.getName()))
username = ck.getValue();

}


log.warn("request.getHeader('sm_user'):" + username);
String password = "temp1234";
String email = request.getHeader("UI_mail");
String fullname = request.getHeader("UI_name");
if ( (user == null) && (username == null))
{
log.warn("No user or username");
return user;
}
if (user != null)
{
if ( (username != null) && (user.getName().compareTo(username) == 0))
{
return user;
}
else
{
log.warn("Session found; different user already logged in");
user = null;
}
}
try
{
UserAccessor userAccessor =
(UserAccessor) com.atlassian.spring.container.ContainerManager.getInstance().getContainerContext().getComponent("userAccessor");

user = userAccessor.getUser(username.toLowerCase());
if(user != null)
{
log.debug("Logged user in via a headers");
}
else
{
// Try creating new user
}
}
catch (Exception ex)
{
log.error(ex.getMessage());
}
return user;
}
}

I am getting issues while compiling. I have set class path correctly. The error is

C:\ANT\com.confluence\src\SiteMinderAuthenticator.java:16: package com.atlassian.jira.security.login does not exist
[javac] extends com.atlassian.jira.security.login.JiraSeraphAuthenticator
[javac] ^
[javac] C:\ANT\com.confluence\src\SiteMinderAuthenticator.java:29: cannot find symbol
[javac] symbol : variable super
[javac] location: class com.siteminder.jira.SiteMinderAuthenticator
[javac] Principal user = super.getUser(request, response);
[javac] ^
[javac] Note: C:\ANT\com.confluence\src\SiteMinderAuthenticator.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 2 errors

I am not sure why the compiler is not able to find this package.Any help would be greatly helpful

Thanks

shiv

5 answers

0 votes
Colin Goudie Nov 08, 2011

How are you compiling this? With Maven? It sounds like your classpath is wrong somewhere

0 votes
shivanand kadalli Nov 08, 2011

I am using ANT and by build.xml file looks like this

<project name="confluence" basedir="." default="main">

<property name="src.dir" value="src"/>

<property name="build.dir" value="build"/>

<property name="lib.dir" value="lib"/>

<property name="classes.dir" value="${build.dir}/classes"/>

<property name="jar.dir" value="${build.dir}/jar"/>

<property name="main-class" value="com.siteminder.confluence.SiteMinderAuthenticator"/>

<property name="login1.dir" value="C:\Program Files\Atlassian\JIRA 4.3.4\atlassian-jira\WEB-INF\lib\" />

<property name="login.dir" value="C:\Program Files\Atlassian\JIRA 4.3.4\atlassian-jira\WEB-INF\classes\com\atlassian\jira\security\login" />

<path id="classpath">

<fileset dir="${lib.dir}" includes="**/*.jar" />

<fileset dir="${lib.dir}" includes="**/*.class" />

<fileset dir="${login1.dir}" includes="**/*.jar" />

<fileset dir="${login.dir}" includes="**/*.class" />

</path>

<target name="clean">

<delete dir="${build.dir}"/>

</target>

<target name="compile">

<mkdir dir="${classes.dir}"/>

<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>

</target>

<target name="jar" depends="compile">

<mkdir dir="${jar.dir}"/>

<jar destfile="${jar.dir}/SiteMinderAuthenticator.jar" basedir="${classes.dir}">

<manifest>

<attribute name="Main-Class" value="${main-class}"/>

</manifest>

</jar>

</target>

<target name="clean-build" depends="clean,jar"/>

<target name="main" depends="clean,compile"/>

</project>

When i compile with verbose option, i see that the compiler scans through all the classes within C:\Program Files\Atlassian\JIRA 4.3.4\atlassian-jira\WEB-INF\classes\com\atlassian\jira\security\login directory

Some how i am not able to make ant recognise the classpath. By the way, I am new to Java(I am .net guy). Pardon me if i am doing a silly mistake.

Thanks

shiv

0 votes
Dieter Nov 09, 2011

I'm not sure if you include all necessary classes in the classpath by using

<property name="login.dir" value="C:\Program Files\Atlassian\JIRA 4.3.4\atlassian-jira\WEB-INF\classes\com\atlassian\jira\security\login" />

Please try to shorten that to

<property name="login.dir" value="C:\Program Files\Atlassian\JIRA 4.3.4\atlassian-jira\WEB-INF\classes" />

to make sure all JIRA classes are scanned

shivanand kadalli Nov 09, 2011

By the way i have more fundamental questions regarding this

Is it possible to Extend JiraSeraphAuthenticator class to acheive Sitemeinder authentication?

If so, then i didn't see a correct getUser method which i can override because it has only one getuser(string username) method and not getUser(Httprequest,HttpResponse) method i am looking.

Second, Which is the simple and cleanest way of compiling jira classes? is it ANT or Marven like Colin suggested above?

Dieter Nov 09, 2011

Hi Shivanand,

The question regarding Siteminder would be a good candidate for a new question on AAC. Please let's first solve your compile problem here. I'd also recommend to use the Atlassian SDK to develop plugins. This SDK is Maven2 based

Best regards,

Dieter

shivanand kadalli Nov 15, 2011

I did shorten the classpath to "C:\Program Files\Atlassian\JIRA 4.3.4\atlassian-jira\WEB-INF\classes"

It still gave me the same error. Cannot find package com.atlassian.jira.security.login does not exist

Does JiraSeraphAuthenticator has a different package name? I thought its in

com.atlassian.jira.security.login

Any insight in to this issue would be of great help. By the way, Sincere thanks to Dieter and colin for paying attention to my questions

Dieter Nov 15, 2011

Sorry i could not help better. I'd recommend you to switch to get the Atlassian Plugin SDK. If the code you want to ccompile has a pom.xml the compilation using the SDK should work flawlessly if you have an internet connection (idealy without proxy since sometimes getting Maven work through a proxy can become difficult)

0 votes
Guido Wischrop Nov 15, 2011

Hi,

this page gives some help for a SiteMinder Confluence implementation:

http://confluence.atlassian.com/display/DEV/SiteMinder+Custom+Seraph+Authenticator+for+Confluence?focusedCommentId=198806463#comment-198806463

Just as a note: We are extending com.atlassian.seraph.auth.DefaultAuthenticator for our SiteMinder SSO plugin.

Good luck,

Guido

0 votes
Tim Theis Oct 10, 2012

Shivanand-

Have you had any luck with your creating your custom authenticator to utilize Siteminder SSO?

I have been able to do this by extending JiraSeraphAuthenticator (JIRA 4.4.5), but still facing an issue that the custom authenticator is bypassing the auto-adding of first time users to the jira-users group.

I have posted a related issue:

https://answers.atlassian.com/questions/89941/issues-with-customer-authenticator-used-for-sso-with-siteminder

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Off-topic

Disney Live Action Reboots: Are you for or against?

Happy Friday Everyone! Today marks the international release of Disney's live action version of the animated classic Aladdin. I know that this movie was met with some controversy of over cast...

139 views 19 8
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you