Example usage for org.springframework.security.ldap.userdetails InetOrgPerson getOu

List of usage examples for org.springframework.security.ldap.userdetails InetOrgPerson getOu

Introduction

In this page you can find the example usage for org.springframework.security.ldap.userdetails InetOrgPerson getOu.

Prototype

public String getOu() 

Source Link

Usage

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;
        }/*from  w ww.j a va2  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;
}