[Minor] added authenticateSingleSignOn method

This commit is contained in:
Reto Breitenmoser 2017-10-08 21:19:30 +02:00
parent adf53dd49f
commit 283a78bdfa
2 changed files with 29 additions and 0 deletions

View File

@ -132,6 +132,22 @@ public class DefaultStrolchPrivilegeHandler extends StrolchComponent implements
}
return certificate;
}
@Override
public Certificate authenticateSingleSignOn(Object data) {
assertContainerStarted();
Certificate certificate = this.privilegeHandler.authenticateSingleSignOn(data);
StrolchRealm realm = getContainer().getRealm(certificate);
try (StrolchTransaction tx = realm.openTx(certificate, StrolchPrivilegeConstants.LOGIN)) {
tx.setSuppressDoNothingLogging(true);
tx.setSuppressAudits(true);
// the id should be set with the username!! But how to get from data?
Audit audit = tx.auditFrom(AccessType.CREATE, StrolchPrivilegeConstants.PRIVILEGE,
StrolchPrivilegeConstants.CERTIFICATE, "sso");
tx.getAuditTrail().add(tx, audit);
}
return certificate;
}
@Override
public PrivilegeContext validate(Certificate certificate) throws PrivilegeException {

View File

@ -42,6 +42,19 @@ public interface PrivilegeHandler {
* @see li.strolch.privilege.handler.PrivilegeHandler#authenticate(String, char[])
*/
Certificate authenticate(String username, char[] password);
/**
* Authenticates a user on a remote Single Sign On service. This is implemented by the
*
* @param data
* the data to perform the SSO
*
* @return the {@link Certificate} for the user
*
* @throws PrivilegeException
* if something goes wrong with the SSO
*/
Certificate authenticateSingleSignOn(Object data) throws PrivilegeException;
/**
* Returns the {@link PrivilegeContext} for the given certificate