Subversion Repositories linid-dm

Compare Revisions

Rev 439 → Rev 442

/trunk/src/main/java/org/linid/dm/wui/t5lib/WuiCommonModule.java
61,6 → 61,7
import org.linid.dm.wui.t5lib.services.LdapTypeAnalyzer;
import org.linid.dm.wui.t5lib.services.LdapViewerAnalyzer;
import org.linid.dm.wui.t5lib.services.LocaleService;
import org.linid.dm.wui.t5lib.services.PasswordPolicyService;
import org.linid.dm.wui.t5lib.services.impl.BooleanTranslator;
import org.linid.dm.wui.t5lib.services.impl.DefaultAttributeValidatorAssignement;
import org.linid.dm.wui.t5lib.services.impl.DefaultLdapEditorAnalyzer;
70,6 → 71,7
import org.linid.dm.wui.t5lib.services.impl.ESchemaLdapOperatorTranslator;
import org.linid.dm.wui.t5lib.services.impl.IByteStringTranslator;
import org.linid.dm.wui.t5lib.services.impl.JpegFileFormatCheckerImpl;
import org.linid.dm.wui.t5lib.services.impl.PasswordPolicyServiceOpenLDAP;
import org.linid.dm.wui.t5lib.services.impl.PropertiesSymbolProvider;
import org.linid.dm.wui.validator.EqualsValidator;
import org.linid.dm.wui.validator.RequiredAttributeValidator;
330,6 → 332,7
public static void bind(ServiceBinder binder) {
binder.bind(JpegFileFormatChecker.class, JpegFileFormatCheckerImpl.class);
binder.bind(PasswordPolicyService.class, PasswordPolicyServiceOpenLDAP.class);
}
}
/trunk/src/main/java/org/linid/dm/wui/t5lib/services/impl/PasswordPolicyServiceOpenLDAP.java New file
0,0 → 1,78
/* *********************************************************
* This file is a part of LinID Directory Manager.
* This software is a computer program whose purpose is
* to manage electronic identity thanks to LDAP directories.
*
* ==LICENSE NOTICE==
* LinID Directory Manager is a free software subjected to the
* ** GNU Affero Public License ** as published by the
* Free Software Foundation, ** version 3 ** of the license.
*
* By application to section 7 in the GNU Affero GPLv3,
* dynamic and static links do not extend license to other
* softwares.
*
* You can redistribute and/or modify since you respect
* the term of the license.
*
* NOTICE : THIS LICENSE IS FREE OF CHARGE AND THE SOFTWARE
* IS DISTRIBUTED WITHOUT ANY WARRANTIES OF ANY KIND
*
* ==LICENSE NOTICE==
*
* (c) 2008-2013 Linagora - http://linagora.com/
********************************************************* */
 
package org.linid.dm.wui.t5lib.services.impl;
 
import javax.naming.InvalidNameException;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.DirContext;
import javax.naming.ldap.LdapName;
 
import org.apache.tapestry5.annotations.Service;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.linid.dm.ldap.core.LdapFacade;
import org.linid.dm.wui.t5lib.services.PasswordPolicyService;
 
public class PasswordPolicyServiceOpenLDAP implements PasswordPolicyService {
 
public static final String LOCK_ATTRIBUTE_NAME = "pwdAccountLockedTime";
public static final String LOCK_VALUE = "00000101000000Z";
@Inject @Service("wuiLdapFacade")
private LdapFacade wuiLdapFacade;
public void lockAccount(String entryDn) {
LdapName entryDnName;
try {
entryDnName = new LdapName(entryDn);
} catch (InvalidNameException e) {
return;
}
Attributes attributes = new BasicAttributes(LOCK_ATTRIBUTE_NAME, LOCK_VALUE);
wuiLdapFacade.modifyAttributes(entryDnName, DirContext.REPLACE_ATTRIBUTE, attributes);
}
public void unlockAccount(String entryDn) {
LdapName entryDnName;
try {
entryDnName = new LdapName(entryDn);
} catch (InvalidNameException e) {
return;
}
Attributes attributes = new BasicAttributes(LOCK_ATTRIBUTE_NAME, null);
wuiLdapFacade.modifyAttributes(entryDnName, DirContext.REPLACE_ATTRIBUTE, attributes);
}
public String getLockAttributeName() {
return LOCK_ATTRIBUTE_NAME;
}
}
/trunk/src/main/java/org/linid/dm/wui/t5lib/services/PasswordPolicyService.java New file
0,0 → 1,36
/* *********************************************************
* This file is a part of LinID Directory Manager.
* This software is a computer program whose purpose is
* to manage electronic identity thanks to LDAP directories.
*
* ==LICENSE NOTICE==
* LinID Directory Manager is a free software subjected to the
* ** GNU Affero Public License ** as published by the
* Free Software Foundation, ** version 3 ** of the license.
*
* By application to section 7 in the GNU Affero GPLv3,
* dynamic and static links do not extend license to other
* softwares.
*
* You can redistribute and/or modify since you respect
* the term of the license.
*
* NOTICE : THIS LICENSE IS FREE OF CHARGE AND THE SOFTWARE
* IS DISTRIBUTED WITHOUT ANY WARRANTIES OF ANY KIND
*
* ==LICENSE NOTICE==
*
* (c) 2008-2013 Linagora - http://linagora.com/
********************************************************* */
 
