/** * Returns {@link LdapPrincipal} of current context. * * @param opContext TODO * @return the authenticated principal */ public static LdapPrincipal getPrincipal( OperationContext opContext ) { return opContext.getSession().getEffectivePrincipal(); }
protected Dn getOperationPrincipal() throws LdapInvalidDnException { Principal principal = opContext.getSession().getEffectivePrincipal(); return opContext.getSession().getDirectoryService().getDnFactory().create( principal.getName() ); }
private Object executeProcedure( OperationContext opContext, String procedure, Object[] values ) throws LdapException { try { Entry spUnit = manager.findStoredProcUnit( opContext.getSession(), procedure ); StoredProcEngine engine = manager.getStoredProcEngineInstance( spUnit ); return engine.invokeProcedure( opContext.getSession(), procedure, values ); } catch ( Exception e ) { LdapOtherException lne = new LdapOtherException( e.getMessage(), e ); lne.initCause( e ); throw lne; } } }
public boolean hasPermission( OperationContext opContext ) throws LdapException { Dn principalName = opContext.getSession().getEffectivePrincipal().getDn(); return principalName.equals( opContext.getSession().getDirectoryService().getAdminSession() .getAuthenticatedPrincipal().getDn() ); } }
public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws LdapInvalidDnException { // Return a safe copy constructed with user provided name. return opContext.getSession().getDirectoryService().getDnFactory().create( oldRdn.getName() ); } };
public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws LdapInvalidDnException { // Return a safe copy constructed with user provided name. return opContext.getSession().getDirectoryService().getDnFactory().create( newDn.getName() ); } };
public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws LdapInvalidDnException { // Return a safe copy constructed with user provided name. return opContext.getSession().getDirectoryService().getDnFactory().create( oldDn.getName() ); } };
public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws LdapInvalidDnException { // Return a safe copy constructed with user provided name. return opContext.getSession().getDirectoryService().getDnFactory().create( oldSuperiorDn.getName() ); } };
public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws LdapInvalidDnException { // Return a safe copy constructed with user provided name. return opContext.getSession().getDirectoryService().getDnFactory().create( newSuperiorDn.getName() ); } };
public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws LdapInvalidDnException { // Return a safe copy constructed with user provided name. return opContext.getSession().getDirectoryService().getDnFactory().create( newRdn.getName() ); } };
@Override public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws LdapInvalidDnException { // Return a safe copy constructed with user provided name. return opContext.getSession().getDirectoryService().getDnFactory().create( addedEntryName.getName() ); } };
public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws LdapInvalidDnException { // Return a safe copy constructed with user provided name. return opContext.getSession().getDirectoryService().getDnFactory().create( modifiedEntryName.getName() ); } };
public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws LdapException { // Return a safe copy constructed with user provided name. return opContext.getSession().getDirectoryService().getDnFactory().create( deletedEntryName.getName() ); } };
/** * Check if the current operation has a valid PrincipalDN or not. * * @param operation the operation type * @throws Exception */ private void checkAuthenticated( OperationContext operation ) throws LdapException { if ( operation.getSession().isAnonymous() && !directoryService.isAllowAnonymousAccess() && !operation.getDn().isEmpty() ) { String msg = I18n.err( I18n.ERR_5, operation.getName() ); LOG.error( msg ); throw new LdapNoPermissionException( msg ); } }
private Entry getEntry( OperationContext opContext ) throws LdapException { /** * Exclude operational attributes while doing lookup * especially subentry related ones like "triggerExecutionSubentries". */ CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, modifiedEntryName, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); return session.getDirectoryService().getPartitionNexus().lookup( lookupContext ); } }
String modifiersName = opContext.getSession().getEffectivePrincipal().getName(); String modifyTimestamp = DateUtils.getGeneralizedTime(); CoreSession session = opContext.getSession(); ModifyOperationContext modifyContext = new ModifyOperationContext( session, schemaModificationDN, mods ); modifyContext.setPartition( this );
private Entry getDeletedEntry( OperationContext opContext ) throws LdapException { /** * Using LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS here to exclude operational attributes * especially subentry related ones like "triggerExecutionSubentries". */ CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, deletedEntryName, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); return session.getDirectoryService().getPartitionNexus().lookup( lookupContext ); } }
@Override public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws LdapException { Generic_LDAP_CONTEXT ldapCtxParam = ( Generic_LDAP_CONTEXT ) param; Dn ldapCtxName = ldapCtxParam.getCtxName(); CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, ldapCtxName, SchemaConstants.ALL_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); return session.getDirectoryService().getPartitionNexus().lookup( lookupContext ); } };
/** * Get the administrativePoint role */ private void checkAdministrativeRole( OperationContext opContext, Dn apDn ) throws LdapException { CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, apDn, SchemaConstants.ALL_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); Entry administrationPoint = directoryService.getPartitionNexus().lookup( lookupContext ); // The administrativeRole AT must exist and not be null Attribute administrativeRole = administrationPoint.get( directoryService.getAtProvider() .getAdministrativeRole() ); // check that administrativeRole has something valid in it for us if ( ( administrativeRole == null ) || ( administrativeRole.size() <= 0 ) ) { LOG.error( "The entry on {} is not an AdministrativePoint", apDn ); throw new LdapNoSuchAttributeException( I18n.err( I18n.ERR_306, apDn ) ); } }
/** * Gets attributes required for modifications. * * @param dn the dn of the entry to get * @return the entry's attributes (may be immutable if the schema subentry) * @throws Exception on error accessing the entry's attributes */ private Entry getAttributes( OperationContext opContext ) throws LdapException { Dn dn = opContext.getDn(); Entry serverEntry; // @todo make sure we're not putting in operational attributes that cannot be user modified if ( dn.equals( ServerDNConstants.CN_SCHEMA_DN ) ) { return SchemaService.getSubschemaEntryCloned( directoryService ); } else { CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, dn, SchemaConstants.ALL_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); serverEntry = directoryService.getPartitionNexus().lookup( lookupContext ); } return serverEntry; } }