/** * Serializes a LdapPrincipal instance. * * @param principal The LdapPrincipal instance to serialize * @param out The stream into which we will write the serialized instance * @throws IOException If the stream can't be written */ public static void serialize( LdapPrincipal principal, ObjectOutput out ) throws IOException { // The Authentication level out.writeInt( principal.getAuthenticationLevel().getLevel() ); // The principal's DN if ( principal.getDn() == null ) { Dn.EMPTY_DN.writeExternal( out ); } else { principal.getDn().writeExternal( out ); } }
/** * Creates a new instance of UnbindOperationContext. * * @param session The session to use */ public UnbindOperationContext( CoreSession session ) { super( session, session.getEffectivePrincipal().getDn() ); setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.UNBIND ) ); }
/** * Creates a new instance of UnbindOperationContext. * * @param session The session to use * @param unbindRequest The UnbindRequest to process */ public UnbindOperationContext( CoreSession session, UnbindRequest unbindRequest ) { super( session, session.getEffectivePrincipal().getDn() ); setRequestControls( unbindRequest.getControls() ); setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.UNBIND ) ); }
/** * {@inheritDoc} */ public void handleExtendedOperation( LdapSession requestor, WhoAmIRequest req ) throws Exception { LOG.debug( "WhoAmI requested" ); LdapPrincipal ldapPrincipal = requestor.getCoreSession().getAuthenticatedPrincipal(); WhoAmIResponse whoAmIResponse = new WhoAmIResponseImpl( req.getMessageId(), ResultCodeEnum.SUCCESS ); String authzId = "dn:" + ldapPrincipal.getDn(); whoAmIResponse.setAuthzId( Strings.getBytesUtf8( authzId ) ); // write the response requestor.getIoSession().write( whoAmIResponse ); }
boolean isAdmin = modifyContext.getSession().getAuthenticatedPrincipal().getDn().equals( adminDn );
Dn principalDn = requestor.getCoreSession().getEffectivePrincipal().getDn();
CoreSession userSession = ds.getSession( ldapPrincipal.getDn(), password, saslMechanism, null );
boolean isAdmin = addContext.getSession().getAuthenticatedPrincipal().getDn().equals( adminDn );