package org.linid.dm.wui.t5lib.services;
 
public interface PasswordPolicyService {
 
public void lockAccount(String entryDn);
public void unlockAccount(String entryDn);
public String getLockAttributeName();
}
trunk/src/main/java/org/linid/dm/wui/t5lib/services/PasswordPolicyService.java Property changes : Added: svn:mime-type + text/plain
/trunk/src/main/java/org/linid/dm/wui/t5lib/components/PpoliciesAccountLockManagement.java
27,9 → 27,6
import java.util.List;
 
import javax.naming.InvalidNameException;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.SearchControls;
import javax.naming.ldap.LdapName;
 
42,6 → 39,7
import org.linid.dm.ldap.core.LdapFacade;
import org.linid.dm.ldap.objects.IELdapAttribute;
import org.linid.dm.ldap.objects.IELdapEntry;
import org.linid.dm.wui.t5lib.services.PasswordPolicyService;
 
/**
* This component manage the status
59,10 → 57,6
*/
public class PpoliciesAccountLockManagement {
 
public static final String LOCK_ATTRIBUTE_NAME = "pwdAccountLockedTime";
public static final String LOCK_VALUE = "00000101000000Z";
 
public static final String UNLOCKED_EVENT ="account_unlocked";
public static final String LOCKED_EVENT ="account_locked";
90,6 → 84,9
private LdapFacade wuiLdapFacade;
@Inject
private PasswordPolicyService ppolicyService;
@Inject
private ComponentResources resources;
/* ***********************************************************
154,7 → 151,7
return;
}
 
SearchControls scs = new SearchControls(SearchControls.SUBTREE_SCOPE,0,0,new String[] { "objectClass", LOCK_ATTRIBUTE_NAME},true,true);
SearchControls scs = new SearchControls(SearchControls.SUBTREE_SCOPE,0,0,new String[] { "objectClass", ppolicyService.getLockAttributeName()},true,true);
List<IELdapEntry> entries = wuiLdapFacade.search(entryDnName, "(objectClass=*)", scs);
 
/*
163,7 → 160,7
*/
if (entries != null && entries.size() == 1) {
IELdapEntry entry = entries.get(0);
IELdapAttribute attribute = entry.getAttribute(LOCK_ATTRIBUTE_NAME);
IELdapAttribute attribute = entry.getAttribute(ppolicyService.getLockAttributeName());
if(null != attribute && null != attribute.getValue()) {
this.canUnlocked = true;
182,18 → 179,16
************************************************************ */
void onActionFromUnlock(String entryDn) throws InvalidNameException {
this.entryDnName = new LdapName(entryDn);
Attributes attributes = new BasicAttributes(LOCK_ATTRIBUTE_NAME, null);
wuiLdapFacade.modifyAttributes(this.entryDnName, DirContext.REPLACE_ATTRIBUTE, attributes);
ppolicyService.unlockAccount(entryDn);
this.resources.triggerEvent(UNLOCKED_EVENT, null, null);
}
 
void onActionFromLock(String entryDn) throws InvalidNameException {
this.entryDnName = new LdapName(entryDn);
Attributes attributes = new BasicAttributes(LOCK_ATTRIBUTE_NAME, LOCK_VALUE);
wuiLdapFacade.modifyAttributes(this.entryDnName, DirContext.REPLACE_ATTRIBUTE, attributes);
ppolicyService.lockAccount(entryDn);
 
this.resources.triggerEvent(LOCKED_EVENT, null, null);
}