List of usage examples for org.springframework.security.ldap.userdetails InetOrgPerson getPostalAddress
public String getPostalAddress()
From source file:net.maritimecloud.identityregistry.utils.AccessControlUtil.java
public static boolean isUserSync(String userSyncMRN, String userSyncO, String userSyncOU, String userSyncC) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth instanceof PreAuthenticatedAuthenticationToken) { log.debug("Certificate authentication of user sync'er in process"); // Certificate authentication PreAuthenticatedAuthenticationToken token = (PreAuthenticatedAuthenticationToken) auth; // Check that the Organization name of the accessed organization and the organization in the certificate is equal InetOrgPerson person = ((InetOrgPerson) token.getPrincipal()); if (userSyncMRN.equals(person.getUid()) && userSyncO.equals(person.getO()) // Hack alert! There is no country property in this type, so we misuse PostalAddress... && userSyncOU.equals(person.getOu()) && userSyncC.equals(person.getPostalAddress())) { log.debug("User sync'er accepted!"); return true; }// w w w . ja v a 2 s .co m log.debug("This was not the user-sync'er! " + userSyncMRN + "~" + person.getUid() + ", " + userSyncO + "~" + person.getO() + ", " + userSyncOU + "~" + person.getOu() + ", " + userSyncC + "~" + person.getPostalAddress()); } return false; }