Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mss committed Jun 29, 2019
2 parents 0409c4d + 29039d2 commit acd6ad5
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ before_install:
- "ls -1 zimbra-common-core-jar_*_amd64.deb | xargs -t sudo dpkg --install --ignore-depends=zimbra-core-components"
- "sudo sed -i -e '/^Depends: zimbra-core-components/d' /var/lib/dpkg/status"
- "rsync -rt -i /opt/zimbra/lib/jars/ lib/"

cache:
directories:
- $HOME/.m2/
- lib/
53 changes: 27 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,6 @@ This Zimbra extensions implements a custom auth handler which authenticates
Zimbra accounts against an installation of Atlassian Crowd.


## Getting Started

### Prerequisites

This project depends on some Zimbra libraries which have to be placed in
the `lib` directory since they aren't available via Maven Central.

Just execute the script `lib.sh` to pull and extract them from the Zimbra
repositories. Alternatively you can copy them from an existing Zimbra
server:

```
rsync -rt -i --delete zimbra.example.com:/opt/zimbra/lib/jars/ lib/ --include 'zimbra*.jar' --exclude '*.jar'
```

### Compilation

This project is built with Maven. Just execute the following command:

```
mvn package
```

This will create a bundle `target/zimbra-crowd-extension.zip` which contains
the extension plus all the required libraries.


## Installation

Expand Down Expand Up @@ -85,6 +59,33 @@ zmprov modifyAccount [email protected] +zimbraForeignPrincipal crowd:jdoe
```


## Development

### Prerequisites

This project depends on some Zimbra libraries which have to be placed in
the `lib` directory since they aren't available via Maven Central.

Just execute the script `lib.sh` to pull and extract them from the Zimbra
repositories. Alternatively you can copy them from an existing Zimbra
server:

```
rsync -rt -i --delete zimbra.example.com:/opt/zimbra/lib/jars/ lib/ --include 'zimbra*.jar' --exclude '*.jar'
```

### Compilation

This project is built with Maven. Just execute the following command:

```
mvn package
```

This will create a bundle `target/zimbra-crowd-extension.zip` which contains
the extension plus all the required libraries.


## License

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
35 changes: 33 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>de.silpion.zimbra.extension.crowd</groupId>
<artifactId>zimbra-crowd-extension</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>

<name>Zimbra Crowd Authentication Extension</name>
<description>Zimbra extension which allows authentication against Atlassian Crowd</description>
Expand All @@ -23,6 +23,12 @@
<url>https://www.silpion.de</url>
</organization>

<scm>
<url>https://github.com/silpion/zimbra-crowd-extension</url>
<connection>scm:git:https://github.com/silpion/zimbra-crowd-extension.git</connection>
<developerConnection>scm:git:[email protected]:silpion/zimbra-crowd-extension.git</developerConnection>
</scm>

<properties>
<crowd.version>3.4.5</crowd.version>
<zimbra.version>8.8.11</zimbra.version>
Expand Down Expand Up @@ -92,7 +98,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.2</version>
<configuration>
<archive>
<manifest>
Expand Down Expand Up @@ -155,6 +161,31 @@
<url>${wagon.url}</url>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M2</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.0.5</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.amashchenko.maven.plugin</groupId>
<artifactId>gitflow-maven-plugin</artifactId>
<version>1.12.0</version>
</plugin>
</plugins>
<extensions>
<extension>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.List;
import java.util.Map;

import com.atlassian.crowd.exception.CrowdException;
import com.zimbra.common.util.ZimbraLog;
import com.zimbra.cs.account.Account;
import com.zimbra.cs.account.auth.ZimbraCustomAuth;
Expand All @@ -35,9 +36,13 @@ public void authenticate(Account account, String password, Map<String, Object> c
try {
new CrowdAccount(account, args).authenticate(password);
}
catch (Exception e) {
catch (CrowdException e) {
ZimbraLog.account.debug("Crowd: Authentication failed: %s", e.getMessage(), e);
throw e;
}
catch (Exception e) {
ZimbraLog.account.error("Crowd: Unexpected %s: %s", e.getClass().getName(), e.getMessage(), e);
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Optional;

import com.zimbra.common.util.QuotedStringParser;
import com.zimbra.common.util.ZimbraLog;
import com.zimbra.cs.account.Domain;

import de.silpion.zimbra.extension.crowd.CrowdExtension;
Expand All @@ -33,20 +34,31 @@ public class CrowdAuthMech {

public CrowdAuthMech(Domain domain) {
config = Optional.ofNullable(domain.getAuthMech()).orElse("");
if (hasArgs()) {
ZimbraLog.extensions.warn("Crowd: Domain %s has configuration arguments. This API is not stable yet and the format of the arguments will probably change in a future release", domain.getName());
}
}

public boolean isEnabled() {
if (!config.startsWith(AUTH_MECH_PREFIX)) {
return false;
}
final int l = AUTH_MECH_PREFIX.length();
return config.startsWith(AUTH_MECH_PREFIX) &&
((config.length() == l) || config.substring(l, l + 1).equals(SPACE));
return config.length() == l || config.substring(l, l + 1).equals(SPACE);
}

public List<String> getArgs() {
final int l = AUTH_MECH_PREFIX.length();
if (!isEnabled() || config.length() == l) {
if (!hasArgs()) {
return Collections.emptyList();
}
final QuotedStringParser parser = new QuotedStringParser(config.substring(l + SPACE.length()));
return parser.parse();
return parseArgString(config.substring(AUTH_MECH_PREFIX.length() + SPACE.length()));
}

private boolean hasArgs() {
return isEnabled() && config.length() > AUTH_MECH_PREFIX.length();
}

private static List<String> parseArgString(String args) {
return new QuotedStringParser(args).parse();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.Map;

import com.atlassian.crowd.exception.CrowdException;
import com.zimbra.common.service.ServiceException;
import com.zimbra.common.util.ZimbraLog;
import com.zimbra.cs.account.Account;
Expand All @@ -37,10 +38,14 @@ public void preModify(Account account, String password, @SuppressWarnings("rawty
try {
new CrowdAccount(account).changePassword(password);
}
catch (Exception e) {
catch (CrowdException e) {
ZimbraLog.account.debug("Crowd: Password change failed: %s", e.getMessage(), e);
throw AccountServiceException.CHANGE_PASSWORD();
}
catch (Exception e) {
ZimbraLog.account.error("Crowd: Unexpected %s: %s", e.getClass().getName(), e.getMessage(), e);
throw AccountServiceException.CHANGE_PASSWORD();
}
}

@Override
Expand Down

0 comments on commit acd6ad5

Please sign in to comment.