throws AuthenticationException {
try {
log.info("Clear CredentialCotntexts");
credentialManager.deactivateCredentialContexts(user);
String dn = credential.getName().toString();
CredentialContext context =
credentialManager.getCredentialContextByDn(dn);
if (context == null) {
log.info("No CredentialContext found for \"" + dn + "\"");
context = credentialManager.createCredentialContext(user, dn);
context.setLabel("tsukuba-gama");
} else if ( ! findContextOfUser(user, dn) ) {
log.info("Delete old credential context oid["
+ context.getOid() + "]");
credentialManager.deleteCredentialContext(context);
context = credentialManager.createCredentialContext(user, dn);
context.setLabel("tsukuba-gama");
} else {
log.info("Activate credential");
}
deleteOldCredentialContext(user, dn);
context.activate(credential);
credentialManager.saveCredentialContext(context);
} catch (GSSException e) {
throw new AuthenticationException(e.getMessage());
} catch (CredentialException e) {
log.error("Couldn't activate", e);