Created
June 18, 2014 04:03
-
-
Save cognifloyd/821706e48b480bfab292 to your computer and use it in GitHub Desktop.
HackyTYPO3Directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.typo3.sso.crowd; | |
//package com.atlassian.crowd.integration.directory.custom;//TODO: Should this be in the TYPO3 Namespace? | |
import com.atlassian.crowd.integration.authentication.PasswordCredential; | |
// https://docs.atlassian.com/atlassian-crowd/current/com/atlassian/crowd/embedded/api/PasswordCredential.html | |
import com.atlassian.crowd.integration.directory.InternalDirectory; | |
// https://docs.atlassian.com/atlassian-crowd/current/com/atlassian/crowd/directory/InternalDirectory.html | |
// https://docs.atlassian.com/atlassian-crowd/current/com/atlassian/crowd/directory/AbstractInternalDirectory.html | |
// implements InternalRemoteDirectory and RemoteDirectory | |
// https://docs.atlassian.com/atlassian-crowd/current/com/atlassian/crowd/directory/InternalRemoteDirectory.html | |
// https://docs.atlassian.com/atlassian-crowd/current/com/atlassian/crowd/directory/RemoteDirectory.html | |
import com.atlassian.crowd.integration.exception.*; | |
import java.rmi.RemoteException; | |
import java.util.List; | |
// https://developer.atlassian.com/display/CROWDDEV/Creating%20a%20Custom%20Directory%20Connector | |
// https://answers.atlassian.com/questions/116383/how-do-you-create-a-custom-directory-connector-in-crowd | |
// https://answers.atlassian.com/questions/150111/need-help-setting-up-to-develop-a-custom-directory-connector-for-crowd | |
// https://answers.atlassian.com/questions/19501/crowd-integration-api-for-implementing-a-custom-directory-connector | |
// http://koblik.blogspot.nl/2008/11/atlassian-crowd-custom-directory.html | |
public class HackyTYPO3Directory extends InternalDirectory | |
{ | |
@override | |
public User authenticate(String username, PasswordCredential[] credentials) | |
throws RemoteException, InactiveAccountException, InvalidAuthenticationException, | |
ExpiredCredentialException, UserNotFoundException | |
{ | |
//Delegate to shell script here. | |
returnValue = Runtime.getRuntime().exec("authenticate.sh " + username + " " + credentials );//TODO: This script doesn't exist yet. Could call php too. | |
switch (returnValue) { | |
case 0: //success | |
try { | |
User user = findUserByName(username); | |
} catch (UserNotFoundException e) { | |
//add the user to Crowd if it's not there, and populate with default groups. | |
//(groups will be managed in Crowd, then pushed to Jira and Gerrit) | |
String[] userinfo = Runtime.getRuntime().exec("getUserInfo.sh " + username);//TODO: This script doesn't exist yet. Could call php too. | |
//break userinfo into firstName, lastName, displayName, email | |
//Also, somehow get whether or not they've signed the CLA and any other groups. | |
username = ; | |
firstName = ; | |
lastName = ; | |
displayName = ; | |
email = ; | |
//signedCla = ; | |
//groups = ; | |
UserTemplate userTemplate = new UserTemplate(username, firstName, lastName, displayName).setEmailAddress(email); | |
User user = addUser(userTemplate, null); //null password in Crowd. | |
//We might need to add default groups eventually, but Crowd might be able to do that automatically, so we'll ignore it for now. | |
//get defaultGroups | |
//for (String groupname : defaultGroups) { | |
// addUserToGroup(username, groupName); | |
//} | |
} | |
return user; | |
break; | |
case 1: //inactive Account | |
throw InactiveAccountException; | |
break; | |
case 2: //wrong password (auth failed) | |
throw InvalidAuthenticationException; | |
break; | |
case 3: //expired password | |
throw ExpiredCredentialException; | |
break; | |
case 4: //User not found | |
throw UserNotFoundException; | |
break; | |
case 5: //server error | |
default: | |
throw remoteException; | |
break; | |
} | |
throw remoteException; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am trying to create a custom external directory connector for Crowd 2.7.2. I cant find an implementation of InternalDirectory in the Crowd jars. Could you post the specific jar you're using to resolve this reference against in 2.7.1?