Posts Tagged ‘Request for Comments’
Articoli recenti
- API-First with Swagger
- API-First con Swagger
- Importare (molteplici) repository SVN in Git
- Visual VM – Profiling della JVM durante l’esecuzione dei test Maven
- Ports Mongodb bloccato dopo l’aggiornamento a OS X Mavericks
- XDebug PHP Eclipse – Error No appropriate file located or no file selected
- MySQL Master/Slave in JEE enviroment
- MySQL Master/Slave in ambiente JEE
- É falso che vi non sia user-friendly
- javax.ejb.NoSuchEJBException after redeploying remote EJBs (JEE6)
- JSF 2.0: come (non) dichiarare la FacesServlet nel file web.xml
- Quartz Scheduler 2.x e JdbcJobStore con MySQL 5
- Eclipse e sviluppo JSF: content assist
- Usare i profili e il filtering di Maven
- ActiveMQ e le virtual Topics
application server
backend
bash
CDI
clone
cookie
dscl
dsconfig
eclipse
editor
EJB
ejb faq
Enterprise JavaBean
filter
git
github
gitignore
glassfish
glassfish embedded eclipse
HttpClient
HTTPOnly
InnoDB
Java
JavaEE
jee6
jersey
JNDI
JPA
JSF
launchdaemons
LDAP
mac os x
Master
maven
mongo
MySQL
mysql replication
open source
plist
profiling
Quartz Scheduler
Remote Debug
Request for Comments
rmi
shell
Slave
software
svn
Symfony
test
text editor
truss
UnboundID
vi
vim
visualvm
webfragment
XDebug
UnboundID – come scrivere un java.util.Date su ldap?
Image via CrunchBase
Devo fare la persistenza, sul mio LDAP preferito (OpenDJ) di un campo ‘data di nascita’ di un mio bean ‘profilo utente’.
Ovviamente il campo del mio bean e’ di tipo java.util.Date; utilizzando le api dell’SDK for Java di UnboundID per accedere al mio directory server LDAP, come posso fare?
La classe ‘com.unboundid.ldap.sdk.Entry‘ dell’SDK mette a disposizione i seguenti metodi per aggiungere un attributo ad una Entry:
public boolean addAttribute(Attribute attribute)
public boolean addAttribute(java.lang.String attributeName, java.lang.String attributeValue)
public boolean addAttribute(java.lang.String attributeName, byte[] attributeValue)
Nella RFC 2252 viene consigliata una rappresentazione alfanumerica (in formato stringa, printabile), chiamata ‘Generalized Time’; per ottenerla, partendo da un tipo java.util.Date, e’ sufficiente utilizzare un metodo statico di utilita’ dell’SDK, StaticUtils.encodeGeneralizedTime:
public static java.lang.String encodeGeneralizedTime(java.util.Date d)
Quindi, per riassumere, ecco cosa ho fatto:
entry.addAttribute(“birthDate”, StaticUtils.encodeGeneralizedTime(_type.getBirthDate()));
E anche questa e’ fatta ;)